@@ -11,11 +11,33 @@ trait RunJdkTestDefinitions { _: RunTestDefinitions =>
11
11
s " zulu: $javaVersion"
12
12
else javaVersion.toString
13
13
14
+ def canUseScalaInstallationWrapper : Boolean =
15
+ actualScalaVersion.startsWith(" 3" ) && actualScalaVersion.split('.' ).drop(1 ).head.toInt >= 5
16
+
14
17
for {
15
18
javaVersion <- Constants .allJavaVersions
16
19
index = javaIndex(javaVersion)
20
+ useScalaInstallationWrapper <-
21
+ if (canUseScalaInstallationWrapper) Seq (false , true ) else Seq (false )
22
+ launcherString = if (useScalaInstallationWrapper) " coursier scala installation" else " Scala CLI"
23
+ scalaRunnerWrapperVersion = actualScalaVersion match {
24
+ case v if v == Constants .scala3NextRc => Constants .scala3NextRcAnnounced
25
+ case v if v == Constants .scala3Next => Constants .scala3NextAnnounced
26
+ case v => v
27
+ }
28
+ withLauncher = (root : os.Path ) =>
29
+ (f : Seq [os.Shellable ] => Unit ) =>
30
+ if (useScalaInstallationWrapper)
31
+ withScalaRunnerWrapper(
32
+ root = root,
33
+ localBin = root / " local-bin" ,
34
+ scalaVersion = scalaRunnerWrapperVersion,
35
+ shouldCleanUp = false
36
+ )(launcher => f(Seq (launcher)))
37
+ else
38
+ f(Seq (TestUtil .cli))
17
39
} {
18
- test(s " correct JVM is picked up when JAVA_HOME set to $index" ) {
40
+ test(s " correct JVM is picked up by $launcherString when JAVA_HOME set to $index" ) {
19
41
TestUtil .retryOnCi() {
20
42
TestInputs (
21
43
os.rel / " check_java_home.sc" ->
@@ -30,25 +52,33 @@ trait RunJdkTestDefinitions { _: RunTestDefinitions =>
30
52
os.proc(TestUtil .cs, " java-home" , " --jvm" , index).call().out.trim(),
31
53
os.pwd
32
54
)
33
- val res = os.proc(TestUtil .cli, " run" , " ." , extraOptions)
55
+ withLauncher(root) { launcher =>
56
+ val res = os.proc(launcher, " run" , " ." , extraOptions)
34
57
.call(cwd = root, env = Map (" JAVA_HOME" -> javaHome.toString))
35
58
expect(res.out.trim().contains(javaHome.toString))
59
+ }
36
60
}
37
61
}
38
62
}
39
63
40
- test(s " hello world with --jvm $index" ) {
41
- val expectedMessage = " Hello, world!"
42
- TestInputs (
43
- os.rel / " hello_world.sc" -> s " println( \" $expectedMessage\" ) "
44
- ).fromRoot { root =>
45
- val res = os.proc(TestUtil .cli, " run" , " ." , extraOptions, " --jvm" , javaVersion)
46
- .call(cwd = root)
47
- expect(res.out.trim() == expectedMessage)
64
+ test(s " hello world with $launcherString and --jvm $index" ) {
65
+ TestUtil .retryOnCi() {
66
+ val expectedMessage = " Hello, world!"
67
+ TestInputs (
68
+ os.rel / " hello_world.sc" -> s " println( \" $expectedMessage\" ) "
69
+ ).fromRoot { root =>
70
+ withLauncher(root) { launcher =>
71
+ val res = os.proc(launcher, " run" , " ." , extraOptions, " --jvm" , javaVersion)
72
+ .call(cwd = root)
73
+ expect(res.out.trim() == expectedMessage)
74
+ }
75
+ }
48
76
}
49
77
}
50
78
51
- test(s " correct JVM is picked up when Java $index is passed with --java-home " ) {
79
+ test(
80
+ s " correct JVM is picked up by $launcherString when Java $index is passed with --java-home "
81
+ ) {
52
82
TestUtil .retryOnCi() {
53
83
TestInputs (
54
84
os.rel / " check_java_home.sc" ->
@@ -63,34 +93,37 @@ trait RunJdkTestDefinitions { _: RunTestDefinitions =>
63
93
os.proc(TestUtil .cs, " java-home" , " --jvm" , index).call().out.trim(),
64
94
os.pwd
65
95
)
66
- val res =
67
- os.proc(TestUtil .cli , " run" , " ." , extraOptions, " --java-home" , javaHome.toString)
96
+ withLauncher(root) { launcher =>
97
+ val res = os.proc(launcher , " run" , " ." , extraOptions, " --java-home" , javaHome.toString)
68
98
.call(cwd = root)
69
- expect(res.out.trim().contains(javaHome.toString))
99
+ expect(res.out.trim().contains(javaHome.toString))
100
+ }
70
101
}
71
102
}
72
103
}
73
104
74
105
if (javaVersion >= Constants .bloopMinimumJvmVersion)
75
- test(s " Bloop runs correctly on JVM $index" ) {
106
+ test(s " Bloop runs correctly with $launcherString on JVM $index" ) {
76
107
TestUtil .retryOnCi() {
77
108
val expectedMessage = " Hello, world!"
78
109
TestInputs (os.rel / " check_java_home.sc" -> s """ println(" $expectedMessage") """ )
79
110
.fromRoot { root =>
80
111
os.proc(TestUtil .cli, " bloop" , " exit" , " --power" ).call(cwd = root)
81
- val res = os.proc(
82
- TestUtil .cli,
83
- " run" ,
84
- " ." ,
85
- extraOptions,
86
- " --bloop-jvm" ,
87
- index,
88
- " --jvm" ,
89
- index
90
- )
91
- .call(cwd = root, stderr = os.Pipe )
92
- expect(res.err.trim().contains(javaVersion.toString))
93
- expect(res.out.trim() == expectedMessage)
112
+ withLauncher(root) { launcher =>
113
+ val res = os.proc(
114
+ launcher,
115
+ " run" ,
116
+ " ." ,
117
+ extraOptions,
118
+ " --bloop-jvm" ,
119
+ index,
120
+ " --jvm" ,
121
+ index
122
+ )
123
+ .call(cwd = root, stderr = os.Pipe )
124
+ expect(res.err.trim().contains(javaVersion.toString))
125
+ expect(res.out.trim() == expectedMessage)
126
+ }
94
127
}
95
128
}
96
129
}
0 commit comments