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

Consolidate test helpers a bit #17938

Merged
merged 1 commit into from
Nov 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\service\FsUnit.fs">
<Link>FsUnit.fs</Link>
</Compile>
<Compile Include="CompilerDirectives\Line.fs" />
<Compile Include="CompilerDirectives\Ifdef.fs" />
<Compile Include="CompilerDirectives\NonStringArgs.fs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Signatures.HashConstraintTests

open Xunit
open FsUnit
open FSharp.Test.Compiler
open Signatures.TestHelpers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Signatures.MemberTests

open Xunit
open FsUnit
open FSharp.Test.Compiler
open Signatures.TestHelpers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Signatures.ModuleOrNamespaceTests

open Xunit
open FsUnit
open FSharp.Test.Compiler
open Signatures.TestHelpers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Signatures.NestedTypeTests

open Xunit
open FsUnit
open FSharp.Test
open FSharp.Test.Compiler
open Signatures.TestHelpers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Signatures.RecordTests

open Xunit
open FsUnit
open FSharp.Test.Compiler
open Signatures.TestHelpers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

open FSharp.Compiler.Symbols
open Xunit
open FsUnit
open FSharp.Test.Compiler
open Signatures.TestHelpers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module FSharp.Compiler.Service.Tests.AssemblyReaderShim

open FsUnit
open FSharp.Compiler.Text
open FSharp.Compiler.AbstractIL.ILBinaryReader
open Xunit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.CSharpProjectAnalysis

open Xunit
open FsUnit
open FSharp.Test.Assert
open System.IO
open FSharp.Compiler.Diagnostics
open FSharp.Compiler.IO
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ open FSharp.Compiler.Symbols
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open TestFramework
open FsUnit
open FSharp.Test.Assert
open Xunit
open FSharp.Test.Utilities

Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/EditorTests.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.EditorTests

open Xunit
open FsUnit
open FSharp.Test.Assert
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Service.Tests.Common
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/ExprTests.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.ExprTests

open Xunit
open FsUnit
open FSharp.Test.Assert
open System
open System.Text
open System.Collections.Generic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
</Content>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="SurfaceArea.fs" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'" />
<Compile Include="..\service\FsUnit.fs">
<Link>FsUnit.fs</Link>
</Compile>
<Compile Include="Common.fs" />
<Compile Include="GeneratedCodeSymbolsTests.fs" />
<Compile Include="AssemblyReaderShim.fs" />
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/FileSystemTests.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.FileSystemTests

open Xunit
open FsUnit
open FSharp.Test.Assert
open FSharp.Test
open System
open System.IO
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.InteractiveCheckerTests

open Xunit
open FsUnit
open FSharp.Test.Assert
open System
open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.Syntax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open FSharp.Compiler.AbstractIL.IL
open FSharp.Compiler.AbstractIL.ILBinaryReader
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Text
open FsUnit
open FSharp.Test.Assert
open Internal.Utilities.Library
open FSharp.Compiler.Service.Tests.Common
open Xunit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.MultiProjectAnalysisTests

open Xunit
open FsUnit
open FSharp.Test.Assert
open System.IO
open System.Collections.Generic
open FSharp.Compiler.CodeAnalysis
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/ParserTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.Syntax
open FSharp.Compiler.Text
open FsUnit
open FSharp.Test.Assert
open Xunit

[<Fact>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module FSharp.Compiler.Service.Tests.PatternMatchCompilationTests
// Most tests here weren't running on desktop and fails

open FSharp.Compiler.Service.Tests.Common
open FsUnit
open FSharp.Test.Assert
open Xunit
open FSharp.Test

Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/PerfTests.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.PerfTests

open Xunit
open FsUnit
open FSharp.Test.Assert
open System.IO
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.IO
Expand Down
4 changes: 2 additions & 2 deletions tests/FSharp.Compiler.Service.Tests/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let runningOnMono = try System.Type.GetType("Mono.Runtime") <> null with e -> false

open Xunit
open FsUnit
open FSharp.Test.Assert
open FSharp.Test
open System
open System.IO
Expand Down Expand Up @@ -96,7 +96,7 @@ let mmmm2 : M.CAbbrev = new M.CAbbrev() // note, these don't count as uses of C
let ``Test project1 whole project errors`` () =

let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunImmediate
wholeProjectResults .Diagnostics.Length |> shouldEqual 2
wholeProjectResults.Diagnostics.Length |> shouldEqual 2
wholeProjectResults.Diagnostics[1].Message.Contains("Incomplete pattern matches on this expression") |> shouldEqual true // yes it does
wholeProjectResults.Diagnostics[1].ErrorNumber |> shouldEqual 25

Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/RangeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
open FSharp.Compiler.Text
open FSharp.Compiler.Text.Position
open FSharp.Compiler.Text.Range
open FsUnit
open FSharp.Test.Assert
open Xunit

[<Fact>]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module FSharp.Compiler.Service.Tests.ServiceUntypedParseTests

open System.IO
open FsUnit
open FSharp.Test.Assert
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.Syntax
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.Symbols
open FSharp.Compiler.Syntax
open FSharp.Compiler.SyntaxTrivia
open FsUnit
open FSharp.Test.Assert
open Xunit

module ActivePatterns =
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/XmlDocTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.Symbols
open FSharp.Compiler.Syntax
open FSharp.Test.Compiler
open FsUnit
open FSharp.Test.Assert
open Xunit

let (|Types|TypeSigs|) = function
Expand Down
11 changes: 10 additions & 1 deletion tests/FSharp.Test.Utilities/Assert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace FSharp.Test
module Assert =
open FluentAssertions
open System.Collections
open System.Text
open Xunit
open System.IO

let inline shouldBeEqualWith (expected : ^T) (message: string) (actual: ^U) =
Expand All @@ -18,9 +18,18 @@ module Assert =
let inline shouldContain (needle : string) (haystack : string) =
haystack.Should().Contain(needle) |> ignore

// One fine day, all of the 3 things below should be purged and replaced with pure Assert.Equal.
T-Gro marked this conversation as resolved.
Show resolved Hide resolved
// Xunit checks types by default. These are just artifacts of the testing chaos in the repo back in a day.
let inline shouldBe (expected : ^T) (actual : ^U) =
actual.Should().Be(expected, "") |> ignore

let inline areEqual (expected: ^T) (actual: ^T) =
Assert.Equal<^T>(expected, actual)

let inline shouldEqual (x: 'a) (y: 'a) =
Assert.Equal<'a>(x, y)
//

let inline shouldBeEmpty (actual : ^T when ^T :> IEnumerable) =
actual.Should().BeEmpty("") |> ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test


module ``Char Constants`` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test


module ``Decimal Constants`` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test


module ``Integer Constants`` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test


module ``IEnumerable Tests`` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test


module ``Round Tests`` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace FSharp.Compiler.UnitTests

open Xunit
open System
open FSharp.Test


module ``String Tests`` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test


module ``Sprintf Tests`` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FSharp.Compiler.UnitTests

open Xunit
open FSharp.Test


module ``DefaultOf Tests`` =
Expand Down
7 changes: 0 additions & 7 deletions tests/fsharp/XunitHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@ module Assert =

[<assembly: CollectionBehavior(DisableTestParallelization = true)>]
do()

let inline fail message = Assert.Fail message

let inline failf fmt = Printf.kprintf fail fmt

let inline areEqual (expected: ^T) (actual: ^T) =
Assert.Equal<^T>(expected, actual)
Loading
Loading