Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Xunit version, migrate FSharpSuite.Tests to Xunit #17652

Merged
merged 11 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@
<RoslynToolsSignToolVersion>1.0.0-beta2-dev3</RoslynToolsSignToolVersion>
<StreamJsonRpcVersion>2.18.48</StreamJsonRpcVersion>
<NerdbankStreamsVersion>2.10.69</NerdbankStreamsVersion>
<XUnitVersion>2.4.1</XUnitVersion>
<XUnitRunnerVersion>2.4.2</XUnitRunnerVersion>
<XUnitVersion>2.9.0</XUnitVersion>
<XUnitRunnerVersion>2.8.2</XUnitRunnerVersion>
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
<HumanizerCoreVersion>2.2.0</HumanizerCoreVersion>
<!-- -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ namespace ErrorMessages

open Xunit
open FSharp.Test.Compiler
open FSharp.Test.Utilities
open NUnit.Framework
open FSharp.Compiler.Diagnostics
open FSharp.Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ let z = Project1.x
ReferencedProjects = [| FSharpReferencedProject.FSharpReference(MultiProjectDirty1.dllName, MultiProjectDirty1.getOptions()) |] }

[<Theory>]
[<InlineData(true)>]
// [<InlineData(true)>]
majocha marked this conversation as resolved.
Show resolved Hide resolved
[<InlineData(false)>]
let ``Test multi project symbols should pick up changes in dependent projects`` useTransparentCompiler =

Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/ProjectGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ module ProjectOperations =
expectOk result ()
Assert.NotEqual<string>(oldSignature, newSignature)

let expectSignatureContains expected result (_oldSignature, newSignature) =
let expectSignatureContains (expected: string) result (_oldSignature, newSignature) =
expectOk result ()
Assert.Contains(expected, newSignature)

Expand Down
17 changes: 1 addition & 16 deletions tests/FSharp.Test.Utilities/TestFramework.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open System.IO
open System.Reflection
open System.Diagnostics
open Scripting
open NUnit.Framework
open Xunit
open FSharp.Compiler.IO

let inline getTestsDirectory src dir = src ++ dir
Expand Down Expand Up @@ -463,21 +463,6 @@ let initializeSuite () =

let suiteHelpers = lazy (initializeSuite ())

[<AttributeUsage(AttributeTargets.Assembly)>]
majocha marked this conversation as resolved.
Show resolved Hide resolved
type public InitializeSuiteAttribute () =
inherit TestActionAttribute()

override x.BeforeTest details =
try
if details.IsSuite
then suiteHelpers.Force() |> ignore
with
| e -> raise (Exception("failed test suite initialization, debug code in InitializeSuiteAttribute", e))
override x.AfterTest _details =
()

override x.Targets = ActionTargets.Test ||| ActionTargets.Suite

let testConfig (testDir: string) =
let cfg = suiteHelpers.Value
if not (Path.IsPathRooted testDir) then
Expand Down
8 changes: 4 additions & 4 deletions tests/FSharp.Test.Utilities/Utilities.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ open System.Threading.Tasks
open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.CSharp
open TestFramework
open NUnit.Framework
open Xunit
open System.Collections.Generic
open FSharp.Compiler.CodeAnalysis
open Newtonsoft.Json
open Newtonsoft.Json.Linq


type TheoryForNETCOREAPPAttribute() =
inherit Xunit.TheoryAttribute()
inherit TheoryAttribute()
#if !NETCOREAPP
do base.Skip <- "Only NETCOREAPP is supported runtime for this kind of test."
#endif

type FactForNETCOREAPPAttribute() =
inherit Xunit.FactAttribute()
inherit FactAttribute()
#if !NETCOREAPP
do base.Skip <- "Only NETCOREAPP is supported runtime for this kind of test."
#endif

type FactForDESKTOPAttribute() =
inherit Xunit.FactAttribute()
inherit FactAttribute()
#if NETCOREAPP
do base.Skip <- "NETCOREAPP is not supported runtime for this kind of test, it is intended for DESKTOP only"
#endif
Expand Down
9 changes: 4 additions & 5 deletions tests/fsharp/Compiler/CodeGen/EmittedIL/BooleanLogic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL

open FSharp.Test
open NUnit.Framework
open Xunit

[<TestFixture>]
module BooleanLogic =

[<Test>]
[<Fact>]
let BooleanOrs() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions ([|"-g"; "--optimize+"|],
"""
Expand Down Expand Up @@ -54,7 +53,7 @@ let compute (x: int) =
"""
]))

[<TestFixture>]

// We had a regression in debug code regression where we were falsely marking pipelines
// as non-side-effecting, causing them to be eliminated in loops.
//
Expand All @@ -63,7 +62,7 @@ let compute (x: int) =
// 2. we don't eliminate loops anyway
module DontEliminateForLoopsInDebugCode =

[<Test>]
[<Fact>]
// See https://github.com/dotnet/fsharp/pull/12021
let Regression12021() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"-g"; "--optimize-"|],
Expand Down
5 changes: 2 additions & 3 deletions tests/fsharp/Compiler/CodeGen/EmittedIL/ByrefTailcalls.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL

open FSharp.Test
open NUnit.Framework
open Xunit

open System
open System.Threading.Tasks

[<TestFixture>]
module ByrefTailcalls =

[<Test>]
[<Fact>]
let ``check no tailcall to inref``() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions([| "/optimize";"/tailcalls" |],
"""
Expand Down
5 changes: 2 additions & 3 deletions tests/fsharp/Compiler/CodeGen/EmittedIL/CeEdiThrow.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL

open FSharp.Compiler.UnitTests
open NUnit.Framework
open Xunit
open FSharp.Test

[<TestFixture>]
module CeEdiThrow =

[<Test>]
[<Fact>]
let ``Emits EDI.Throw``() =
CompilerAssert.CompileLibraryAndVerifyIL(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL

open FSharp.Test
open NUnit.Framework
open Xunit

open System

#if !DEBUG // sensitive to debug-level code coming across from debug FSharp.Core
[<TestFixture>]

module ComputationExpressionOptimizations =

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
//
// This tests a number of code optimizations cooperating together.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL

open FSharp.Test
open NUnit.Framework
open Xunit


[<TestFixture>]
module ``ComputedListExpressions`` =

[<Test>]
[<Fact>]
let ``ComputedListExpression01``() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"-g"; "--optimize-"|],
"""
Expand All @@ -35,7 +35,7 @@ let ListExpressionSteppingTest1 () = [ yield 1 ]
"""
]))

[<Test>]
[<Fact>]
let ``ComputedListExpression02``() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"-g"; "--optimize-"|],
"""
Expand Down Expand Up @@ -78,7 +78,7 @@ let ListExpressionSteppingTest2 () =
"""
]))

[<Test>]
[<Fact>]
let ``ComputedListExpression03``() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions(
[|"-g"; "--optimize-"|],
Expand Down Expand Up @@ -128,7 +128,7 @@ let ListExpressionSteppingTest3 () =
"""
]))

[<Test>]
[<Fact>]
let ``ComputedListExpression04``() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"-g"; "--optimize-"|],
"""
Expand Down Expand Up @@ -212,7 +212,7 @@ let ListExpressionSteppingTest4 () =
"""
]))

[<Test>]
[<Fact>]
let ``ComputedListExpression05``() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"-g"; "--optimize-"|],
"""
Expand Down Expand Up @@ -275,7 +275,7 @@ let ListExpressionSteppingTest5 () =
}
"""]))

[<Test>]
[<Fact>]
let ``ComputedListExpression06``() =
CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"-g"; "--optimize-"|],
"""
Expand Down
10 changes: 5 additions & 5 deletions tests/fsharp/Compiler/CodeGen/EmittedIL/DebugScopes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL

open FSharp.Test
open NUnit.Framework
open Xunit


[<TestFixture>]
module DebugScopes =

[<Test>]
[<Fact>]
let SimpleFunction() =
CompilerAssert.CompileLibraryAndVerifyDebugInfoWithOptions(
[|"--debug:portable"; "--optimize-"; "--optimize-"|],
Expand All @@ -20,7 +20,7 @@ let f x =
2
""")

[<Test>]
[<Fact>]
let SimpleShadowingFunction() =
CompilerAssert.CompileLibraryAndVerifyDebugInfoWithOptions(
[|"--debug:portable"; "--optimize-"; "--optimize-"|],
Expand All @@ -34,7 +34,7 @@ let f x =
2
""")

[<Test>]
[<Fact>]
let ComplexShadowingFunction() =
CompilerAssert.CompileLibraryAndVerifyDebugInfoWithOptions(
[|"--debug:portable"; "--optimize-"; "--optimize-"|],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL

open FSharp.Test
open NUnit.Framework
open Xunit

#if !DEBUG // sensitive to debug-level code coming across from debug FSharp.Core
[<TestFixture>]

module DelegateAndFuncOptimizations =

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
let ``Reduce function via InlineIfLambda``() =
CompilerAssert.CompileLibraryAndVerifyIL(
Expand Down Expand Up @@ -153,7 +153,7 @@ type C =
"""
]))

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
let ``Reduce delegate invoke via InlineIfLambda``() =
CompilerAssert.CompileLibraryAndVerifyIL(
Expand Down Expand Up @@ -301,7 +301,7 @@ type C =
"""
]))

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
let ``Reduce computed function invoke``() =
CompilerAssert.CompileLibraryAndVerifyIL(
Expand Down Expand Up @@ -341,7 +341,7 @@ let ApplyComputedFunction(c: int) =
"""
]))

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
let ``Reduce Computed Delegate``() =
CompilerAssert.CompileLibraryAndVerifyIL(
Expand Down Expand Up @@ -381,7 +381,7 @@ let ApplyComputedDelegate(c: int) =
"""
]))

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
let ``Reduce Computed Function with irreducible match``() =
CompilerAssert.CompileLibraryAndVerifyIL(
Expand Down Expand Up @@ -433,7 +433,7 @@ let ApplyComputedFunction(c: int) =
"""
]))

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
let ``Immediately apply computed function in sequential``() =
CompilerAssert.CompileLibraryAndVerifyIL(
Expand Down Expand Up @@ -492,7 +492,7 @@ let ApplyComputedFunction(c: int) =
"""
]))

[<Test>]
[<Fact>]
// See https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1034-lambda-optimizations.md
// See also https://github.com/dotnet/fsharp/issues/17607 for a regression caused by realsig+ becoming default
// This test case must keep using direct call to ReduceComputedDelegate, and not a FSharpFunc invocation.
Expand Down
Loading
Loading