Skip to content

Commit d202650

Browse files
committed
Skip all tests and run reflected and in parallel
* Skip all tests and run by hand, i.e. reflection-based runner test * Implement our own test runner * Run parallelized self-written testrunner several times in parallel
1 parent 32facc6 commit d202650

18 files changed

+301
-147
lines changed

src/FSharpy.TaskSeq.Test/FSharpy.TaskSeq.Test.fsproj

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Compile Include="AssemblyInfo.fs" />
1212
<Compile Include="Nunit.Extensions.fs" />
1313
<Compile Include="TestUtils.fs" />
14+
<Compile Include="TaskSeq.AllTests.fs" />
1415
<Compile Include="TaskSeq.Choose.Tests.fs" />
1516
<Compile Include="TaskSeq.Collect.Tests.fs" />
1617
<Compile Include="TaskSeq.Filter.Tests.fs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
namespace FSharpy.Tests
2+
3+
open System
4+
open System.Threading.Tasks
5+
open System.Reflection
6+
7+
open Xunit
8+
open FsUnit.Xunit
9+
open FsToolkit.ErrorHandling
10+
11+
open FSharpy
12+
open Xunit.Abstractions
13+
14+
15+
type AllTests(output: ITestOutputHelper) =
16+
let createParallelRunner () =
17+
let myAsm = Assembly.GetExecutingAssembly()
18+
19+
let allMethods = [
20+
for ty in myAsm.DefinedTypes do
21+
for mem in ty.DeclaredMembers do
22+
match mem.MemberType with
23+
| MemberTypes.Method ->
24+
if mem.Name.StartsWith("TaskSeq") || mem.Name.StartsWith("CE") then
25+
yield ty, mem :?> MethodInfo
26+
| _ -> ()
27+
]
28+
29+
let all = seq {
30+
for (ty, method) in allMethods do
31+
let ctor = ty.GetConstructor [| typeof<ITestOutputHelper> |]
32+
33+
if isNull ctor then
34+
failwith "Constructor for test not found"
35+
36+
let testObj = ctor.Invoke([| output |])
37+
38+
if method.ReturnType.Name.Contains "Task" then
39+
//task {
40+
// let! x = Async.StartChildAsTask (Async.ofTask (method.Invoke(testObj, null) :?> Task<unit>))
41+
// return! x
42+
//}
43+
async {
44+
return!
45+
method.Invoke(testObj, null) :?> Task<unit>
46+
|> Async.AwaitTask
47+
}
48+
else
49+
async { return method.Invoke(testObj, null) |> ignore }
50+
}
51+
52+
all |> Async.Parallel |> Async.map ignore
53+
54+
let multiply f x =
55+
seq {
56+
for i in [ 0..x ] do
57+
yield f ()
58+
}
59+
|> Async.Parallel
60+
|> Async.map ignore
61+
62+
[<Fact>]
63+
let ``Run all tests 1 times in parallel`` () = task { do! multiply createParallelRunner 1 }
64+
65+
[<Theory>]
66+
[<InlineData 1; InlineData 2; InlineData 3; InlineData 4; InlineData 5; InlineData 6; InlineData 7; InlineData 8>]
67+
let ``Run all tests X times in parallel`` i = task { do! multiply createParallelRunner i }
68+
69+
[<Theory>]
70+
[<InlineData 1; InlineData 2; InlineData 3; InlineData 4; InlineData 5; InlineData 6; InlineData 7; InlineData 8>]
71+
let ``Run all tests again X times in parallel`` i = task { do! multiply createParallelRunner i }
72+
73+
[<Theory>]
74+
[<InlineData 1; InlineData 2; InlineData 3; InlineData 4; InlineData 5; InlineData 6; InlineData 7; InlineData 8>]
75+
let ``Run all tests and once more, X times in parallel`` i = task { do! multiply createParallelRunner i }
76+
77+
78+
//[<Fact>]
79+
//let ``Run all tests 3 times in parallel`` () =
80+
// multiply createParallelRunner 15
81+
// |> Async.RunSynchronously
82+
83+
84+
//[<Fact>]
85+
//let ``Run all tests 4 times in parallel`` () =
86+
// multiply createParallelRunner 15
87+
// |> Async.RunSynchronously
88+
89+
90+
//[<Fact>]
91+
//let ``Run all tests 5 times in parallel`` () =
92+
// multiply createParallelRunner 15
93+
// |> Async.RunSynchronously
94+
95+
96+
//[<Fact>]
97+
//let ``Run all tests 6 times in parallel`` () =
98+
// multiply createParallelRunner 15
99+
// |> Async.RunSynchronously
100+
101+
102+
//[<Fact>]
103+
//let ``Run all tests 7 times in parallel`` () =
104+
// multiply createParallelRunner 15
105+
// |> Async.RunSynchronously
106+
107+
108+
//[<Fact>]
109+
//let ``Run all tests 8 times in parallel`` () =
110+
// multiply createParallelRunner 15
111+
// |> Async.RunSynchronously
112+
113+
114+
//[<Fact>]
115+
//let ``Run all tests 9 times in parallel`` () =
116+
// multiply createParallelRunner 15
117+
// |> Async.RunSynchronously
118+
119+
120+
//[<Fact>]
121+
//let ``Run all tests 10 times in parallel`` () =
122+
// multiply createParallelRunner 15
123+
// |> Async.RunSynchronously
124+
125+
126+
//[<Fact>]
127+
//let ``Run all tests 11 times in parallel`` () =
128+
// multiply createParallelRunner 15
129+
// |> Async.RunSynchronously
130+
131+
132+
//[<Fact>]
133+
//let ``Run all tests 12 times in parallel`` () =
134+
// multiply createParallelRunner 15
135+
// |> Async.RunSynchronously
136+
137+
138+
//[<Fact>]
139+
//let ``Run all tests 13 times in parallel`` () =
140+
// multiply createParallelRunner 15
141+
// |> Async.RunSynchronously
142+
143+
144+
//[<Fact>]
145+
//let ``Run all tests 14 times in parallel`` () =
146+
// multiply createParallelRunner 15
147+
// |> Async.RunSynchronously
148+
149+
150+
//[<Fact>]
151+
//let ``Run all tests 15 times in parallel`` () =
152+
// multiply createParallelRunner 15
153+
// |> Async.RunSynchronously

src/FSharpy.TaskSeq.Test/TaskSeq.Choose.Tests.fs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ open Xunit.Abstractions
1313

1414
type Choose(output: ITestOutputHelper) =
1515

16-
[<Fact(Timeout = 10_000)>]
16+
[<Fact(Skip = "CI test runner chokes!")>]
1717
let ``ZHang timeout test`` () =
1818
logStart output
1919

@@ -22,7 +22,7 @@ type Choose(output: ITestOutputHelper) =
2222
empty |> should be Null
2323
}
2424

25-
[<Fact(Timeout = 10_000)>]
25+
[<Fact(Skip = "CI test runner chokes!")>]
2626
let ``TaskSeq-choose on an empty sequence`` () =
2727
logStart output
2828

@@ -35,7 +35,7 @@ type Choose(output: ITestOutputHelper) =
3535
List.isEmpty empty |> should be True
3636
}
3737

38-
[<Fact(Timeout = 10_000)>]
38+
[<Fact(Skip = "CI test runner chokes!")>]
3939
let ``TaskSeq-chooseAsync on an empty sequence`` () =
4040
logStart output
4141

@@ -48,7 +48,7 @@ type Choose(output: ITestOutputHelper) =
4848
List.isEmpty empty |> should be True
4949
}
5050

51-
[<Fact(Timeout = 10_000)>]
51+
[<Fact(Skip = "CI test runner chokes!")>]
5252
let ``TaskSeq-choose can convert and filter`` () =
5353
logStart output
5454

@@ -61,7 +61,7 @@ type Choose(output: ITestOutputHelper) =
6161
String alphabet |> should equal "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
6262
}
6363

64-
[<Fact(Timeout = 10_000)>]
64+
[<Fact(Skip = "CI test runner chokes!")>]
6565
let ``TaskSeq-chooseAsync can convert and filter`` () =
6666
logStart output
6767

src/FSharpy.TaskSeq.Test/TaskSeq.Collect.Tests.fs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ open FSharpy
88

99
type Collect(output) =
1010

11-
[<Fact(Timeout = 10_000)>]
11+
[<Fact(Skip = "CI test runner chokes!")>]
1212
let ``TaskSeq-collect operates in correct order`` () =
1313
logStart output
1414

@@ -27,7 +27,7 @@ type Collect(output) =
2727
|> should equal "ABBCCDDEEFFGGHHIIJJK"
2828
}
2929

30-
[<Fact(Timeout = 10_000)>]
30+
[<Fact(Skip = "CI test runner chokes!")>]
3131
let ``TaskSeq-collectSeq operates in correct order`` () =
3232
logStart output
3333

@@ -46,7 +46,7 @@ type Collect(output) =
4646
|> should equal "ABBCCDDEEFFGGHHIIJJK"
4747
}
4848

49-
[<Fact(Timeout = 10_000)>]
49+
[<Fact(Skip = "CI test runner chokes!")>]
5050
let ``TaskSeq-collect with empty task sequences`` () =
5151
logStart output
5252

@@ -59,7 +59,7 @@ type Collect(output) =
5959
Seq.isEmpty sq |> should be True
6060
}
6161

62-
[<Fact(Timeout = 10_000)>]
62+
[<Fact(Skip = "CI test runner chokes!")>]
6363
let ``TaskSeq-collectSeq with empty sequences`` () =
6464
logStart output
6565

@@ -72,7 +72,7 @@ type Collect(output) =
7272
Seq.isEmpty sq |> should be True
7373
}
7474

75-
[<Fact(Timeout = 10_000)>]
75+
[<Fact(Skip = "CI test runner chokes!")>]
7676
let ``TaskSeq-empty is empty`` () =
7777
logStart output
7878

src/FSharpy.TaskSeq.Test/TaskSeq.Filter.Tests.fs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open FSharpy
1010

1111
type Filter(output) =
1212

13-
[<Fact(Timeout = 10_000)>]
13+
[<Fact(Skip = "CI test runner chokes!")>]
1414
let ``TaskSeq-filter on an empty sequence`` () =
1515
logStart output
1616

@@ -23,7 +23,7 @@ type Filter(output) =
2323
List.isEmpty empty |> should be True
2424
}
2525

26-
[<Fact(Timeout = 10_000)>]
26+
[<Fact(Skip = "CI test runner chokes!")>]
2727
let ``TaskSeq-filterAsync on an empty sequence`` () =
2828
logStart output
2929

@@ -36,7 +36,7 @@ type Filter(output) =
3636
List.isEmpty empty |> should be True
3737
}
3838

39-
[<Fact(Timeout = 10_000)>]
39+
[<Fact(Skip = "CI test runner chokes!")>]
4040
let ``TaskSeq-filter filters correctly`` () =
4141
logStart output
4242

@@ -52,7 +52,7 @@ type Filter(output) =
5252
String alphabet |> should equal "Z[\]^_`abcdefghijklmnopqr"
5353
}
5454

55-
[<Fact(Timeout = 10_000)>]
55+
[<Fact(Skip = "CI test runner chokes!")>]
5656
let ``TaskSeq-filterAsync filters correctly`` () =
5757
logStart output
5858

0 commit comments

Comments
 (0)