Skip to content
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
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

// Because of shared fsi session.
[<FSharp.Test.RunTestCasesInSequence>]
// Leverage caching/prevent concurrent mutation via long-lived fsiSession in module state
[<Xunit.TestClass(DisableParallelization = true)>]
module Language.BooleanReturningAndReturnTypeDirectedPartialActivePatternTests

open Xunit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ open Xunit
open FSharp.Test.Compiler
open FSharp.Test.ScriptHelpers

// Run sequentially because of shared fsiSession.
[<FSharp.Test.RunTestCasesInSequence>]
// Leverage caching/prevent concurrent mutation via long-lived fsiSession in module state
[<TestClass(DisableParallelization = true)>]
module SequenceExpression =

let fsiSession = getSessionForEval [||] LangVersion.Preview
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[<FSharp.Test.RunTestCasesInSequence>]
// TODO @T-Gro document reasoning for inhibiting parallelization
[<Xunit.TestClass(DisableParallelization = true)>]
module FSharp.Compiler.Service.Tests.ScriptDiagnosticsTests

open System
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Compiler.Service.Tests/FsiTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module MyModule =
let test(x: int) = ()

// Running in parallel is unstable with occasional System.IO.FileLoadException: Could not load file or assembly 'FSI-ASSEMBLY...
[<RunTestCasesInSequence>]
[<TestClass(DisableParallelization = true)>]
module FsiTests =

let createFsiSession (useOneDynamicAssembly: bool) =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Sequential execution because of shared mutable state.
[<FSharp.Test.RunTestCasesInSequence>]
// Tests utilize caching in module state (checker) and `mutable` state
[<Xunit.TestClass(DisableParallelization = true)>]
module FSharp.Compiler.Service.Tests.ModuleReaderCancellationTests

open System
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ module GenerativeTypeProviderFallbackTest =
begin
let fileName = __SOURCE_DIRECTORY__ ++ @"../service/data/TestProject/TestProject.fs"
let fileSource = FileSystem.OpenFileForReadShim(fileName).ReadAllText()
let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, SourceText.ofString fileSource, optionsTestProject) |> Async.
RunSynchronouslyImmediate
let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, SourceText.ofString fileSource, optionsTestProject) |> Async.RunSynchronouslyImmediate

let fileCheckResults =
match fileCheckAnswer with
Expand Down
23 changes: 8 additions & 15 deletions tests/FSharp.Compiler.Service.Tests/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ let ``Test file explicit parse symbols`` () =

let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronouslyImmediate
let parseResults1 = checker.ParseFile(Project1.fileName1, Project1.fileSource1, Project1.parsingOptions) |> Async.RunSynchronouslyImmediate

let parseResults2 = checker.ParseFile(Project1.fileName2, Project1.fileSource2, Project1.parsingOptions) |> Async.RunSynchronouslyImmediate

let checkResults1 =
Expand Down Expand Up @@ -621,7 +620,6 @@ let ``Test file explicit parse all symbols`` () =

let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronouslyImmediate
let parseResults1 = checker.ParseFile(Project1.fileName1, Project1.fileSource1, Project1.parsingOptions) |> Async.RunSynchronouslyImmediate

let parseResults2 = checker.ParseFile(Project1.fileName2, Project1.fileSource2, Project1.parsingOptions) |> Async.RunSynchronouslyImmediate

let checkResults1 =
Expand Down Expand Up @@ -3721,7 +3719,7 @@ let _ = MyType().DoNothing()
{ checker.GetProjectOptionsFromCommandLineArgs(projFileName, args) with SourceFiles = fileNames })

// Uses TestTP (built locally) — no NuGet needed, deterministic.
[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Inhibit shared usage of Project25.checker module state
let ``Test Project25 whole project errors`` () =
let wholeProjectResults = Project25.checker.ParseAndCheckProject(Project25.options.Value) |> Async.RunSynchronouslyImmediate

Expand All @@ -3730,7 +3728,7 @@ let ``Test Project25 whole project errors`` () =

wholeProjectResults.Diagnostics.Length |> shouldEqual 0

[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Inhibit shared usage of Project25.checker module state
let ``Test Project25 symbol uses of type-provided members`` () =
let wholeProjectResults = Project25.checker.ParseAndCheckProject(Project25.options.Value) |> Async.RunSynchronouslyImmediate

Expand Down Expand Up @@ -3789,7 +3787,7 @@ let ``Test Project25 symbol uses of type-provided members`` () =
[| ("file1", ((5, 8), (5, 21))) // line 5: T().DoNothing
("file1", ((10, 8), (10, 26))) |] // line 10: MyType().DoNothing

[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Inhibit shared usage of Project25.checker module state
let ``GetDeclarationLocation on a provided-ctor without DefinitionLocationAttribute returns DeclFound (regression #5538)`` () =
let wholeProjectResults =
Project25.checker.ParseAndCheckProject(Project25.options.Value)
Expand Down Expand Up @@ -3830,7 +3828,7 @@ let ``GetDeclarationLocation on a provided-ctor without DefinitionLocationAttrib
| FindDeclResult.ExternalDecl _ ->
failwith "expected DeclFound for provided-ctor `T()`, got ExternalDecl"

[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Inhibit shared usage of Project25.checker module state
let ``GetDeclarationLocation on a provided-ctor invoked through the original provided name returns DeclFound (regression #5538)`` () =
let wholeProjectResults =
Project25.checker.ParseAndCheckProject(Project25.options.Value)
Expand Down Expand Up @@ -3867,7 +3865,7 @@ let ``GetDeclarationLocation on a provided-ctor invoked through the original pro
| FindDeclResult.ExternalDecl _ ->
failwith "expected DeclFound for provided-ctor `MyType()`, got ExternalDecl"

[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Inhibit shared usage of Project25.checker module state
let ``Test Project25 symbol uses of type-provided types`` () =
let wholeProjectResults = Project25.checker.ParseAndCheckProject(Project25.options.Value) |> Async.RunSynchronouslyImmediate

Expand All @@ -3890,7 +3888,7 @@ let ``Test Project25 symbol uses of type-provided types`` () =
("file1", ((5, 8), (5, 9))) // line 5: let _ = >T<() (T resolves to MyType)
("file1", ((10, 8), (10, 14))) |] // line 10: let _ = >MyType<()

[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Inhibit shared usage of Project25.checker module state
let ``Test Project25 symbol uses of fully-qualified records`` () =
let wholeProjectResults = Project25.checker.ParseAndCheckProject(Project25.options.Value) |> Async.RunSynchronouslyImmediate

Expand Down Expand Up @@ -4884,7 +4882,6 @@ let ``Test project37 typeof and arrays in attribute constructor arguments`` () =
let wholeProjectResults =
checker.ParseAndCheckProject(Project37.options)
|> Async.RunSynchronouslyImmediate

let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols()
for su in allSymbolsUses do
match su.Symbol with
Expand Down Expand Up @@ -4939,7 +4936,6 @@ let ``Test project37 DeclaringEntity`` () =
let wholeProjectResults =
checker.ParseAndCheckProject(Project37.options)
|> Async.RunSynchronouslyImmediate

let allSymbolsUses = wholeProjectResults.GetAllUsesOfAllSymbols()
for sym in allSymbolsUses do
match sym.Symbol with
Expand Down Expand Up @@ -5028,7 +5024,6 @@ let ``Test project38 abstract slot information`` () =
let wholeProjectResults =
checker.ParseAndCheckProject(Project38.options)
|> Async.RunSynchronouslyImmediate

let printAbstractSignature (s: FSharpAbstractSignature) =
let printType (t: FSharpType) =
hash t |> ignore // smoke test to check hash code doesn't loop
Expand Down Expand Up @@ -5358,7 +5353,6 @@ let ``Test project42 to ensure cached checked results are invalidated`` () =
FileSystem.OpenFileForWriteShim(Project42.fileName1).Write("""module File1""")
try
let checkedFile2Again = checker.ParseAndCheckFileInProject(Project42.fileName2, text2.GetHashCode(), text2, Project42.options) |> Async.RunSynchronouslyImmediate

match checkedFile2Again with
| _, FSharpCheckFileAnswer.Succeeded(checkedFile2AgainResults) ->
Assert.NotEmpty(checkedFile2AgainResults.Diagnostics) // this should contain errors as File1 does not contain the function `test()`
Expand Down Expand Up @@ -5473,7 +5467,7 @@ let x = (1 = 3.0)
let args = mkProjectCommandLineArgs (dllName, [])
let options = { checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) with SourceFiles = fileNames }

[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Avoid concurrent use of checker
let ``Test diagnostics with line directives active`` () =

let wholeProjectResults = checker.ParseAndCheckProject(ProjectLineDirectives.options) |> Async.RunSynchronouslyImmediate
Expand All @@ -5491,7 +5485,7 @@ let ``Test diagnostics with line directives active`` () =
let m = e.Range in m.StartLine, m.EndLine, m.FileName ]
|> shouldEqual [10, 10, "Test.fsy"]

[<Fact; RunTestCasesInSequence>]
[<Fact4(DisableParallelization = true)>] // Avoid concurrent use of checker
let ``Test diagnostics with line directives ignored`` () =

// If you pass hidden IDE flag --ignorelinedirectives, the diagnostics are reported w.r.t. the source
Expand Down Expand Up @@ -5900,7 +5894,6 @@ let checkContentAsScript content =
let scriptFullPath = Path.Combine(tempDir, scriptName)
let sourceText = SourceText.ofString content
let projectOptions, _ = checker.GetProjectOptionsFromScript(scriptFullPath, sourceText, useSdkRefs = true, assumeDotNetFramework = false) |> Async.RunSynchronouslyImmediate

let parseOptions, _ = checker.GetParsingOptionsFromProjectOptions projectOptions
let parseResults = checker.ParseFile(scriptFullPath, sourceText, parseOptions) |> Async.RunSynchronouslyImmediate
let checkResults = checker.CheckFileInProject(parseResults, scriptFullPath, 0, sourceText, projectOptions) |> Async.RunSynchronouslyImmediate
Expand Down
4 changes: 2 additions & 2 deletions tests/FSharp.Compiler.Service.Tests/ScriptOptionsTests.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Because of script closure cache.
[<FSharp.Test.RunTestCasesInSequence>]
// Avoid parallelism to leverage script closure cache.
[<Xunit.TestClass(DisableParallelization = true)>]
module FSharp.Compiler.Service.Tests.ScriptOptionsTests

open Xunit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

// Tests for camelCase functions in module Async
module FSharp.Core.UnitTests.Controa.AsyncModuleFunctionsTestsl

// Intentionally in same collection to help rule out potential flakiness due to concurrency re #20306
[<Xunit.Collection(nameof FSharp.Test.NotThreadSafeResourceCollection)>]
module FSharp.Core.UnitTests.Control.AsyncModuleFunctionsTests

open System
open System.Threading
Expand All @@ -20,7 +23,7 @@ let cancelWithToken (tcs: TaskCompletionSource<'T>) =
#endif

let asyncWait (a: Async<'T>): 'T = Async.RunSynchronouslyImmediate a
let asyncWaitWithCt (ct: CancellationToken) (a: Async<'T>): 'T = Async.RunSynchronously(a, cancellationToken = ct)
let asyncWaitWithCt (ct: CancellationToken) (a: Async<'T>): 'T = Async.RunSynchronouslyImmediate(a, cancellationToken = ct)

[<Fact>]
let ``Async.result wraps value`` () =
Expand Down
Loading
Loading