aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/Jars.scala
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/test/dotty/Jars.scala')
-rw-r--r--compiler/test/dotty/Jars.scala33
1 files changed, 27 insertions, 6 deletions
diff --git a/compiler/test/dotty/Jars.scala b/compiler/test/dotty/Jars.scala
index f062f8b25..bc000fced 100644
--- a/compiler/test/dotty/Jars.scala
+++ b/compiler/test/dotty/Jars.scala
@@ -2,21 +2,42 @@ package dotty
/** Jars used when compiling test, normally set from the sbt build */
object Jars {
+ /** Dotty library Jar */
val dottyLib: String = sys.env.get("DOTTY_LIB")
- .getOrElse(sys.props("dotty.tests.classes.library"))
+ .getOrElse(Properties.dottyLib)
+ /** Dotty Compiler Jar */
val dottyCompiler: String = sys.env.get("DOTTY_COMPILER")
- .getOrElse(sys.props("dotty.tests.classes.compiler"))
+ .getOrElse(Properties.dottyCompiler)
+ /** Dotty Interfaces Jar */
val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE")
- .getOrElse(sys.props("dotty.tests.classes.interfaces"))
+ .getOrElse(Properties.dottyInterfaces)
- val dottyExtras: List[String] = Option(sys.env.get("DOTTY_EXTRAS")
- .getOrElse(sys.props("dotty.tests.extraclasspath")))
- .map(_.split(":").toList).getOrElse(Nil)
+ /** Dotty extras classpath from env or properties */
+ val dottyExtras: List[String] = sys.env.get("DOTTY_EXTRAS")
+ .map(_.split(":").toList).getOrElse(Properties.dottyExtras)
+ /** Dotty REPL dependencies */
val dottyReplDeps: List[String] = dottyLib :: dottyExtras
+ /** Dotty test dependencies */
val dottyTestDeps: List[String] =
dottyLib :: dottyCompiler :: dottyInterfaces :: dottyExtras
+
+ /** Gets the scala 2.* library at runtime, note that doing this is unsafe
+ * unless you know that the library will be on the classpath of the running
+ * application. It is currently safe to call this function if the tests are
+ * run by sbt.
+ */
+ def scalaLibraryFromRuntime: String = findJarFromRuntime("scala-library-2.")
+
+ private def findJarFromRuntime(partialName: String) = {
+ val urls = ClassLoader.getSystemClassLoader.asInstanceOf[java.net.URLClassLoader].getURLs.map(_.getFile.toString)
+ urls.find(_.contains(partialName)).getOrElse {
+ throw new java.io.FileNotFoundException(
+ s"""Unable to locate $partialName on classpath:\n${urls.toList.mkString("\n")}"""
+ )
+ }
+ }
}