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

Test NodeCode #16576

Merged
merged 9 commits into from
Jan 25, 2024
Merged
Changes from 2 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 @@ -211,6 +211,43 @@ let ``Job is restarted if first requestor cancels but keeps running if second re
type ExpectedException() =
inherit Exception()

[<Fact>]
let internal ``NodeCode preserves DiagnosticsThreadStatics`` () =
let random =
let rng = Random()
fun n -> rng.Next n

let job _ = node {
do! random 10 |> Async.Sleep |> NodeCode.AwaitAsync
}

let work (phase: BuildPhase) =
node {
use _ = new CompilationGlobalsScope(DiscardErrorsLogger, phase)
let! _ = Seq.init 8 job |> NodeCode.Parallel
Assert.Equal(phase, DiagnosticsThreadStatics.BuildPhase)
}

let phases = [|
BuildPhase.DefaultPhase
BuildPhase.Compile
BuildPhase.Parameter
BuildPhase.Parse
BuildPhase.TypeCheck
BuildPhase.CodeGen
BuildPhase.Optimize
BuildPhase.IlxGen
BuildPhase.IlGen
BuildPhase.Output
BuildPhase.Interactive
|]

let pickRandomPhase _ = phases[random phases.Length]
Seq.init 100 pickRandomPhase
|> Seq.map (work >> Async.AwaitNodeCode)
|> Async.Parallel
|> Async.RunSynchronously

[<Fact>]
let ``Stress test`` () =

Expand Down
Loading