aboutsummaryrefslogtreecommitdiff
path: root/test/dotty
diff options
context:
space:
mode:
authorvsalvis <salvisbergvera@gmail.com>2015-05-19 14:51:19 +0200
committervsalvis <salvisbergvera@gmail.com>2015-05-22 11:12:44 +0200
commited31c2a82d6b59ef092e17bd8811278f5ffd15e9 (patch)
tree4363a13773e73e46be66d486c3e0893875a17473 /test/dotty
parent12f7dcba50671361f3de04d3a23b049f74a79280 (diff)
downloaddotty-ed31c2a82d6b59ef092e17bd8811278f5ffd15e9.tar.gz
dotty-ed31c2a82d6b59ef092e17bd8811278f5ffd15e9.tar.bz2
dotty-ed31c2a82d6b59ef092e17bd8811278f5ffd15e9.zip
Less verbose partest with compiler output redirected, better --verbose output
Diffstat (limited to 'test/dotty')
-rw-r--r--test/dotty/partest/DPConfig.scala4
-rw-r--r--test/dotty/partest/DPConsoleRunner.scala62
2 files changed, 35 insertions, 31 deletions
diff --git a/test/dotty/partest/DPConfig.scala b/test/dotty/partest/DPConfig.scala
index c744a9562..ad9c271ef 100644
--- a/test/dotty/partest/DPConfig.scala
+++ b/test/dotty/partest/DPConfig.scala
@@ -18,9 +18,7 @@ object DPConfig {
lazy val testDirs = {
val root = new File(testRoot)
val dirs = if (!root.exists) Array.empty[String] else root.listFiles.filter(_.isDirectory).map(_.getName)
- if (dirs.length > 0)
- println(s"Partest found generated source directories in $testRoot: " + dirs.mkString(", "))
- else
+ if (dirs.isEmpty)
throw new Exception("Partest did not detect any generated sources")
dirs
}
diff --git a/test/dotty/partest/DPConsoleRunner.scala b/test/dotty/partest/DPConsoleRunner.scala
index 1f3eaa39d..b0d05f4bf 100644
--- a/test/dotty/partest/DPConsoleRunner.scala
+++ b/test/dotty/partest/DPConsoleRunner.scala
@@ -9,7 +9,7 @@ import scala.tools.partest._
import scala.tools.partest.nest._
import scala.util.matching.Regex
import tools.nsc.io.{ File => NSCFile }
-import java.io.File
+import java.io.{ File, PrintStream, FileOutputStream }
import java.net.URLClassLoader
/** Runs dotty partest from the Console, discovering test sources in
@@ -25,7 +25,7 @@ object DPConsoleRunner {
val (jarList, otherArgs) = args.toList.partition(jarFinder.findFirstIn(_).isDefined)
val (extraJars, moreArgs) = jarList match {
case Nil => sys.error("Error: DPConsoleRunner needs \"-dottyJars <jarCount> <jars>*\".")
- case jarFinder(nr, jarString) :: Nil =>
+ case jarFinder(nr, jarString) :: Nil =>
val jars = jarString.split(" ").toList
val count = nr.toInt
if (jars.length < count)
@@ -64,7 +64,7 @@ class DPSuiteRunner(testSourcePath: String, // relative path, like "files", or "
failed: Boolean,
javaCmdPath: String = PartestDefaults.javaCmd,
javacCmdPath: String = PartestDefaults.javacCmd,
- scalacExtraArgs: Seq[String] = Seq.empty)
+ scalacExtraArgs: Seq[String] = Seq.empty)
extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPath, javacCmdPath, scalacExtraArgs) {
if (!DPConfig.runTestsInParallel)
@@ -82,32 +82,38 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat
""".stripMargin
}
- // override to provide DPTestRunner
+ // override for DPTestRunner and redirecting compilation output to test.clog
override def runTest(testFile: File): TestState = {
val runner = new DPTestRunner(testFile, this)
- // when option "--failed" is provided execute test only if log
- // is present (which means it failed before)
val state =
- if (failed && !runner.logFile.canRead)
- runner.genPass()
- else {
- val (state, _) =
- try timed(runner.run())
- catch {
- case t: Throwable => throw new RuntimeException(s"Error running $testFile", t)
- }
- NestUI.reportTest(state)
- runner.cleanup()
- state
+ try {
+ // IO redirection is messy, there are no concurrency guarantees.
+ // Parts of test output might end up in the wrong file or get lost.
+ Console.out.flush
+ Console.err.flush
+ val clog = SFile(runner.logFile).changeExtension("clog")
+ val stream = new PrintStream(new FileOutputStream(clog.jfile), true)
+ val result = Console.withOut(stream)({ Console.withErr(stream)({
+ runner.run()
+ Console.err.flush
+ Console.out.flush
+ })})
+ result match {
+ // Append compiler output to transcript if compilation failed,
+ // printed with --verbose option
+ case TestState.Fail(f, r@"compilation failed", transcript) =>
+ TestState.Fail(f, r, transcript ++ clog.fileLines.dropWhile(_ == ""))
+ case res => res
+ }
+ } catch {
+ case t: Throwable => throw new RuntimeException(s"Error running $testFile", t)
}
+ NestUI.reportTest(state)
+ runner.cleanup()
+
onFinishTest(testFile, state)
}
-
- // override val fileManager = new DottyFileManager(testClassLoader)
- // sbt package generates a dotty compiler jar, currently
- // ".../git/dotty/target/scala-2.11/dotty_2.11-0.1-SNAPSHOT.jar"
- // but it doesn't seem to be used anywhere
}
class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runner(testFile, suiteRunner) {
@@ -146,7 +152,7 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
def nerrIsOk(reason: String) = {
val nerrFinder = """compilation failed with (\d+) errors""".r
reason match {
- case nerrFinder(found) =>
+ case nerrFinder(found) =>
SFile(FileOps(testFile) changeExtension "nerr").safeSlurp match {
case Some(exp) if (exp != found) => CompFailedButWrongNErr(exp, found)
case _ => CompFailed
@@ -154,10 +160,10 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
case _ => CompFailed
}
}
-
+
// we keep the partest semantics where only one round needs to fail
// compilation, not all
- val compFailingRounds = compilationRounds(testFile).map({round =>
+ val compFailingRounds = compilationRounds(testFile).map({round =>
val ok = round.isOk
setLastState(if (ok) genPass else genFail("compilation failed"))
(round.result, ok)
@@ -173,14 +179,14 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
if (failureStates.exists({ case CompFailed => true; case _ => false })) {
true
} else {
- val existsNerr = failureStates.exists({
+ val existsNerr = failureStates.exists({
case CompFailedButWrongNErr(exp, found) => nextTestActionFailing(s"wrong number of compilation errors, expected: $exp, found: $found"); true
case _ => false
})
if (existsNerr) {
- false
+ false
} else {
- val existsDiff = failureStates.exists({
+ val existsDiff = failureStates.exists({
case CompFailedButWrongDiff() => nextTestActionFailing(s"output differs"); true
case _ => false
})