Skip to content

Commit 4aed7f5

Browse files
rochalaWojciechMazur
authored andcommitted
Make 11 test start only on jvm 11+
[Cherry-picked f5dc97f]
1 parent a2ba08f commit 4aed7f5

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease11Suite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ package dotty.tools.pc.tests.completion
33
import dotty.tools.pc.base.BaseCompletionSuite
44

55
import org.junit.Test
6+
import org.junit.Before
67
import java.nio.file.Path
8+
import dotty.tools.pc.utils.JRE
79

810
class CompletionRelease11Suite extends BaseCompletionSuite:
911

1012
override protected def scalacOptions(classpath: Seq[Path]): Seq[String] =
1113
"-release:11" +: super.scalacOptions(classpath)
1214

15+
@Before
16+
def beforeMethod(): Unit =
17+
org.junit.Assume.assumeTrue(JRE.getJavaMajorVersion >= 11)
18+
1319
@Test def java11Symbols =
1420
check(
1521
"""

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease8Suite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ package dotty.tools.pc.tests.completion
33
import dotty.tools.pc.base.BaseCompletionSuite
44

55
import org.junit.Test
6+
import org.junit.Before
67
import java.nio.file.Path
8+
import dotty.tools.pc.utils.JRE
79

810
class CompletionRelease8Suite extends BaseCompletionSuite:
911

1012
override protected def scalacOptions(classpath: Seq[Path]): Seq[String] =
1113
"-release:8" +: super.scalacOptions(classpath)
1214

15+
@Before
16+
def beforeMethod(): Unit =
17+
org.junit.Assume.assumeTrue(JRE.getJavaMajorVersion >= 8)
18+
1319
@Test def noJvm11Symbols =
1420
check(
1521
"""
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package dotty.tools.pc.utils
2+
3+
object JRE:
4+
5+
def getJavaMajorVersion: Int =
6+
val javaVersion = sys.env.get("java.version").filter(!_.isEmpty())
7+
8+
javaVersion match
9+
case Some(version) if version.startsWith("1.8") => 8
10+
case _ =>
11+
scala.util.Try:
12+
val versionMethod = classOf[Runtime].getMethod("version")
13+
versionMethod.nn.setAccessible(true)
14+
val version = versionMethod.nn.invoke(null)
15+
16+
val majorMethod = version.getClass().getMethod("feature")
17+
majorMethod.nn.setAccessible(true)
18+
val major = majorMethod.nn.invoke(version).asInstanceOf[Int]
19+
major
20+
.getOrElse(8) // Minimal version supported by Scala
21+
22+

0 commit comments

Comments
 (0)