@@ -6,36 +6,12 @@ import java.nio.file.Files
6
6
7
7
import scala .util .Properties
8
8
9
- class JmhTests extends ScalaCliSuite {
9
+ class JmhTests extends ScalaCliSuite with JmhSuite {
10
10
override def group : ScalaCliSuite .TestGroup = ScalaCliSuite .TestGroup .First
11
11
12
- lazy val inputs : TestInputs = TestInputs (
13
- os.rel / " benchmark.scala" ->
14
- s """ package bench
15
- |
16
- |import java.util.concurrent.TimeUnit
17
- |import org.openjdk.jmh.annotations._
18
- |
19
- |@BenchmarkMode(Array(Mode.AverageTime))
20
- |@OutputTimeUnit(TimeUnit.NANOSECONDS)
21
- |@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
22
- |@Measurement(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS)
23
- |@Fork(0)
24
- |class Benchmarks {
25
- |
26
- | @Benchmark
27
- | def foo(): Unit = {
28
- | (1L to 10000000L).sum
29
- | }
30
- |
31
- |}
32
- | """ .stripMargin
33
- )
34
- lazy val expectedInOutput = """ Result "bench.Benchmarks.foo":"""
35
-
36
12
test(" simple" ) {
37
13
// TODO extract running benchmarks to a separate scope, or a separate sub-command
38
- inputs .fromRoot { root =>
14
+ simpleInputs .fromRoot { root =>
39
15
val res =
40
16
os.proc(TestUtil .cli, " --power" , TestUtil .extraOptions, " ." , " --jmh" ).call(cwd = root)
41
17
val output = res.out.trim()
@@ -44,14 +20,14 @@ class JmhTests extends ScalaCliSuite {
44
20
}
45
21
46
22
test(" compile" ) {
47
- inputs .fromRoot { root =>
23
+ simpleInputs .fromRoot { root =>
48
24
os.proc(TestUtil .cli, " compile" , " --power" , TestUtil .extraOptions, " ." , " --jmh" )
49
25
.call(cwd = root)
50
26
}
51
27
}
52
28
53
29
test(" doc" ) {
54
- inputs .fromRoot { root =>
30
+ simpleInputs .fromRoot { root =>
55
31
val res = os.proc(TestUtil .cli, " doc" , " --power" , TestUtil .extraOptions, " ." , " --jmh" )
56
32
.call(cwd = root, stderr = os.Pipe )
57
33
expect(! res.err.trim().contains(" Error" ))
@@ -60,7 +36,7 @@ class JmhTests extends ScalaCliSuite {
60
36
61
37
test(" setup-ide" ) {
62
38
// TODO fix setting jmh via a reload & add tests for it
63
- inputs .fromRoot { root =>
39
+ simpleInputs .fromRoot { root =>
64
40
os.proc(TestUtil .cli, " setup-ide" , " --power" , TestUtil .extraOptions, " ." , " --jmh" )
65
41
.call(cwd = root)
66
42
}
@@ -69,7 +45,7 @@ class JmhTests extends ScalaCliSuite {
69
45
test(" package" ) {
70
46
// TODO make package with --jmh build an artifact that actually runs benchmarks
71
47
val expectedMessage = " Placeholder main method"
72
- inputs
48
+ simpleInputs
73
49
.add(os.rel / " Main.scala" -> s """ @main def main: Unit = println(" $expectedMessage") """ )
74
50
.fromRoot { root =>
75
51
val launcherName = {
@@ -96,7 +72,7 @@ class JmhTests extends ScalaCliSuite {
96
72
}
97
73
98
74
test(" export" ) {
99
- inputs .fromRoot { root =>
75
+ simpleInputs .fromRoot { root =>
100
76
// TODO add proper support for JMH export, we're checking if it doesn't fail the command for now
101
77
os.proc(TestUtil .cli, " export" , " --power" , TestUtil .extraOptions, " ." , " --jmh" )
102
78
.call(cwd = root)
0 commit comments