summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2008-09-02 16:30:12 +0000
committerPhilipp Haller <hallerp@gmail.com>2008-09-02 16:30:12 +0000
commitfb882601b725bc7c632ee910687ed63b52028204 (patch)
tree99f32bb452922b7bb79b517278beb3a950ea0b2b /src/partest
parentc49538d2041fe7ff68b8ff56e1b2cb0559a1e83f (diff)
downloadscala-fb882601b725bc7c632ee910687ed63b52028204.tar.gz
scala-fb882601b725bc7c632ee910687ed63b52028204.tar.bz2
scala-fb882601b725bc7c632ee910687ed63b52028204.zip
Adds support for .flags file containing scalac ...
Adds support for .flags file containing scalac options. Supports running individual test dirs. Handles empty test dirs properly.
Diffstat (limited to 'src/partest')
-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