aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-11-23 15:42:46 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-11-23 18:08:53 +0100
commitfa6054b874d1a9b6428d30f88a0346fc994c97de (patch)
tree58aa2745cbd0216fbe5bbe60d4bc52b7637093da
parente0439545c598478a9c619ae704d7859f866e0664 (diff)
downloaddotty-fa6054b874d1a9b6428d30f88a0346fc994c97de.tar.gz
dotty-fa6054b874d1a9b6428d30f88a0346fc994c97de.tar.bz2
dotty-fa6054b874d1a9b6428d30f88a0346fc994c97de.zip
Make tests depend on environment variables for classpath jars
sbt adds the correct jars to classpath and the tests depend on `packageAll` which creates these. When using something else however, these together with `sbt-interfaces` do not get propagated from the build. To remedy this and make the testing a bit more flexible, we now take these from `sys.props` instead, see `tests/dotty/Jars.scala`. If the props aren't defined we fall back to the ones default to sbt.
-rw-r--r--compiler/test/dotc/tests.scala31
-rw-r--r--compiler/test/dotty/Jars.scala22
-rw-r--r--compiler/test/dotty/tools/DottyTest.scala5
-rw-r--r--compiler/test/dotty/tools/ShowClassTests.scala6
-rw-r--r--compiler/test/dotty/tools/dotc/EntryPointsTest.scala7
-rw-r--r--compiler/test/dotty/tools/dotc/InterfaceEntryPointTest.scala7
-rw-r--r--compiler/test/dotty/tools/dotc/repl/TestREPL.scala8
7 files changed, 61 insertions, 25 deletions
diff --git a/compiler/test/dotc/tests.scala b/compiler/test/dotc/tests.scala
index a3946947c..7d3dbd8db 100644
--- a/compiler/test/dotc/tests.scala
+++ b/compiler/test/dotc/tests.scala
@@ -1,5 +1,6 @@
package dotc
+import dotty.Jars
import dotty.tools.dotc.CompilerTest
import org.junit.{Before, Test}
@@ -32,18 +33,28 @@ class tests extends CompilerTest {
)
val classPath = {
- val paths = List(
- "../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar",
- "./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar",
- "../interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar"
- ).map { p =>
+ val paths = Jars.dottyTestDeps map { p =>
val file = new JFile(p)
assert(
file.exists,
- s"""File "$p" couldn't be found. Run `packageAll` from build tool before testing"""
+ s"""|File "$p" couldn't be found. Run `packageAll` from build tool before
+ |testing.
+ |
+ |If running without sbt, test paths need to be setup environment variables:
+ |
+ | - DOTTY_LIBRARY
+ | - DOTTY_COMPILER
+ | - DOTTY_INTERFACES
+ | - DOTTY_EXTRAS
+ |
+ |Where these all contain locations, except extras which is a comma
+ |separated list of jars.
+ |
+ |When compiling with eclipse, you need the sbt-interfaces jar, but
+ |it in extras."""
)
file.getAbsolutePath
- }.mkString(":")
+ } mkString (":")
List("-classpath", paths)
}
@@ -338,10 +349,16 @@ class tests extends CompilerTest {
@Test def tasty_tests = compileDir(testsDir, "tasty", testPickling)
@Test def tasty_bootstrap = {
+ val f = new JFile(getClass.getProtectionDomain.getCodeSource.getLocation.getPath)
+ println(f)
+ println(System.getProperty("java.class.path"))
+
+
val opt = List("-priorityclasspath", defaultOutputDir, "-Ylog-classpath")
// first compile dotty
compileDir(dottyDir, ".", List("-deep", "-Ycheck-reentrant", "-strict"))(allowDeepSubtypes)
+
compileDir(dottyDir, "tools", opt)
compileDir(toolsDir, "dotc", opt)
compileDir(dotcDir, "ast", opt)
diff --git a/compiler/test/dotty/Jars.scala b/compiler/test/dotty/Jars.scala
new file mode 100644
index 000000000..989726bd4
--- /dev/null
+++ b/compiler/test/dotty/Jars.scala
@@ -0,0 +1,22 @@
+package dotty
+
+/** Jars used when compiling test, defaults to sbt locations */
+object Jars {
+ val dottyLib: String = sys.env.get("DOTTY_LIB") getOrElse {
+ "../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
+ }
+
+ val dottyCompiler: String = sys.env.get("DOTTY_COMPILER") getOrElse {
+ "./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar"
+ }
+
+ val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE") getOrElse {
+ "../interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar"
+ }
+
+ val dottyExtras: List[String] = sys.env.get("DOTTY_EXTRAS")
+ .map(_.split(",").toList).getOrElse(Nil)
+
+ val dottyTestDeps: List[String] =
+ dottyLib :: dottyCompiler :: dottyInterfaces :: dottyExtras
+}
diff --git a/compiler/test/dotty/tools/DottyTest.scala b/compiler/test/dotty/tools/DottyTest.scala
index 77dc97bec..bd6b1cfa4 100644
--- a/compiler/test/dotty/tools/DottyTest.scala
+++ b/compiler/test/dotty/tools/DottyTest.scala
@@ -23,10 +23,7 @@ class DottyTest extends ContextEscapeDetection{
import base.settings._
val ctx = base.initialCtx.fresh
ctx.setSetting(ctx.settings.encoding, "UTF8")
- ctx.setSetting(
- ctx.settings.classpath,
- "../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
- )
+ ctx.setSetting(ctx.settings.classpath, Jars.dottyLib)
// when classpath is changed in ctx, we need to re-initialize to get the
// correct classpath from PathResolver
base.initialize()(ctx)
diff --git a/compiler/test/dotty/tools/ShowClassTests.scala b/compiler/test/dotty/tools/ShowClassTests.scala
index 3c730b716..4aa9e8845 100644
--- a/compiler/test/dotty/tools/ShowClassTests.scala
+++ b/compiler/test/dotty/tools/ShowClassTests.scala
@@ -1,4 +1,5 @@
-package dotty.tools
+package dotty
+package tools
import dotc.core._
import dotc.core.Contexts._
@@ -18,8 +19,7 @@ class ShowClassTests extends DottyTest {
ctx.setSetting(ctx.settings.encoding, "UTF8")
ctx.setSetting(
ctx.settings.classpath,
- "../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" +
- ":../interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar"
+ Jars.dottyLib + ":" + Jars.dottyInterfaces
)
base.initialize()(ctx)
ctx
diff --git a/compiler/test/dotty/tools/dotc/EntryPointsTest.scala b/compiler/test/dotty/tools/dotc/EntryPointsTest.scala
index 4a87bbcb5..f095dc725 100644
--- a/compiler/test/dotty/tools/dotc/EntryPointsTest.scala
+++ b/compiler/test/dotty/tools/dotc/EntryPointsTest.scala
@@ -1,4 +1,5 @@
-package dotty.tools
+package dotty
+package tools
package dotc
import org.junit.Test
@@ -20,9 +21,9 @@ class EntryPointsTest {
private val sources =
List("../tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath())
private val dottyInterfaces =
- new java.io.File("../interfaces/dotty-interfaces-0.1-SNAPSHOT.jar").getPath
+ new java.io.File(Jars.dottyInterfaces).getPath
private val dottyLibrary =
- new java.io.File("../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar").getPath
+ new java.io.File(Jars.dottyLib).getPath
private val args =
sources ++
List("-d", "../out/") ++
diff --git a/compiler/test/dotty/tools/dotc/InterfaceEntryPointTest.scala b/compiler/test/dotty/tools/dotc/InterfaceEntryPointTest.scala
index b36ea2955..7589e6f3b 100644
--- a/compiler/test/dotty/tools/dotc/InterfaceEntryPointTest.scala
+++ b/compiler/test/dotty/tools/dotc/InterfaceEntryPointTest.scala
@@ -1,4 +1,5 @@
-package dotty.tools.dotc
+package dotty
+package tools.dotc
import org.junit.Test
import org.junit.Assert._
@@ -21,9 +22,9 @@ class InterfaceEntryPointTest {
val sources =
List("../tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath())
val dottyInterfaces =
- new java.io.File("../interfaces/dotty-interfaces-0.1-SNAPSHOT.jar").getPath
+ new java.io.File(Jars.dottyInterfaces).getPath
val dottyLibrary =
- new java.io.File("../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar").getPath
+ new java.io.File(Jars.dottyLib).getPath
val args =
sources ++
diff --git a/compiler/test/dotty/tools/dotc/repl/TestREPL.scala b/compiler/test/dotty/tools/dotc/repl/TestREPL.scala
index 2263e85a0..70f701791 100644
--- a/compiler/test/dotty/tools/dotc/repl/TestREPL.scala
+++ b/compiler/test/dotty/tools/dotc/repl/TestREPL.scala
@@ -1,4 +1,5 @@
-package dotty.tools.dotc
+package dotty
+package tools.dotc
package repl
import core.Contexts.Context
@@ -23,10 +24,7 @@ class TestREPL(script: String) extends REPL {
override def context(ctx: Context) = {
val fresh = ctx.fresh
fresh.setSetting(ctx.settings.color, "never")
- fresh.setSetting(
- ctx.settings.classpath,
- "../library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
- )
+ fresh.setSetting(ctx.settings.classpath, Jars.dottyLib)
fresh.initialize()(fresh)
fresh
}