-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run some extra tests for Java 8, 11, 17, 21 & 23
- Loading branch information
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
98 changes: 98 additions & 0 deletions
98
modules/integration/src/test/scala/scala/cli/integration/RunJdkTestDefinitions.scala
This file contains 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,98 @@ | ||
package scala.cli.integration | ||
|
||
import com.eed3si9n.expecty.Expecty.expect | ||
|
||
import scala.util.Properties | ||
|
||
trait RunJdkTestDefinitions { _: RunTestDefinitions => | ||
def javaIndex(javaVersion: Int): String = | ||
// TODO just passing the version number on arm64 should be enough, needs a fix in cs | ||
if (Properties.isMac && TestUtil.isM1 && (javaVersion < 11 || javaVersion == 16)) | ||
s"zulu:$javaVersion" | ||
else javaVersion.toString | ||
|
||
for { | ||
javaVersion <- Constants.allJavaVersions | ||
index = javaIndex(javaVersion) | ||
} { | ||
test(s"correct JVM is picked up when JAVA_HOME set to $index") { | ||
TestUtil.retryOnCi() { | ||
TestInputs( | ||
os.rel / "check_java_home.sc" -> | ||
s"""assert( | ||
| System.getProperty("java.version").startsWith("$javaVersion") || | ||
| System.getProperty("java.version").startsWith("1.$javaVersion") | ||
|) | ||
|println(System.getProperty("java.home"))""".stripMargin | ||
).fromRoot { root => | ||
val javaHome = | ||
os.Path( | ||
os.proc(TestUtil.cs, "java-home", "--jvm", index).call().out.trim(), | ||
os.pwd | ||
) | ||
val res = os.proc(TestUtil.cli, "run", ".", extraOptions) | ||
.call(cwd = root, env = Map("JAVA_HOME" -> javaHome.toString)) | ||
expect(res.out.trim().contains(javaHome.toString)) | ||
} | ||
} | ||
} | ||
|
||
test(s"hello world with --jvm $index") { | ||
val expectedMessage = "Hello, world!" | ||
TestInputs( | ||
os.rel / "hello_world.sc" -> s"println(\"$expectedMessage\")" | ||
).fromRoot { root => | ||
val res = os.proc(TestUtil.cli, "run", ".", extraOptions, "--jvm", javaVersion) | ||
.call(cwd = root) | ||
expect(res.out.trim() == expectedMessage) | ||
} | ||
} | ||
|
||
test(s"correct JVM is picked up when Java $index is passed with --java-home") { | ||
TestUtil.retryOnCi() { | ||
TestInputs( | ||
os.rel / "check_java_home.sc" -> | ||
s"""assert( | ||
| System.getProperty("java.version").startsWith("$javaVersion") || | ||
| System.getProperty("java.version").startsWith("1.$javaVersion") | ||
|) | ||
|println(System.getProperty("java.home"))""".stripMargin | ||
).fromRoot { root => | ||
val javaHome = | ||
os.Path( | ||
os.proc(TestUtil.cs, "java-home", "--jvm", index).call().out.trim(), | ||
os.pwd | ||
) | ||
val res = | ||
os.proc(TestUtil.cli, "run", ".", extraOptions, "--java-home", javaHome.toString) | ||
.call(cwd = root) | ||
expect(res.out.trim().contains(javaHome.toString)) | ||
} | ||
} | ||
} | ||
|
||
if (javaVersion >= Constants.bloopMinimumJvmVersion) | ||
test(s"Bloop runs correctly on JVM $index") { | ||
TestUtil.retryOnCi() { | ||
val expectedMessage = "Hello, world!" | ||
TestInputs(os.rel / "check_java_home.sc" -> s"""println("$expectedMessage")""") | ||
.fromRoot { root => | ||
os.proc(TestUtil.cli, "bloop", "exit", "--power").call(cwd = root) | ||
val res = os.proc( | ||
TestUtil.cli, | ||
"run", | ||
".", | ||
extraOptions, | ||
"--bloop-jvm", | ||
index, | ||
"--jvm", | ||
index | ||
) | ||
.call(cwd = root, stderr = os.Pipe) | ||
expect(res.err.trim().contains(javaVersion.toString)) | ||
expect(res.out.trim() == expectedMessage) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains 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 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