Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit 4eac034

Browse files
committed
Pass testSourcePath as SuiteRunner constructor arg
1 parent dcf4883 commit 4eac034

File tree

6 files changed

+17
-28
lines changed

6 files changed

+17
-28
lines changed

src/main/scala/scala/tools/partest/PartestDefaults.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import scala.tools.nsc.Properties.{ propOrElse, propOrNone, propOrEmpty }
66
import java.lang.Runtime.{ getRuntime => runtime }
77

88
object PartestDefaults {
9+
def sourcePath = propOrElse("partest.srcdir", "files")
910
def javaCmd = propOrElse("partest.javacmd", "java")
1011
def javacCmd = propOrElse("partest.javac_cmd", "javac")
1112
def javaOpts = propOrElse("partest.java_opts", "")

src/main/scala/scala/tools/partest/PartestTask.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ class PartestTask extends Task with CompilationPathProperty with ScalaTask {
115115
NestUI.setDebug()
116116
}
117117

118-
srcDir foreach (nest.PathSettings.testSourcePath = _)
119-
120118
if (compilationPath.isEmpty) sys.error("Mandatory attribute 'compilationPath' is not set.")
121119

122120
def scalacArgsFlat: Array[String] = scalacArgs.toArray flatMap (_ flatMap { a =>
@@ -125,7 +123,7 @@ class PartestTask extends Task with CompilationPathProperty with ScalaTask {
125123
})
126124

127125
var failureCount = 0
128-
val summary = new scala.tools.partest.nest.AntRunner(compilationPath.get.list, javacmd.getOrElse(null), javaccmd.getOrElse(null), scalacArgsFlat) {
126+
val summary = new scala.tools.partest.nest.AntRunner(srcDir.getOrElse(null), compilationPath.get.list, javacmd.getOrElse(null), javaccmd.getOrElse(null), scalacArgsFlat) {
129127
def echo(msg: String): Unit = PartestTask.this.log(msg)
130128
def log(msg: String): Unit = PartestTask.this.log(msg)
131129

src/main/scala/scala/tools/partest/nest/AntRunner.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import sbt.testing.SuiteSelector
2020
import sbt.testing.TestSelector
2121

2222
// not using any Scala types to ease calling across different scala versions
23-
abstract class AntRunner(compilationPaths: Array[String], javaCmd: File, javacCmd: File, scalacArgs: Array[String]) extends SuiteRunner(
23+
abstract class AntRunner(srcDir: String, compilationPaths: Array[String], javaCmd: File, javacCmd: File, scalacArgs: Array[String]) extends SuiteRunner(
24+
testSourcePath = Option(srcDir) getOrElse PartestDefaults.sourcePath,
2425
new FileManager(testClassPath = compilationPaths map { fs => Path(fs) } toList),
2526
updateCheck = false,
2627
failed = false,
@@ -67,7 +68,9 @@ abstract class AntRunner(compilationPaths: Array[String], javaCmd: File, javacCm
6768
}
6869
}
6970

70-
class SBTRunner(partestFingerprint: Fingerprint, eventHandler: EventHandler, loggers: Array[Logger], compilationPaths: Array[String], javaCmd: File, javacCmd: File, scalacArgs: Array[String]) extends AntRunner(compilationPaths, javaCmd, javacCmd, scalacArgs) {
71+
class SBTRunner(partestFingerprint: Fingerprint, eventHandler: EventHandler, loggers: Array[Logger],
72+
srcDir: String, compilationPaths: Array[String], javaCmd: File, javacCmd: File, scalacArgs: Array[String])
73+
extends AntRunner(srcDir, compilationPaths, javaCmd, javacCmd, scalacArgs) {
7174
override def error(msg: String): Nothing = sys.error(msg)
7275
def echo(msg: String): Unit = loggers foreach { l => l.info(msg) }
7376
def log(msg: String): Unit = loggers foreach { l => l.debug(msg) }

src/main/scala/scala/tools/partest/nest/ConsoleRunner.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class ConsoleRunner(argstr: String) extends {
1919
} with ConsoleRunnerSpec with Instance {
2020

2121
val suiteRunner = new SuiteRunner (
22-
new ConsoleFileManager(if (optPack) Some("build/pack") else optBuildPath, optClassPath),
23-
optUpdateCheck,
24-
optFailed)
22+
testSourcePath = optSourcePath.map(_.getAbsolutePath) getOrElse PartestDefaults.sourcePath,
23+
fileManager = new ConsoleFileManager(if (optPack) Some("build/pack") else optBuildPath, optClassPath),
24+
updateCheck = optUpdateCheck,
25+
failed = optFailed)
2526
import suiteRunner._
2627
import NestUI._
2728
import NestUI.color._
@@ -109,7 +110,6 @@ class ConsoleRunner(argstr: String) extends {
109110
echoWarning(s"Discarding ${invalid.size} invalid test paths")
110111
}
111112

112-
optSourcePath foreach (PathSettings.testSourcePath = _)
113113
optTimeout foreach (x => setProp("partest.timeout", x))
114114

115115
NestUI echo banner

src/main/scala/scala/tools/partest/nest/PathSettings.scala

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,7 @@ import Path._
2020
* NOTE: the members are methods because `testSourcePath` changes.
2121
*/
2222
object PathSettings {
23-
private[this] var myTestSourcePath: String = null
24-
private def defaultSrcDirName = propOrElse("partest.srcdir", "files")
25-
26-
/** testSourcePath determines where we look for tests, relative to the `testRoot`
27-
* after it's been read, it cannot be changed
28-
*/
29-
def testSourcePath: String = {
30-
if (myTestSourcePath eq null) myTestSourcePath = defaultSrcDirName
31-
myTestSourcePath
32-
}
33-
34-
/** testSourcePath determines where we look for tests, relative to the `testRoot`
35-
* it can be set only if it hasn't been read yet
36-
*/
37-
def testSourcePath_= (path: String): Unit = {
38-
// assert(myTestSourcePath eq null, "Test Source Path set after use.")
39-
myTestSourcePath = path
40-
}
23+
private[nest] var testSourcePath: String = null // set by RunnerSuite
4124

4225
// defaults can be set using the environment, but note PathSettings is mutable
4326
private def defaultTestRootName = propOrNone("partest.root")

src/main/scala/scala/tools/partest/nest/Runner.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ class Runner(val testFile: File, val suiteRunner: SuiteRunner) {
735735

736736
/** Extended by Ant- and ConsoleRunner for running a set of tests. */
737737
class SuiteRunner(
738+
val testSourcePath: String,
738739
val fileManager: FileManager,
739740
val updateCheck: Boolean,
740741
val failed: Boolean,
@@ -745,7 +746,10 @@ class SuiteRunner(
745746
import PartestDefaults.{ numThreads, waitTime }
746747

747748
setUncaughtHandler
748-
749+
750+
// TODO: make this immutable
751+
PathSettings.testSourcePath = testSourcePath
752+
749753
def banner = {
750754
def relativize(path: String) = path.replace(fileManager.baseDir.toString, "$baseDir").replace(PathSettings.srcDir.toString, "$sourceDir")
751755
val vmBin = javaHome + fileSeparator + "bin"

0 commit comments

Comments
 (0)