Skip to content

Commit ebbe0b2

Browse files
committed
Adapt tests for Java 9
- scala-library and scala-xml used to be on the bootclasspath and need to be on the regular classpath now. - Jars.findJarFromRuntime relied on ClassLoader.getSystemClassLoader being an URLClassLoader, this isn't true anymore in Java 9. This is replaced by passing properties from the sbt build instead, like we were already doing for the dotty jars. While I was at it I completely killed dotty.Jars and cleaned things a bit.
1 parent 1dee611 commit ebbe0b2

17 files changed

+134
-161
lines changed

compiler/test/dotty/Jars.scala

Lines changed: 0 additions & 62 deletions
This file was deleted.

compiler/test/dotty/Properties.scala

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,36 @@ object Properties {
3232
*/
3333
val testsSafeMode: Boolean = sys.props.isDefinedAt("dotty.tests.safemode")
3434

35-
/** Dotty compiler path provided through define */
36-
def dottyCompiler: String = sys.props("dotty.tests.classes.compiler")
37-
3835
/** Dotty classpath extras provided through define */
3936
def dottyExtras: List[String] =
4037
Option(sys.props("dotty.tests.extraclasspath"))
4138
.map(_.split(":").toList)
4239
.getOrElse(Nil)
4340

44-
/** Dotty interfaces path provided through define */
45-
def dottyInterfaces: String = sys.props("dotty.tests.classes.interfaces")
41+
/** dotty-interfaces jar */
42+
def dottyInterfaces: String = sys.props("dotty.tests.classes.dottyInterfaces")
43+
44+
/** dotty-library jar */
45+
def dottyLibrary: String = sys.props("dotty.tests.classes.dottyLibrary")
46+
47+
/** dotty-compiler jar */
48+
def dottyCompiler: String = sys.props("dotty.tests.classes.dottyCompiler")
49+
50+
/** compiler-interface jar */
51+
def compilerInterface: String = sys.props("dotty.tests.classes.compilerInterface")
52+
53+
/** scala-library jar */
54+
def scalaLibrary: String = sys.props("dotty.tests.classes.scalaLibrary")
55+
56+
/** scala-asm jar */
57+
def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm")
58+
59+
/** scala-xml jar */
60+
def scalaXml: String = sys.props("dotty.tests.classes.scalaXml")
61+
62+
/** jline-terminal jar */
63+
def jlineTerminal: String = sys.props("dotty.tests.classes.jlineTerminal")
4664

47-
/** Dotty library path provided through define */
48-
def dottyLib: String = sys.props("dotty.tests.classes.library")
65+
/** jline-reader jar */
66+
def jlineReader: String = sys.props("dotty.tests.classes.jlineReader")
4967
}

compiler/test/dotty/tools/DottyTest.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dotty
22
package tools
33

4+
import vulpix.TestConfiguration
5+
46
import dotc.core._
57
import dotc.core.Comments.{ContextDoc, ContextDocstrings}
68
import dotc.core.Contexts._
@@ -39,7 +41,7 @@ trait DottyTest extends ContextEscapeDetection {
3941

4042
protected def initializeCtx(fc: FreshContext): Unit = {
4143
fc.setSetting(fc.settings.encoding, "UTF8")
42-
fc.setSetting(fc.settings.classpath, Jars.dottyLib)
44+
fc.setSetting(fc.settings.classpath, TestConfiguration.basicClasspath)
4345
fc.setProperty(ContextDoc, new ContextDocstrings)
4446
}
4547

compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package dotty
22
package tools
33
package backend.jvm
44

5+
import vulpix.TestConfiguration
6+
57
import dotc.core.Contexts.{Context, ContextBase}
68
import dotc.core.Comments.{ContextDoc, ContextDocstrings}
79
import dotc.core.Phases.Phase
@@ -44,7 +46,7 @@ trait DottyBytecodeTest {
4446
def initCtx = {
4547
val ctx0 = (new ContextBase).initialCtx.fresh
4648
val outputDir = new VirtualDirectory("<DottyBytecodeTest output>")
47-
ctx0.setSetting(ctx0.settings.classpath, Jars.dottyLib)
49+
ctx0.setSetting(ctx0.settings.classpath, TestConfiguration.basicClasspath)
4850
ctx0.setProperty(ContextDoc, new ContextDocstrings)
4951
ctx0.setSetting(ctx0.settings.outputDir, outputDir)
5052
}

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,56 +33,56 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
3333

3434
@Test def posWithCompiler: Unit = {
3535
implicit val testGroup: TestGroup = TestGroup("compilePosWithCompiler")
36-
compileFilesInDir("tests/pos-with-compiler", defaultOptions) +
37-
compileDir("compiler/src/dotty/tools/dotc/ast", defaultOptions) +
38-
compileDir("compiler/src/dotty/tools/dotc/config", defaultOptions) +
39-
compileDir("compiler/src/dotty/tools/dotc/core", defaultOptions) +
40-
compileDir("compiler/src/dotty/tools/dotc/transform", defaultOptions) +
41-
compileDir("compiler/src/dotty/tools/dotc/parsing", defaultOptions) +
42-
compileDir("compiler/src/dotty/tools/dotc/printing", defaultOptions) +
43-
compileDir("compiler/src/dotty/tools/dotc/reporting", defaultOptions) +
44-
compileDir("compiler/src/dotty/tools/dotc/typer", defaultOptions) +
45-
compileDir("compiler/src/dotty/tools/dotc/util", defaultOptions) +
46-
compileDir("compiler/src/dotty/tools/io", defaultOptions) +
47-
compileDir("compiler/src/dotty/tools/dotc/core", TestFlags(classPath, noCheckOptions))
36+
compileFilesInDir("tests/pos-with-compiler", withCompilerOptions) +
37+
compileDir("compiler/src/dotty/tools/dotc/ast", withCompilerOptions) +
38+
compileDir("compiler/src/dotty/tools/dotc/config", withCompilerOptions) +
39+
compileDir("compiler/src/dotty/tools/dotc/core", withCompilerOptions) +
40+
compileDir("compiler/src/dotty/tools/dotc/transform", withCompilerOptions) +
41+
compileDir("compiler/src/dotty/tools/dotc/parsing", withCompilerOptions) +
42+
compileDir("compiler/src/dotty/tools/dotc/printing", withCompilerOptions) +
43+
compileDir("compiler/src/dotty/tools/dotc/reporting", withCompilerOptions) +
44+
compileDir("compiler/src/dotty/tools/dotc/typer", withCompilerOptions) +
45+
compileDir("compiler/src/dotty/tools/dotc/util", withCompilerOptions) +
46+
compileDir("compiler/src/dotty/tools/io", withCompilerOptions) +
47+
compileDir("compiler/src/dotty/tools/dotc/core", withCompilerOptions)
4848
}.checkCompile()
4949

5050
@Test def posTwiceWithCompiler: Unit = {
5151
implicit val testGroup: TestGroup = TestGroup("posTwiceWithCompiler")
52-
compileFile("tests/pos-with-compiler/Labels.scala", defaultOptions) +
53-
compileFile("tests/pos-with-compiler/Patterns.scala", defaultOptions) +
52+
compileFile("tests/pos-with-compiler/Labels.scala", withCompilerOptions) +
53+
compileFile("tests/pos-with-compiler/Patterns.scala", withCompilerOptions) +
5454
compileList(
5555
"testNonCyclic",
5656
List(
5757
"compiler/src/dotty/tools/dotc/CompilationUnit.scala",
5858
"compiler/src/dotty/tools/dotc/core/Types.scala",
5959
"compiler/src/dotty/tools/dotc/ast/Trees.scala"
6060
),
61-
defaultOptions.and("-Xprompt")
61+
withCompilerOptions
6262
) +
6363
compileList(
6464
"testIssue34",
6565
List(
6666
"compiler/src/dotty/tools/dotc/config/Properties.scala",
6767
"compiler/src/dotty/tools/dotc/config/PathResolver.scala"
6868
),
69-
defaultOptions.and("-Xprompt")
69+
withCompilerOptions
7070
)
7171
}.times(2).checkCompile()
7272

7373
// Negative tests ------------------------------------------------------------
7474

7575
@Test def negAll: Unit = {
7676
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
77-
compileFilesInDir("tests/neg-with-compiler", defaultOptions)
77+
compileFilesInDir("tests/neg-with-compiler", withCompilerOptions)
7878
}.checkExpectedErrors()
7979

8080
// Run tests -----------------------------------------------------------------
8181

8282
@Test def runWithCompiler: Unit = {
8383
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
84-
compileFilesInDir("tests/run-with-compiler", defaultRunWithCompilerOptions) +
85-
compileFile("tests/run-with-compiler-custom-args/staged-streams_1.scala", defaultRunWithCompilerOptions without "-Yno-deep-subtypes")
84+
compileFilesInDir("tests/run-with-compiler", withCompilerOptions) +
85+
compileFile("tests/run-with-compiler-custom-args/staged-streams_1.scala", withCompilerOptions without "-Yno-deep-subtypes")
8686
}.checkRuns()
8787

8888
// Pickling Tests ------------------------------------------------------------
@@ -92,24 +92,24 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
9292

9393
@Test def picklingWithCompiler: Unit = {
9494
implicit val testGroup: TestGroup = TestGroup("testPicklingWithCompiler")
95-
compileDir("compiler/src/dotty/tools", picklingOptions, recursive = false) +
96-
compileDir("compiler/src/dotty/tools/dotc", picklingOptions, recursive = false) +
97-
compileDir("library/src/dotty/runtime", picklingOptions) +
98-
compileDir("compiler/src/dotty/tools/backend/jvm", picklingOptions) +
99-
compileDir("compiler/src/dotty/tools/dotc/ast", picklingOptions) +
100-
compileDir("compiler/src/dotty/tools/dotc/core", picklingOptions, recursive = false) +
101-
compileDir("compiler/src/dotty/tools/dotc/config", picklingOptions) +
102-
compileDir("compiler/src/dotty/tools/dotc/parsing", picklingOptions) +
103-
compileDir("compiler/src/dotty/tools/dotc/printing", picklingOptions) +
104-
compileDir("compiler/src/dotty/tools/repl", picklingOptions) +
105-
compileDir("compiler/src/dotty/tools/dotc/rewrite", picklingOptions) +
106-
compileDir("compiler/src/dotty/tools/dotc/transform", picklingOptions) +
107-
compileDir("compiler/src/dotty/tools/dotc/typer", picklingOptions) +
108-
compileDir("compiler/src/dotty/tools/dotc/util", picklingOptions) +
109-
compileDir("compiler/src/dotty/tools/io", picklingOptions) +
110-
compileFile("tests/pos/pickleinf.scala", picklingOptions) +
111-
compileDir("compiler/src/dotty/tools/dotc/core/classfile", picklingOptions) +
112-
compileDir("compiler/src/dotty/tools/dotc/core/tasty", picklingOptions) +
113-
compileDir("compiler/src/dotty/tools/dotc/core/unpickleScala2", picklingOptions)
95+
compileDir("compiler/src/dotty/tools", picklingWithCompilerOptions, recursive = false) +
96+
compileDir("compiler/src/dotty/tools/dotc", picklingWithCompilerOptions, recursive = false) +
97+
compileDir("library/src/dotty/runtime", picklingWithCompilerOptions) +
98+
compileDir("compiler/src/dotty/tools/backend/jvm", picklingWithCompilerOptions) +
99+
compileDir("compiler/src/dotty/tools/dotc/ast", picklingWithCompilerOptions) +
100+
compileDir("compiler/src/dotty/tools/dotc/core", picklingWithCompilerOptions, recursive = false) +
101+
compileDir("compiler/src/dotty/tools/dotc/config", picklingWithCompilerOptions) +
102+
compileDir("compiler/src/dotty/tools/dotc/parsing", picklingWithCompilerOptions) +
103+
compileDir("compiler/src/dotty/tools/dotc/printing", picklingWithCompilerOptions) +
104+
compileDir("compiler/src/dotty/tools/repl", picklingWithCompilerOptions) +
105+
compileDir("compiler/src/dotty/tools/dotc/rewrite", picklingWithCompilerOptions) +
106+
compileDir("compiler/src/dotty/tools/dotc/transform", picklingWithCompilerOptions) +
107+
compileDir("compiler/src/dotty/tools/dotc/typer", picklingWithCompilerOptions) +
108+
compileDir("compiler/src/dotty/tools/dotc/util", picklingWithCompilerOptions) +
109+
compileDir("compiler/src/dotty/tools/io", picklingWithCompilerOptions) +
110+
compileFile("tests/pos/pickleinf.scala", picklingWithCompilerOptions) +
111+
compileDir("compiler/src/dotty/tools/dotc/core/classfile", picklingWithCompilerOptions) +
112+
compileDir("compiler/src/dotty/tools/dotc/core/tasty", picklingWithCompilerOptions) +
113+
compileDir("compiler/src/dotty/tools/dotc/core/unpickleScala2", picklingWithCompilerOptions)
114114
}.limitThreads(4).checkCompile()
115115
}

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ class CompilationTests extends ParallelTesting {
204204
defaultOutputDir + libGroup + "/src/:" +
205205
// as well as bootstrapped compiler:
206206
defaultOutputDir + dotty1Group + "/dotty/:" +
207-
// and the other compiler dependecies:
208-
Jars.dottyInterfaces + ":" + Jars.jlineTerminal + ":" + Jars.jlineReader,
207+
// and the other compiler dependenies:
208+
Properties.compilerInterface + ":" + Properties.scalaLibrary + ":" + Properties.scalaAsm + ":" +
209+
Properties.dottyInterfaces + ":" + Properties.jlineTerminal + ":" + Properties.jlineReader,
209210
Array("-Ycheck-reentrant", "-Yemit-tasty-in-class")
210211
)
211212

@@ -277,7 +278,7 @@ class CompilationTests extends ParallelTesting {
277278
val compileDir = createOutputDirsForDir(dir, sourceDir, outDir)
278279
import java.nio.file.StandardCopyOption.REPLACE_EXISTING
279280
Files.copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), REPLACE_EXISTING)
280-
val flags = TestFlags(classPath, noCheckOptions) and ("-Xplugin:" + compileDir.getAbsolutePath)
281+
val flags = TestFlags(withCompilerClasspath, noCheckOptions) and ("-Xplugin:" + compileDir.getAbsolutePath)
281282
SeparateCompilationSource("testPlugins", dir, flags, compileDir)
282283
}
283284

compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ package dotc
55
import org.junit.Test
66
import org.junit.Assert._
77

8-
import vulpix.TestConfiguration.mkClassPath
8+
import vulpix.TestConfiguration.mkClasspath
99

1010
class MissingCoreLibTests {
1111

1212
@Test def missingDottyLib: Unit = {
13-
val classPath = mkClassPath(Jars.dottyCompiler :: Jars.dottyInterfaces :: Jars.dottyExtras) // missing Jars.dottyLib
13+
val classPath = mkClasspath(List(Properties.scalaLibrary)) // missing Properties.dottyLibrary
1414
val source = "tests/pos/Foo.scala"
1515
val options = Array("-classpath", classPath, source)
1616
val reporter = Main.process(options)

compiler/test/dotty/tools/dotc/SettingsTests.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
package dotty.tools.dotc
1+
package dotty.tools
2+
package dotc
3+
4+
import vulpix.TestConfiguration
25

36
import org.junit.Test
47
import org.junit.Assert._
58

69
import java.nio.file._
710

8-
import dotty.Jars
9-
import dotty.tools.vulpix.TestConfiguration.mkClassPath
11+
import dotty.tools.vulpix.TestConfiguration.mkClasspath
1012

1113
class SettingsTests {
1214

@@ -18,11 +20,10 @@ class SettingsTests {
1820
}
1921

2022
@Test def jarOutput: Unit = {
21-
val classPath = mkClassPath(Jars.dottyTestDeps)
2223
val source = "tests/pos/Foo.scala"
2324
val out = Paths.get("out/jaredFoo.jar").normalize
2425
if (Files.exists(out)) Files.delete(out)
25-
val options = Array("-classpath", classPath, "-d", out.toString, source)
26+
val options = Array("-classpath", TestConfiguration.basicClasspath, "-d", out.toString, source)
2627
val reporter = Main.process(options)
2728
assertEquals(0, reporter.errorCount)
2829
assertTrue(Files.exists(out))

compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package tools
33
package dotc
44
package transform
55

6+
import vulpix.TestConfiguration
7+
68
import java.io._
79
import java.nio.file.{Path => JPath}
810

@@ -15,7 +17,7 @@ import vulpix.TestConfiguration
1517
class PatmatExhaustivityTest {
1618
val testsDir = "tests/patmat"
1719
// stop-after: patmatexhaust-huge.scala crash compiler
18-
val options = List("-color:never", "-Ystop-after:splitter", "-Ycheck-all-patmat", "-classpath", TestConfiguration.classPath)
20+
val options = List("-color:never", "-Ystop-after:splitter", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath)
1921

2022
private def compileFile(path: JPath) = {
2123
val stringBuffer = new StringWriter()

compiler/test/dotty/tools/repl/ReplTest.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
package dotty.tools.repl
1+
package dotty.tools
2+
package repl
3+
4+
import vulpix.TestConfiguration
25

36
import java.io.{ByteArrayOutputStream, PrintStream}
47

5-
import dotty.Jars
68
import dotty.tools.dotc.reporting.MessageRendering
79
import org.junit.{After, Before}
810

911

1012
class ReplTest private (out: ByteArrayOutputStream) extends ReplDriver(
11-
Array("-classpath", List(Jars.dottyLib, Jars.dottyInterfaces).mkString(":"), "-color:never"),
13+
Array("-classpath", TestConfiguration.basicClasspath, "-color:never"),
1214
new PrintStream(out)
1315
) with MessageRendering {
1416

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
346346
"javac",
347347
"-encoding", "UTF-8",
348348
"-classpath",
349-
s"${Jars.scalaLibrary}:${targetDir.getAbsolutePath}"
349+
s"${Properties.scalaLibrary}:${targetDir.getAbsolutePath}"
350350
) ++ flags.all.takeRight(2) ++ fs
351351

352352
val process = Runtime.getRuntime.exec(fullArgs)

compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ trait RunnerOrchestration {
159159
val sep = sys.props("file.separator")
160160
val cp =
161161
classOf[ChildJVMMain].getProtectionDomain.getCodeSource.getLocation.getFile + ":" +
162-
Jars.scalaLibrary
162+
Properties.scalaLibrary
163163
val javaBin = sys.props("java.home") + sep + "bin" + sep + "java"
164164
new ProcessBuilder(javaBin, "-Xmx1g", "-cp", cp, "dotty.tools.vulpix.ChildJVMMain")
165165
.redirectErrorStream(true)

0 commit comments

Comments
 (0)