summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala25
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala5
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala15
-rw-r--r--src/partest/scala/tools/partest/nest/FileManager.scala5
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala2
5 files changed, 39 insertions, 13 deletions
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index bcd0d3961b..44552f89cd 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -7,10 +7,10 @@
package scala.tools.partest.nest
-import scala.tools.nsc.{Global, Settings, CompilerCommand}
+import scala.tools.nsc.{Global, Settings, CompilerCommand, FatalError}
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
-import java.io.{File, BufferedReader, PrintWriter, FileWriter, StringWriter}
+import java.io.{File, BufferedReader, PrintWriter, FileReader, FileWriter, StringWriter}
class ExtConsoleReporter(override val settings: Settings, reader: BufferedReader, var writer: PrintWriter) extends ConsoleReporter(settings, reader, writer) {
def this(settings: Settings) = {
@@ -51,7 +51,23 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
def compile(out: Option[File], files: List[File], kind: String, log: File): Boolean = {
val testSettings = newSettings
val logWriter = new FileWriter(log)
- val args = List.fromArray(fileManager.SCALAC_OPTS.split("\\s"))
+
+ // check whether there is a ".flags" file
+ val testBase = {
+ val logBase = fileManager.basename(log.getName)
+ logBase.substring(0, logBase.length-4)
+ }
+ val argsFile = new File(log.getParentFile, testBase+".flags")
+ val argString = if (argsFile.exists) {
+ val fileReader = new FileReader(argsFile)
+ val reader = new BufferedReader(fileReader)
+ val options = reader.readLine()
+ reader.close()
+ options
+ } else ""
+ val allOpts = fileManager.SCALAC_OPTS+" "+argString
+ NestUI.verbose("scalac options: "+allOpts)
+ val args = List.fromArray(allOpts.split("\\s"))
val command = new CompilerCommand(args, testSettings, x => {}, false)
val global = newGlobal(command.settings, logWriter)
val testRep: ExtConsoleReporter = global.reporter.asInstanceOf[ExtConsoleReporter]
@@ -82,6 +98,9 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
testRep.writer.flush
testRep.writer.close
} catch {
+ case FatalError(msg) =>
+ logWriter.write("FatalError: "+msg)
+ return false
case e: Exception =>
e.printStackTrace()
return false
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index 0ae368c256..16493b8f63 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -258,11 +258,6 @@ else
}
}
- private def basename(name: String): String = {
- val inx = name.lastIndexOf(".")
- if (inx < 0) name else name.substring(0, inx)
- }
-
var testFiles: List[File] = List()
def getFiles(kind: String, doCheck: Boolean, filter: Option[(String, Boolean)]): List[File] = {
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
index e5ed9442fb..b43f430f4a 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
@@ -46,6 +46,12 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
case _ => false
}
+ def denotesTestFile(arg: String) =
+ arg.endsWith(".scala") || arg.endsWith(".res")
+
+ def denotesTestDir(arg: String) =
+ (new File(arg)).isDirectory
+
def main(argstr: String) {
// tokenize args. filter: "".split("\\s") yields Array("")
var args = List.fromArray(argstr.split("\\s")).remove(_ == "")
@@ -73,8 +79,9 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
new ConsoleFileManager
if (!args.exists(denotesTestSet(_)) &&
- !args.exists(_.endsWith(".scala")) &&
- !args.exists(_.endsWith(".res"))) runAll = true
+ !args.exists(denotesTestFile(_)) &&
+ !args.exists(denotesTestDir(_)))
+ runAll = true
for (arg <- args) {
arg match {
@@ -96,9 +103,9 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
case "--version" => //todo: printVersion
case "--ansi" => NestUI.initialize(NestUI.MANY)
case _ =>
- if (arg.endsWith(".scala") || arg.endsWith(".res")) {
+ if (denotesTestFile(arg) || denotesTestDir(arg)) {
val file = new File(arg)
- if (file.isFile) {
+ if (file.exists) {
NestUI.verbose("adding test file "+file)
testFiles = file :: testFiles
} else {
diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala
index 36e051e221..a780e8050a 100644
--- a/src/partest/scala/tools/partest/nest/FileManager.scala
+++ b/src/partest/scala/tools/partest/nest/FileManager.scala
@@ -12,6 +12,11 @@ import java.net.URI
trait FileManager {
+ def basename(name: String): String = {
+ val inx = name.lastIndexOf(".")
+ if (inx < 0) name else name.substring(0, inx)
+ }
+
def deleteRecursive(dir: File) {
if (dir.isDirectory) {
for (file <- dir.list) deleteRecursive(new File(dir, file))
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 469c56850b..fc422ef33a 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -352,7 +352,7 @@ class Worker(val fileManager: FileManager) extends Actor {
javac(outDir, javaFiles, logFile)
// 2. compile all '.scala' files together
val scalaFiles = testFiles.filter(_.getName.endsWith(".scala"))
- if (!compileMgr.shouldCompile(outDir, scalaFiles, kind, logFile)) {
+ if (!scalaFiles.isEmpty && !compileMgr.shouldCompile(outDir, scalaFiles, kind, logFile)) {
NestUI.verbose("compilation of "+scalaFiles+" failed\n")
succeeded = false
} else