-
Notifications
You must be signed in to change notification settings - Fork 833
Tests: add helper Stress attribute for stress testing
#18452
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bcc1e90
add Repeat helper
majocha bc7dfc8
fix flaky test
majocha 322efc4
Merge branch 'main' into tests-repeat
majocha be15f41
Update tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemo…
majocha 87f6281
update docs
majocha 41be29d
naming
majocha 84544a2
Merge branch 'main' into tests-repeat
majocha 668afd3
add tests
majocha d6888de
Merge branch 'tests-repeat' of https://github.com/majocha/fsharp into…
majocha 8f92db0
Merge branch 'main' into tests-repeat
majocha b991398
Merge branch 'main' into tests-repeat
majocha 060042f
tests
majocha 98b297e
Merge branch 'main' into tests-repeat
majocha e37f764
Merge branch 'main' into tests-repeat
majocha e29ddc1
run tests in ci
majocha 4e0c2cc
Merge branch 'main' into tests-repeat
majocha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| module FSharp.Test.UtilitiesTests | ||
|
|
||
| open System | ||
| open System.Threading | ||
| open Xunit | ||
| open FSharp.Test | ||
|
|
||
| type RunOrFail(name) = | ||
| let mutable count = 0 | ||
| member _.Run(shouldFail: bool) = | ||
| let count = Interlocked.Increment &count | ||
| if shouldFail && count = 42 then | ||
| failwith $"{name}, failed as expected on {count}" | ||
| else | ||
| printfn $"{name}, iteration {count} passed" | ||
| count | ||
|
|
||
| let passing = RunOrFail "Passing" | ||
| let failing = RunOrFail "Failing" | ||
|
|
||
| [<Theory(Skip = "Explicit, unskip to run"); Stress(true, Count = 50)>] | ||
| let ``Stress attribute should catch intermittent failure`` shouldFail _ = | ||
| failing.Run shouldFail | ||
|
|
||
| [<Theory; Stress(Count = 5)>] | ||
| let ``Stress attribute works`` _ = | ||
| passing.Run false | ||
|
|
||
| [<Fact>] | ||
| let ``TestConsole captures output`` () = | ||
| let rnd = Random() | ||
| let task n = | ||
| async { | ||
| use console = new TestConsole.ExecutionCapture() | ||
| do! Async.Sleep (rnd.Next 50) | ||
| printf $"Hello, world! {n}" | ||
| do! Async.Sleep (rnd.Next 50) | ||
| eprintf $"Some error {n}" | ||
| return console.OutText, console.ErrorText | ||
| } | ||
|
|
||
| let expected = [ for n in 0 .. 9 -> $"Hello, world! {n}", $"Some error {n}" ] | ||
|
|
||
| let results = Seq.init 10 task |> Async.Parallel |> Async.RunSynchronously | ||
| Assert.Equal(expected, results) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": "denied", | ||
| "parallelizeAssembly": true | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.