Skip to content

Commit 14deae1

Browse files
ratsclubMichał Niegrzybowski
andauthored
Remove deprecated code (#449)
Co-authored-by: Michał Niegrzybowski <mniegrzybowski@datto.com>
1 parent 9dc40a9 commit 14deae1

5 files changed

Lines changed: 44 additions & 97 deletions

File tree

Expecto.Tests.CSharp/Tests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Expecto.CSharp;
55
using Expecto;
66
using static Expecto.Impl;
7+
using static Expecto.Tests.CLIArguments;
78

89
namespace Test.CSharp
910
{
@@ -86,12 +87,12 @@ public class Samples
8687

8788
public static int Main(string[] args)
8889
{
89-
var config =
90-
Runner.DefaultConfig
91-
.AddPrinter(new CSharpPrinter())
92-
.AddNUnitSummary("bin/Expecto.Tests.CSharp.TestResults.xml")
93-
.AddJUnitSummary("bin/Expecto.Tests.CSharp.TestResults.junit.xml");
94-
return Runner.RunTestsInAssembly(config, args);
90+
Tests.CLIArguments[] config = new[]
91+
{
92+
NewNUnit_Summary("bin/Expecto.Tests.CSharp.TestResults.xml"),
93+
NewJUnit_Summary("bin/Expecto.Tests.CSharp.TestResults.junit.xml"),
94+
};
95+
return Runner.RunTestsInAssemblyWithCLIArgs(config, args);
9596
}
9697
}
9798
}

Expecto.Tests/Tests.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ let expecto =
510510
"--fscheck-max-tests"; "5"
511511
"--fscheck-start-size"; "10"
512512
"--fscheck-end-size"; "20"
513-
"--my-spirit-is-weak"
514513
"--allow-duplicate-names"
515514
"--no-spinner"
516515
"--colours"; "256"
@@ -538,7 +537,6 @@ let expecto =
538537
FsCheck_Max_Tests 5
539538
FsCheck_Start_Size 10
540539
FsCheck_End_Size 20
541-
My_Spirit_Is_Weak
542540
Allow_Duplicate_Names
543541
No_Spinner
544542
Colours 256

Expecto/CSharp.fs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace Expecto.CSharp
33
#nowarn "46"
44

55
open System
6+
open System.Threading
67
open System.Threading.Tasks
78
open System.Runtime.CompilerServices
89
open System.Runtime.InteropServices
@@ -47,10 +48,10 @@ module Runner =
4748
Async.AwaitTask tcs.Task
4849

4950
let RunTests(config, tests) = runEval config tests
50-
let RunTestsWithArgs(config, args, tests) = runTestsWithArgs config args tests
5151
let RunTestsWithCLIArgs(cliArgs, args, tests) = runTestsWithCLIArgs cliArgs args tests
52-
let RunTestsInAssembly(config, args) = runTestsInAssembly config args
52+
let RunTestsWithCLIArgsAndCancel(ct, cliArgs, args, tests) = runTestsWithCLIArgsAndCancel ct cliArgs args tests
5353
let RunTestsInAssemblyWithCLIArgs(cliArgs, args) = runTestsInAssemblyWithCLIArgs cliArgs args
54+
let RunTestsInAssemblyWithCLIArgsAndCancel(ct, cliArgs, args) = runTestsInAssemblyWithCLIArgsAndCancel ct cliArgs args
5455
let ListTests(config, tests) = listTests config tests
5556
let TestList(name, tests: IEnumerable<Test>) = testList name (List.ofSeq tests)
5657
[<CompiledName("TestCase")>]
@@ -131,9 +132,6 @@ module Runner =
131132
[<Extension; CompiledName("WithFsCheckEndSize")>]
132133
member x.WithFsCheckEndSize(fsCheckEndSize) = { x with fsCheckEndSize = fsCheckEndSize }
133134

134-
[<Extension; CompiledName("WithMySpiritIsWeak")>]
135-
member x.WithMySpiritIsWeak(mySpiritIsWeak) = { x with mySpiritIsWeak = mySpiritIsWeak }
136-
137135
[<Extension; CompiledName("WithAllowDuplicateNames")>]
138136
member x.WithAllowDuplicateNames(allowDuplicateNames) = { x with allowDuplicateNames = allowDuplicateNames }
139137

Expecto/Expecto.Impl.fs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,6 @@ module Impl =
512512
/// FsCheck end size (default: 100 for testing and 10,000 for
513513
/// stress testing).
514514
fsCheckEndSize: int option
515-
/// Deprecated. Will be removed on next major release.
516-
mySpiritIsWeak: bool
517515
/// Allows duplicate test names.
518516
allowDuplicateNames: bool
519517
/// Disable spinner progress update.
@@ -544,7 +542,6 @@ module Impl =
544542
fsCheckMaxTests = 100
545543
fsCheckStartSize = 1
546544
fsCheckEndSize = None
547-
mySpiritIsWeak = false
548545
allowDuplicateNames = false
549546
noSpinner = false
550547
colour = Colour8

Expecto/Expecto.fs

Lines changed: 34 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ module Tests =
360360
| Summary_Location
361361
/// Print out version information.
362362
| Version
363-
/// Deprecated
364-
| My_Spirit_Is_Weak
365363
/// Allow duplicate test names.
366364
| Allow_Duplicate_Names
367365
/// Disable the spinner progress update.
@@ -400,7 +398,6 @@ module Tests =
400398
"--fscheck-max-tests", "Set FsCheck maximum number of tests (default: 100).", Args.number FsCheck_Max_Tests
401399
"--fscheck-start-size", "Set FsCheck start size (default: 1).", Args.number FsCheck_Start_Size
402400
"--fscheck-end-size", "Set FsCheck end size (default: 100 for testing and 10,000 for stress testing).", Args.number FsCheck_End_Size
403-
"--my-spirit-is-weak", Args.deprecated, Args.none My_Spirit_Is_Weak
404401
"--allow-duplicate-names", "Allow duplicate test names.", Args.none Allow_Duplicate_Names
405402
"--colours", "Set the level of colours to use. Can be 0, 8 (default) or 256.", Args.number Colours
406403
"--no-spinner", "Disable the spinner progress update.", Args.none No_Spinner
@@ -448,7 +445,6 @@ module Tests =
448445
| FsCheck_Max_Tests n -> fun o -> {o with fsCheckMaxTests = n }
449446
| FsCheck_Start_Size n -> fun o -> {o with fsCheckStartSize = n }
450447
| FsCheck_End_Size n -> fun o -> {o with fsCheckEndSize = Some n }
451-
| My_Spirit_Is_Weak -> id
452448
| Allow_Duplicate_Names -> fun o -> { o with allowDuplicateNames = true }
453449
| No_Spinner -> fun o -> { o with noSpinner = true }
454450
| Colours i -> fun o -> { o with colour =
@@ -533,51 +529,43 @@ module Tests =
533529
| _, x :: _ :: _ -> Some x.name
534530
| _ -> None
535531
)
536-
/// Runs tests with the supplied config.
532+
533+
/// Runs all given tests with the supplied typed command-line options.
537534
/// Returns 0 if all tests passed, otherwise 1
538-
/// Deprecated: please use runTestsWithCLIArgsAndCancel.
539-
[<Obsolete("Deprecated: please use runTestsWithCLIArgsAndCancel")>]
540-
let runTestsWithCancel (ct:CancellationToken) config (tests:Test) =
541-
ANSIOutputWriter.setColourLevel config.colour
542-
Global.initialiseIfDefault
543-
{ Global.defaultConfig with
544-
getLogger = fun name ->
545-
LiterateConsoleTarget(
546-
name, config.verbosity,
547-
consoleSemaphore = Global.semaphore()) :> Logger
548-
}
549-
config.logName |> Option.iter setLogName
550-
if config.failOnFocusedTests && passesFocusTestCheck config tests |> not then
551-
1
552-
else
553-
let fTests = config.filter tests
554-
let duplicates = lazy duplicatedNames config.joinWith fTests
555-
if config.allowDuplicateNames || List.isEmpty duplicates.Value then
556-
let retCode =
557-
match config.stress with
558-
| None -> runEvalWithCancel ct config fTests |> Async.RunSynchronously
559-
| Some _ -> runStressWithCancel ct config fTests |> Async.RunSynchronously
560-
afterRunTestsInvoke()
561-
retCode
562-
else
563-
sprintf "Found duplicated test names, these names are: %A" duplicates.Value
564-
|> config.printer.info
565-
|> Async.RunSynchronously
566-
ANSIOutputWriter.close()
535+
let runTestsWithCLIArgsAndCancel (ct:CancellationToken) cliArgs args tests =
536+
let runTestsWithCancel (ct:CancellationToken) config (tests:Test) =
537+
ANSIOutputWriter.setColourLevel config.colour
538+
Global.initialiseIfDefault
539+
{ Global.defaultConfig with
540+
getLogger = fun name ->
541+
LiterateConsoleTarget(
542+
name, config.verbosity,
543+
consoleSemaphore = Global.semaphore()) :> Logger
544+
}
545+
config.logName |> Option.iter setLogName
546+
if config.failOnFocusedTests && passesFocusTestCheck config tests |> not then
567547
1
548+
else
549+
let fTests = config.filter tests
550+
let duplicates = lazy duplicatedNames config.joinWith fTests
551+
if config.allowDuplicateNames || List.isEmpty duplicates.Value then
552+
let retCode =
553+
match config.stress with
554+
| None -> runEvalWithCancel ct config fTests |> Async.RunSynchronously
555+
| Some _ -> runStressWithCancel ct config fTests |> Async.RunSynchronously
556+
afterRunTestsInvoke()
557+
retCode
558+
else
559+
sprintf "Found duplicated test names, these names are: %A" duplicates.Value
560+
|> config.printer.info
561+
|> Async.RunSynchronously
562+
ANSIOutputWriter.close()
563+
1
568564

569-
/// Runs tests with the supplied config.
570-
/// Returns 0 if all tests passed, otherwise 1
571-
/// Deprecated: please use runTestsWithCLIArgs.
572-
[<Obsolete("Deprecated: please use runTestsWithCLIArgs")>]
573-
let runTests config tests =
574-
runTestsWithCancel CancellationToken.None config tests
565+
let config =
566+
Seq.fold (fun s a -> foldCLIArgumentToConfig a s)
567+
ExpectoConfig.defaultConfig cliArgs
575568

576-
/// Runs all given tests with the supplied command-line options.
577-
/// Returns 0 if all tests passed, otherwise 1
578-
/// Deprecated: please use runTestsWithCLIArgsAndCancel
579-
[<Obsolete("Deprecated: please use runTestsWithCLIArgsAndCancel")>]
580-
let runTestsWithArgsAndCancel (ct:CancellationToken) config args tests =
581569
match ExpectoConfig.fillFromArgs config args with
582570
| ArgsUsage (usage, errors) ->
583571
if not (List.isEmpty errors) then
@@ -593,51 +581,16 @@ module Tests =
593581
printfn "EXPECTO! v%s\n" expectoVersion
594582
runTestsWithCancel ct config tests
595583

596-
/// Runs all given tests with the supplied typed command-line options.
597-
/// Returns 0 if all tests passed, otherwise 1
598-
let runTestsWithCLIArgsAndCancel (ct:CancellationToken) cliArgs args tests =
599-
let config =
600-
Seq.fold (fun s a -> foldCLIArgumentToConfig a s)
601-
ExpectoConfig.defaultConfig cliArgs
602-
runTestsWithArgsAndCancel ct config args tests
603-
604-
/// Runs all given tests with the supplied command-line options.
605-
/// Returns 0 if all tests passed, otherwise 1
606-
/// Deprecated: please use runTestsWithCLIArgs
607-
[<Obsolete("Deprecated: please use runTestsWithCLIArgs")>]
608-
let runTestsWithArgs config args tests =
609-
runTestsWithArgsAndCancel CancellationToken.None config args tests
610-
611584
/// Runs all given tests with the supplied typed command-line options.
612585
/// Returns 0 if all tests passed, otherwise 1
613586
let runTestsWithCLIArgs cliArgs args tests =
614587
runTestsWithCLIArgsAndCancel CancellationToken.None cliArgs args tests
615588

616-
/// Runs tests in this assembly with the supplied command-line options.
617-
/// Returns 0 if all tests passed, otherwise 1
618-
/// Deprecated: please use runTestsInAssemblyWithCLIArgsAndCancel
619-
[<Obsolete("Deprecated: please use runTestsInAssemblyWithCLIArgsAndCancel")>]
620-
let runTestsInAssemblyWithCancel (ct:CancellationToken) config args =
621-
let config = { config with locate = getLocation (Assembly.GetEntryAssembly()) }
622-
testFromThisAssembly ()
623-
|> Option.orDefault (TestList ([], Normal))
624-
|> runTestsWithArgsAndCancel ct config args
625-
626589
/// Runs tests in this assembly with the supplied command-line options.
627590
/// Returns 0 if all tests passed, otherwise 1
628591
let runTestsInAssemblyWithCLIArgsAndCancel (ct:CancellationToken) cliArgs args =
629-
let config = { ExpectoConfig.defaultConfig
630-
with locate = getLocation (Assembly.GetEntryAssembly()) }
631-
let config = Seq.fold (fun s a -> foldCLIArgumentToConfig a s) config cliArgs
632592
let tests = testFromThisAssembly() |> Option.orDefault (TestList ([], Normal))
633-
runTestsWithArgsAndCancel ct config args tests
634-
635-
/// Runs tests in this assembly with the supplied command-line options.
636-
/// Returns 0 if all tests passed, otherwise 1
637-
/// Deprecated: please use runTestsInAssemblyWithCLIArgs
638-
[<Obsolete("Deprecated: please use runTestsInAssemblyWithCLIArgs")>]
639-
let runTestsInAssembly config args =
640-
runTestsInAssemblyWithCancel CancellationToken.None config args
593+
runTestsWithCLIArgsAndCancel ct cliArgs args tests
641594

642595
/// Runs tests in this assembly with the supplied command-line options.
643596
/// Returns 0 if all tests passed, otherwise 1

0 commit comments

Comments
 (0)