Skip to content

Commit ef29ed7

Browse files
committed
Add Properties object for dotty testing props and env
1 parent 428135c commit ef29ed7

File tree

4 files changed

+64
-12
lines changed

4 files changed

+64
-12
lines changed

compiler/test/dotc/tests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class tests extends CompilerTest {
2121
// tests that match regex '(pos|dotc|run|java|compileStdLib)\.*' would be
2222
// executed as benchmarks.
2323

24-
def isRunByDrone: Boolean = sys.props.isDefinedAt("DRONE")
24+
def isRunByDrone: Boolean = dotty.Properties.runningDrone
2525

2626
val defaultOutputDir = "../out/"
2727

@@ -227,7 +227,7 @@ class tests extends CompilerTest {
227227
|../scala-scala/src/library/scala/collection/parallel/mutable/ParSet.scala
228228
|../scala-scala/src/library/scala/collection/mutable/SetLike.scala""".stripMargin)(scala2mode ++ defaultOptions)
229229

230-
@Test def dotty = {
230+
@Test def dottyBooted = {
231231
dottyBootedLib
232232
dottyDependsOnBootedLib
233233
}

compiler/test/dotty/Jars.scala

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,34 @@ package dotty
22

33
/** Jars used when compiling test, normally set from the sbt build */
44
object Jars {
5+
/** Dotty library Jar */
56
val dottyLib: String = sys.env.get("DOTTY_LIB")
6-
.getOrElse(sys.props("dotty.tests.classes.library"))
7+
.getOrElse(Properties.dottyLib)
78

9+
/** Dotty Compiler Jar */
810
val dottyCompiler: String = sys.env.get("DOTTY_COMPILER")
9-
.getOrElse(sys.props("dotty.tests.classes.compiler"))
11+
.getOrElse(Properties.dottyCompiler)
1012

13+
/** Dotty Interfaces Jar */
1114
val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE")
12-
.getOrElse(sys.props("dotty.tests.classes.interfaces"))
15+
.getOrElse(Properties.dottyInterfaces)
1316

14-
val dottyExtras: List[String] = Option(sys.env.get("DOTTY_EXTRAS")
15-
.getOrElse(sys.props("dotty.tests.extraclasspath")))
16-
.map(_.split(":").toList).getOrElse(Nil)
17+
/** Dotty extras classpath from env or properties */
18+
val dottyExtras: List[String] = sys.env.get("DOTTY_EXTRAS")
19+
.map(_.split(":").toList).getOrElse(Properties.dottyExtras)
1720

21+
/** Dotty REPL dependencies */
1822
val dottyReplDeps: List[String] = dottyLib :: dottyExtras
1923

24+
/** Dotty test dependencies */
2025
val dottyTestDeps: List[String] =
2126
dottyLib :: dottyCompiler :: dottyInterfaces :: dottyExtras
2227

23-
28+
/** Gets the scala 2.* library at runtime, note that doing this is unsafe
29+
* unless you know that the library will be on the classpath of the running
30+
* application. It is currently safe to call this function if the tests are
31+
* run by sbt.
32+
*/
2433
def scalaLibraryFromRuntime: String = findJarFromRuntime("scala-library-2.")
2534

2635
private def findJarFromRuntime(partialName: String) = {
@@ -31,5 +40,4 @@ object Jars {
3140
)
3241
}
3342
}
34-
3543
}

compiler/test/dotty/Properties.scala

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package dotty
2+
3+
/** Runtime properties from defines or environmnent */
4+
object Properties {
5+
6+
/** If property is unset or "TRUE" we consider it `true` */
7+
private[this] def propIsNullOrTrue(prop: String): Boolean = {
8+
val prop = System.getProperty("dotty.tests.interactive")
9+
prop == null || prop == "TRUE"
10+
}
11+
12+
/** Are we running on the Drone CI? */
13+
val runningDrone: Boolean = sys.env.isDefinedAt("DRONE")
14+
15+
/** Tests should run interactive? */
16+
val testsInteractive: Boolean = propIsNullOrTrue("dotty.tests.interactive")
17+
18+
/** Filter out tests not matching the regex supplied by "dotty.tests.filter"
19+
* define
20+
*/
21+
val testsFilter: Option[String] = sys.props.get("dotty.tests.filter")
22+
23+
/** Should Unit tests run in safe mode?
24+
*
25+
* For run tests this means that we respawn child JVM processes after each
26+
* test, so that they are never reused.
27+
*/
28+
val testsSafeMode: Boolean = sys.props.isDefinedAt("dotty.tests.safemode")
29+
30+
/** Dotty compiler path provided through define */
31+
def dottyCompiler: String = sys.props("dotty.tests.classes.compiler")
32+
33+
/** Dotty classpath extras provided through define */
34+
def dottyExtras: List[String] =
35+
Option(sys.props("dotty.tests.extraclasspath"))
36+
.map(_.split(":").toList)
37+
.getOrElse(Nil)
38+
39+
/** Dotty interfaces path provided through define */
40+
def dottyInterfaces: String = sys.props("dotty.tests.classes.interfaces")
41+
42+
/** Dotty library path provided through define */
43+
def dottyLib: String = sys.props("dotty.tests.classes.library")
44+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class CompilationTests extends SummaryReport with ParallelTesting {
1616

1717
def maxDuration = 180.seconds
1818
def numberOfSlaves = 5
19-
def safeMode = sys.env.get("dotty.tests.safemode").isDefined
19+
def safeMode = Properties.testsSafeMode
2020
def isInteractive = SummaryReport.isInteractive
21-
def testFilter = sys.props.get("dotty.tests.filter").map(r => new Regex(r))
21+
def testFilter = Properties.testsFilter.map(r => new Regex(r))
2222

2323
// Positive tests ------------------------------------------------------------
2424

0 commit comments

Comments
 (0)