Skip to content

Commit

Permalink
Fix FSharpSuite net472 xUnit migration (#17660)
Browse files Browse the repository at this point in the history
* fix quotes test, update readme

* Update SpanTests.fs

---------

Co-authored-by: Petr <[email protected]>
  • Loading branch information
majocha and psfinaki authored Sep 3, 2024
1 parent bb027e1 commit f18511f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/fsharp/Compiler/Language/SpanTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ type T(span: Span<byte>) = struct end
"""
[| |]

[<Test>]
[<Fact>]
let ``A byref struct with custom attr can be passed as typar``() =
CompilerAssert.TypeCheckWithErrors """
namespace System.Runtime.CompilerServices
Expand All @@ -193,4 +193,4 @@ module WhatEver =
let processT (a: Action<T>, ie: seq<T>, asList: list<T>) = ()
"""
[| FSharpDiagnosticSeverity.Error, 3300, (13, 45, 13, 51), "The parameter 'asList' has an invalid type 'T list'. This is not permitted by the rules of Common IL." |]
#endif
#endif
6 changes: 5 additions & 1 deletion tests/fsharp/FSharpSuite.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Compile Include="..\scripts\scriptlib.fsx">
<Link>scriptlib.fsx</Link>
</Compile>
<Compile Include="NUnitHelpers.fs" />
<Compile Include="XunitHelpers.fs" />
<Compile Include="HandleExpects.fs" />
<Compile Include="single-test.fs" />
<Compile Include="TypeProviderTests.fs" />
Expand Down Expand Up @@ -100,6 +100,10 @@
<EmbeddedResource Remove="**" />
</ItemGroup>

<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Build\FSharp.Build.fsproj" />
<ProjectReference Include="$(FSharpSourcesRoot)\Compiler\FSharp.Compiler.Service.fsproj" />
Expand Down
File renamed without changes.
Binary file added tests/fsharp/core/quotes/cslib.dll
Binary file not shown.
12 changes: 6 additions & 6 deletions tests/fsharp/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Layout

The tests are NUNIT test cases. They test a very wide range of compiler, interactive and FSharp.Core scenarios.
The tests are xUnit test cases. They test a very wide range of compiler, interactive and FSharp.Core scenarios.

The bulk of the test cases are enumerated in tests.fs, these are the old cambridge test suite. They build on a test-suite ported from windows batch files. They run the compiler and fsi as separate processes, when built for the coreclr it runs the coreclr versions using dotnet.exe

The framework and utilities can be found in test-framework.fs, single-test.fs.

test cases look similar to:
````
[<Test>]
[<Fact>]
let ``array-FSI`` () = singleTestBuildAndRun "core/array" FSI
````
This test case builds and runs the test case in the folder core/array
Expand All @@ -20,7 +20,7 @@ __#if !NETCOREAPP__

There are some older tests in this section that looks similar to:
````
[<Test>]
[<Fact>]
let events () =
let cfg = testConfig "core/events"
fsc cfg "%s -a -o:test.dll -g" cfg.fsc_flags ["test.fs"]
Expand All @@ -34,11 +34,11 @@ There are some older tests in this section that looks similar to:
````
These tests build, compile, peverify and run fsi.

Below the Compiler directory there is a set of tests built on the compiler service. They are nunit and instead of executing the compiler and fsi using files on disk the tests are built from memory. These tests use the CompilerAssert framework and look similar to:
Below the Compiler directory there is a set of tests built on the compiler service. They are xUnit and instead of executing the compiler and fsi using files on disk the tests are built from memory. These tests use the CompilerAssert framework and look similar to:

This test verifies that a warning is produces when a value is implicitly discarded. The line ````x = 20``` looks like an assignment but in F# is a test for equality it yields and discards the value false.
````
[<Test>]
[<Fact>]
let ``Unused compare with immutable when assignment might be intended``() =
CompilerAssert.TypeCheckSingleError
"""
Expand All @@ -62,4 +62,4 @@ When a test is run, .err/.vserr output files are created and compared to their m

Refer to [Test Guide](../../TESTGUIDE.md#baselines) to know more about how to update them.

Tests are organized under modules as functions bearing NUnit `[<Test>]` attribute and can be run from an IDE or the command line (see the [Test Guide](../../TESTGUIDE.md)).
Tests are organized under modules as functions bearing xUnit `[<Fact>]` attribute and can be run from an IDE or the command line (see the [Test Guide](../../TESTGUIDE.md)).
5 changes: 5 additions & 0 deletions tests/fsharp/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"appDomain": "ifAvailable",
"shadowCopy": false
}

0 comments on commit f18511f

Please sign in to comment.