diff options
Diffstat (limited to 'src')
4 files changed, 26 insertions, 70 deletions
diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala index c6a51ebd83..d0c2747ae1 100644 --- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala +++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala @@ -111,7 +111,7 @@ class InterpreterLoop(in0: Option[BufferedReader], out: PrintWriter) { /** Create a new interpreter. */ def createInterpreter() { if (!addedClasspath.isEmpty) - settings.classpath.value += addedClasspath.map(File.pathSeparator + _).mkString + addedClasspath foreach (settings appendToClasspath _) interpreter = new Interpreter(settings, out) { override protected def parentClassLoader = classOf[InterpreterLoop].getClassLoader diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index e61f7dc11e..8c921b98a1 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -7,6 +7,7 @@ package scala.tools.nsc import java.io.File +import File.pathSeparator import io.AbstractFile import util.SourceFile import Settings._ @@ -22,7 +23,7 @@ class Settings(errorFn: String => Unit) extends ScalacSettings { // given any number of possible path segments, flattens down to a // :-separated style path private def concatPath(segments: Option[String]*): String = - segments.toList.flatMap(x => x) mkString File.pathSeparator + segments.toList.flatMap(x => x) mkString pathSeparator protected def classpathDefault = sysenvopt("CLASSPATH") getOrElse "." @@ -817,6 +818,7 @@ trait ScalacSettings { * Temporary Settings */ val suppressVTWarn = BooleanSetting ("-Ysuppress-vt-typer-warnings", "Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL!") + def appendToClasspath(entry: String) = classpath.value += (pathSeparator + entry) /** * Standard settings diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index b67653d900..e9d9d65390 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -113,8 +113,7 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler { out match { case Some(outDir) => command.settings.outdir.value = outDir.getAbsolutePath - command.settings.classpath.value = command.settings.classpath.value+ - File.pathSeparator+outDir.getAbsolutePath + command.settings appendToClasspath outDir.getAbsolutePath case None => // do nothing } diff --git a/src/partest/scala/tools/partest/nest/TestFile.scala b/src/partest/scala/tools/partest/nest/TestFile.scala index 5a62beb48d..a7656a3c12 100644 --- a/src/partest/scala/tools/partest/nest/TestFile.scala +++ b/src/partest/scala/tools/partest/nest/TestFile.scala @@ -10,23 +10,24 @@ package nest import java.io.{File, BufferedReader, FileReader} import scala.tools.nsc.Settings +import scala.tools.nsc.io.{ Path, Directory } + +abstract class TestFile(kind: String) { + def file: File + def fileManager: FileManager + def createOutDir: Boolean -class TestFile(kind: String, val file: File, val fileManager: FileManager, createOutDir: Boolean) { val dir = file.getParentFile val dirpath = dir.getAbsolutePath val fileBase: String = basename(file.getName) + def objDir = fileBase + "-" + kind + ".obj" // @mutates settings protected def baseSettings(settings: Settings) { - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+dirpath + settings appendToClasspath dirpath + if (createOutDir) - settings.outdir.value = { - val outDir = new File(dir, fileBase + "-" + kind + ".obj") - if (!outDir.exists) - outDir.mkdir() - outDir.toString - } + settings.outdir.value = (Path(dir) / objDir).createDirectory(true).path // add additional flags found in 'testname.flags' val flagsFile = new File(dir, fileBase + ".flags") @@ -40,6 +41,7 @@ class TestFile(kind: String, val file: File, val fileManager: FileManager, creat def defineSettings(settings: Settings) { baseSettings(settings) + settings appendToClasspath fileManager.CLASSPATH } private def basename(name: String): String = { @@ -50,68 +52,21 @@ class TestFile(kind: String, val file: File, val fileManager: FileManager, creat override def toString(): String = kind+" "+file } -case class PosTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("pos", file, fileManager, createOutDir) { - override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH - } -} - -case class NegTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("neg", file, fileManager, createOutDir) { - override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH - } -} - -case class RunTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("run", file, fileManager, createOutDir) { +case class PosTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("pos") +case class NegTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("neg") +case class RunTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("run") +case class BuildManagerTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("bm") +case class ScalaCheckTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("scalacheck") +case class JvmTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("jvm") +case class ShootoutTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("shootout") { override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH - } -} - -case class BuildManagerTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("bm", file, fileManager, createOutDir) { - override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH - } -} - -case class ScalaCheckTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("scalacheck", file, fileManager, createOutDir) { - override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH - } -} - -case class JvmTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("jvm", file, fileManager, createOutDir) { - override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH - } -} - -case class ShootoutTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("shootout", file, fileManager, createOutDir) { - override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH + super.defineSettings(settings) settings.outdir.value = file.getParent } } - -case class ScalapTestFile(override val file: File, override val fileManager: FileManager, createOutDir: Boolean) extends TestFile("scalap", file, fileManager, createOutDir) { +case class ScalapTestFile(file: File, fileManager: FileManager, createOutDir: Boolean) extends TestFile("scalap") { override def defineSettings(settings: Settings) { - baseSettings(settings) - settings.classpath.value = settings.classpath.value+ - File.pathSeparator+fileManager.CLASSPATH + super.defineSettings(settings) settings.outdir.value = file.getParent } } |