Skip to content

Commit cd736c4

Browse files
Removing Nunit from utils (#17770)
* Migrate last Nunit tests to Xunit * up * up * up * Update TestLib.LanguageService.fs * up * up * up * Remove unused tests * one more * Salsa * up * up * up * Update FsUnit.fs * Up * Update AsyncTests.fs --------- Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
1 parent 2907d59 commit cd736c4

File tree

27 files changed

+195
-463
lines changed

27 files changed

+195
-463
lines changed

src/FSharp.Build/Fsc.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,10 @@ type public Fsc() as this =
786786
let builder = generateCommandLineBuilder ()
787787
builder.GetCapturedArguments() |> String.concat Environment.NewLine
788788

789-
// expose this to internal components (for nunit testing)
789+
// expose this to internal components (for unit testing)
790790
member internal fsc.InternalGenerateCommandLineCommands() = fsc.GenerateCommandLineCommands()
791791

792-
// expose this to internal components (for nunit testing)
792+
// expose this to internal components (for unit testing)
793793
member internal fsc.InternalGenerateResponseFileCommands() = fsc.GenerateResponseFileCommands()
794794

795795
member internal fsc.InternalExecuteTool(pathToTool, responseFileCommands, commandLineCommands) =

src/FSharp.Build/Fsi.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ type public Fsi() as this =
388388
let builder = generateCommandLineBuilder ()
389389
builder.GetCapturedArguments() |> String.concat Environment.NewLine
390390

391-
// expose this to internal components (for nunit testing)
391+
// expose this to internal components (for unit testing)
392392
member internal fsi.InternalGenerateCommandLineCommands() = fsi.GenerateCommandLineCommands()
393393

394-
// expose this to internal components (for nunit testing)
394+
// expose this to internal components (for unit testing)
395395
member internal fsi.InternalGenerateResponseFileCommands() = fsi.GenerateResponseFileCommands()
396396

397397
member internal fsi.InternalExecuteTool(pathToTool, responseFileCommands, commandLineCommands) =

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/CompilationFromCmdlineArgsTests.fs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ module CompilationFromCmdlineArgsTests =
55
open System
66
open System.IO
77
open FSharp.Compiler.CodeAnalysis
8-
open NUnit.Framework
8+
open Xunit
99
open CompilationTests
1010

1111
// Point to a generated args.txt file.
1212
// Use scrape.fsx to generate an args.txt from a binary log file.
1313
// The path needs to be absolute.
14-
let localProjects: string list =
14+
let localProjects =
1515
[
1616
@"C:\Projects\fantomas\src\Fantomas.Core\Fantomas.Core.args.txt"
1717
@"C:\Projects\FsAutoComplete\src\FsAutoComplete\FsAutoComplete.args.txt"
1818
@"C:\Projects\fsharp\src\Compiler\FSharp.Compiler.Service.args.txt"
1919
@"C:\Projects\fsharp\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.args.txt"
20-
]
20+
] |> Seq.map (fun p -> [| box p |])
2121

2222
let checker = FSharpChecker.Create()
2323

@@ -43,16 +43,16 @@ module CompilationFromCmdlineArgsTests =
4343
for diag in diagnostics do
4444
printfn "%A" diag
4545

46-
Assert.That(exitCode, Is.Zero)
46+
Assert.Equal(exitCode, 0)
4747
finally
4848
Environment.CurrentDirectory <- oldWorkDir
4949

50-
[<TestCaseSource(nameof localProjects)>]
51-
[<Explicit("Slow, only useful as a sanity check that the test codebase is sound and type-checks using the old method")>]
50+
[<MemberData(nameof localProjects)>]
51+
[<Theory(Skip = "Slow, only useful as a sanity check that the test codebase is sound and type-checks using the old method")>]
5252
let ``Test sequential type-checking`` (projectArgumentsFilePath: string) =
5353
testCompilerFromArgs Method.Sequential projectArgumentsFilePath
5454

55-
[<TestCaseSource(nameof localProjects)>]
56-
[<Explicit("This only runs with the explicitly mentioned projects above")>]
55+
[<MemberData(nameof localProjects)>]
56+
[<Theory(Skip = "This should only run with the explicitly mentioned projects above")>]
5757
let ``Test graph-based type-checking`` (projectArgumentsFilePath: string) =
5858
testCompilerFromArgs Method.Graph projectArgumentsFilePath

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/DependencyResolutionTests.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
module TypeChecks.DependencyResolutionTests
22

33
open TypeChecks.TestUtils
4-
open NUnit.Framework
4+
open Xunit
55
open FSharp.Compiler.GraphChecking
66
open Scenarios
77

8-
[<TestCaseSource(nameof scenarios)>]
8+
let scenarios = scenarios |> Seq.map (fun p -> [| box p |])
9+
10+
[<Theory>]
11+
[<MemberData(nameof scenarios)>]
912
let ``Supported scenario`` (scenario: Scenario) =
1013
let files =
1114
scenario.Files
@@ -18,4 +21,4 @@ let ``Supported scenario`` (scenario: Scenario) =
1821
for file in scenario.Files do
1922
let expectedDeps = file.ExpectedDependencies
2023
let actualDeps = set graph.[file.Index]
21-
Assert.AreEqual(expectedDeps, actualDeps, $"Dependencies don't match for {System.IO.Path.GetFileName file.FileName}")
24+
Assert.True((expectedDeps = actualDeps), $"Dependencies don't match for {System.IO.Path.GetFileName file.FileName}")

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TypeChecks.FileContentMappingTests
22

3-
open NUnit.Framework
3+
open Xunit
44
open FSharp.Compiler.GraphChecking
55
open TestUtils
66

@@ -35,7 +35,7 @@ let private (|NestedModule|_|) value e =
3535
| FileContentEntry.NestedModule(name, nestedContent) -> if name = value then Some(nestedContent) else None
3636
| _ -> None
3737

38-
[<Test>]
38+
[<Fact>]
3939
let ``Top level module only exposes namespace`` () =
4040
let content =
4141
getContent
@@ -45,10 +45,10 @@ module X.Y.Z
4545
"""
4646

4747
match content with
48-
| [ TopLevelNamespace "X.Y" [] ] -> Assert.Pass()
48+
| [ TopLevelNamespace "X.Y" [] ] -> ()
4949
| content -> Assert.Fail($"Unexpected content: {content}")
5050

51-
[<Test>]
51+
[<Fact>]
5252
let ``Top level namespace`` () =
5353
let content =
5454
getContent
@@ -58,10 +58,10 @@ namespace X.Y
5858
"""
5959

6060
match content with
61-
| [ TopLevelNamespace "X.Y" [] ] -> Assert.Pass()
61+
| [ TopLevelNamespace "X.Y" [] ] -> ()
6262
| content -> Assert.Fail($"Unexpected content: {content}")
6363

64-
[<Test>]
64+
[<Fact>]
6565
let ``Open statement in top level module`` () =
6666
let content =
6767
getContent
@@ -73,10 +73,10 @@ open A.B.C
7373
"""
7474

7575
match content with
76-
| [ TopLevelNamespace "X.Y" [ OpenStatement "A.B.C" ] ] -> Assert.Pass()
76+
| [ TopLevelNamespace "X.Y" [ OpenStatement "A.B.C" ] ] -> ()
7777
| content -> Assert.Fail($"Unexpected content: {content}")
7878

79-
[<Test>]
79+
[<Fact>]
8080
let ``PrefixedIdentifier in type annotation`` () =
8181
let content =
8282
getContent
@@ -88,10 +88,10 @@ let fn (a: A.B.CType) = ()
8888
"""
8989

9090
match content with
91-
| [ TopLevelNamespace "X.Y" [ PrefixedIdentifier "A.B" ] ] -> Assert.Pass()
91+
| [ TopLevelNamespace "X.Y" [ PrefixedIdentifier "A.B" ] ] -> ()
9292
| content -> Assert.Fail($"Unexpected content: {content}")
9393

94-
[<Test>]
94+
[<Fact>]
9595
let ``Nested module`` () =
9696
let content =
9797
getContent
@@ -104,10 +104,10 @@ module Z =
104104
"""
105105

106106
match content with
107-
| [ TopLevelNamespace "X" [ NestedModule "Z" [] ] ] -> Assert.Pass()
107+
| [ TopLevelNamespace "X" [ NestedModule "Z" [] ] ] -> ()
108108
| content -> Assert.Fail($"Unexpected content: {content}")
109109

110-
[<Test>]
110+
[<Fact>]
111111
let ``Single ident module abbreviation`` () =
112112
let content =
113113
getContent
@@ -119,13 +119,13 @@ module B = C
119119
"""
120120

121121
match content with
122-
| [ TopLevelNamespace "" [ PrefixedIdentifier "C" ] ] -> Assert.Pass()
122+
| [ TopLevelNamespace "" [ PrefixedIdentifier "C" ] ] -> ()
123123
| content -> Assert.Fail($"Unexpected content: {content}")
124124

125125

126126
module InvalidSyntax =
127127

128-
[<Test>]
128+
[<Fact>]
129129
let ``Nested module`` () =
130130
let content =
131131
getContent
@@ -137,11 +137,11 @@ module InvalidSyntax =
137137
"""
138138

139139
match content with
140-
| [ TopLevelNamespace "" [] ] -> Assert.Pass()
140+
| [ TopLevelNamespace "" [] ] -> ()
141141
| content -> Assert.Fail($"Unexpected content: {content}")
142142

143143

144-
[<Test>]
144+
[<Fact>]
145145
let ``Module above namespace`` () =
146146
let content =
147147
getContent
@@ -153,5 +153,5 @@ module InvalidSyntax =
153153
"""
154154

155155
match content with
156-
| [ TopLevelNamespace "" [] ] -> Assert.Pass()
156+
| [ TopLevelNamespace "" [] ] -> ()
157157
| content -> Assert.Fail($"Unexpected content: {content}")

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/GraphProcessingTests.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
open System.Threading
44
open FSharp.Compiler.GraphChecking.GraphProcessing
5-
open NUnit.Framework
5+
open Xunit
66

7-
[<Test>]
7+
[<Fact>]
88
let ``When processing a node throws an exception, an exception is raised with the original exception included`` () =
99
let graph = [1, [|2|]; 2, [||]] |> readOnlyDict
1010
let work (_processor : int -> ProcessedNode<int, string>) (_node : NodeInfo<int>) : string = failwith "Work exception"
@@ -18,6 +18,6 @@ let ``When processing a node throws an exception, an exception is raised with th
1818
CancellationToken.None
1919
|> ignore
2020
)
21-
Assert.That(exn.Message, Is.EqualTo("Encountered exception when processing item '2'"))
22-
Assert.That(exn.InnerException, Is.Not.Null)
23-
Assert.That(exn.InnerException.Message, Is.EqualTo("Work exception"))
21+
Assert.Equal(exn.Message, "Encountered exception when processing item '2'")
22+
Assert.NotNull(exn.InnerException)
23+
Assert.Equal(exn.InnerException.Message, "Work exception")

tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/QueryTrieTests.fs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
open System.Collections.Generic
44
open System.Collections.Immutable
5-
open NUnit.Framework
5+
open Xunit
66
open FSharp.Compiler.GraphChecking
77
open FSharp.Compiler.GraphChecking.DependencyResolution
88

@@ -757,35 +757,35 @@ let private fantomasCoreTrie: TrieNode =
757757
|]
758758
}
759759

760-
[<Test>]
760+
[<Fact>]
761761
let ``Query nonexistent node in trie`` () =
762762
let result =
763763
queryTrie fantomasCoreTrie [ "System"; "System"; "Runtime"; "CompilerServices" ]
764764

765765
match result with
766-
| QueryTrieNodeResult.NodeDoesNotExist -> Assert.Pass()
766+
| QueryTrieNodeResult.NodeDoesNotExist -> ()
767767
| result -> Assert.Fail $"Unexpected result: %A{result}"
768768

769-
[<Test>]
769+
[<Fact>]
770770
let ``Query node that does not expose data in trie`` () =
771771
let result = queryTrie fantomasCoreTrie [ "Fantomas"; "Core" ]
772772

773773
match result with
774-
| QueryTrieNodeResult.NodeDoesNotExposeData -> Assert.Pass()
774+
| QueryTrieNodeResult.NodeDoesNotExposeData -> ()
775775
| result -> Assert.Fail $"Unexpected result: %A{result}"
776776

777-
[<Test>]
777+
[<Fact>]
778778
let ``Query module node that exposes one file`` () =
779779
let result =
780780
queryTrie fantomasCoreTrie [ "Fantomas"; "Core"; "ISourceTextExtensions" ]
781781

782782
match result with
783783
| QueryTrieNodeResult.NodeExposesData file ->
784784
let file = Seq.exactlyOne file
785-
Assert.AreEqual(indexOf "ISourceTextExtensions.fs", file)
785+
Assert.Equal(indexOf "ISourceTextExtensions.fs", file)
786786
| result -> Assert.Fail $"Unexpected result: %A{result}"
787787

788-
[<Test>]
788+
[<Fact>]
789789
let ``ProcessOpenStatement full path match`` () =
790790
let state =
791791
FileContentQueryState.Create Set.empty
@@ -794,4 +794,4 @@ let ``ProcessOpenStatement full path match`` () =
794794
processOpenPath fantomasCoreTrie [ "Fantomas"; "Core"; "AstExtensions" ] state
795795

796796
let dep = Seq.exactlyOne result.FoundDependencies
797-
Assert.AreEqual(indexOf "AstExtensions.fsi", dep)
797+
Assert.Equal(indexOf "AstExtensions.fsi", dep)

0 commit comments

Comments
 (0)