Skip to content

Commit

Permalink
Battle-test the CI runner with our own mini test-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
abelbraaksma committed Oct 15, 2022
1 parent 65e3885 commit 4e30077
Showing 1 changed file with 115 additions and 18 deletions.
133 changes: 115 additions & 18 deletions src/FSharpy.TaskSeq.Test/TaskSeq.AllTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ open Xunit.Abstractions


type AllTests(output: ITestOutputHelper) =

[<Fact>]
let ``Run all tests`` () =
let createParallelRunner () =
let myAsm = Assembly.GetExecutingAssembly()

let allMethods = [
Expand All @@ -28,13 +26,7 @@ type AllTests(output: ITestOutputHelper) =
| _ -> ()
]

let x =
{ new System.IFormattable with
member x.ToString(format: string, provider: System.IFormatProvider) =
if format = "D" then "foo" else "bar"
}

task {
let all = seq {
for (ty, method) in allMethods do
let ctor = ty.GetConstructor [| typeof<ITestOutputHelper> |]

Expand All @@ -43,14 +35,119 @@ type AllTests(output: ITestOutputHelper) =

let testObj = ctor.Invoke([| output |])

let! _ =
if method.ReturnType.Name.Contains "Task" then
method.Invoke(testObj, null) :?> Task<unit>
else
method.Invoke(testObj, null) |> ignore
task { return () }
if method.ReturnType.Name.Contains "Task" then
//task {
// let! x = Async.StartChildAsTask (Async.ofTask (method.Invoke(testObj, null) :?> Task<unit>))
// return! x
//}
async {
return!
method.Invoke(testObj, null) :?> Task<unit>
|> Async.AwaitTask
}
else
async { return method.Invoke(testObj, null) |> ignore }
}

()
all |> Async.Parallel |> Async.map ignore

return ()
let multiply f x =
seq {
for i in [ 0..x ] do
yield f ()
}
|> Async.Parallel
|> Async.map ignore

[<Fact>]
let ``Run all tests 1 times in parallel`` () = task { do! multiply createParallelRunner 1 }

[<Theory>]
[<InlineData 1; InlineData 2; InlineData 3; InlineData 4; InlineData 5; InlineData 6; InlineData 7; InlineData 8>]
let ``Run all tests X times in parallel`` i = task { do! multiply createParallelRunner i }

[<Theory>]
[<InlineData 1; InlineData 2; InlineData 3; InlineData 4; InlineData 5; InlineData 6; InlineData 7; InlineData 8>]
let ``Run all tests again X times in parallel`` i = task { do! multiply createParallelRunner i }

[<Theory>]
[<InlineData 1; InlineData 2; InlineData 3; InlineData 4; InlineData 5; InlineData 6; InlineData 7; InlineData 8>]
let ``Run all tests and once more, X times in parallel`` i = task { do! multiply createParallelRunner i }


//[<Fact>]
//let ``Run all tests 3 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 4 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 5 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 6 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 7 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 8 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 9 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 10 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 11 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 12 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 13 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 14 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously


//[<Fact>]
//let ``Run all tests 15 times in parallel`` () =
// multiply createParallelRunner 15
// |> Async.RunSynchronously

0 comments on commit 4e30077

Please sign in to comment.