summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-10-08 14:42:45 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-10-08 14:42:45 +0000
commit4af97e33e7f60e61df1483af3605050a3af5dfb6 (patch)
treeb760c9211fcbce08c043f4e5677d57379699db65 /src/partest
parent41d7f547c03f2226748a3f9683a4e50084933776 (diff)
downloadscala-4af97e33e7f60e61df1483af3605050a3af5dfb6.tar.gz
scala-4af97e33e7f60e61df1483af3605050a3af5dfb6.tar.bz2
scala-4af97e33e7f60e61df1483af3605050a3af5dfb6.zip
Added more complete output if tests fail.
Log file is printed now right away if: - test fails due to an exception thrown in the a test - test fails due to a ScalaCheck test fail - test fails due to compiler errors in ScalaCheck tests Review by extempore.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 6631d476a8..637e5160ee 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -310,6 +310,13 @@ class Worker(val fileManager: FileManager, scalaCheckParentClassLoader: ScalaCla
def isScala(f: File) = SFile(f) hasExtension "scala"
def isJavaOrScala(f: File) = isJava(f) || isScala(f)
+ def outputLogFile(logFile: File) {
+ NestUI.normal("Log file '" + logFile + "': \n")
+ val lines = SFile(logFile).lines
+ for (lin <- lines) NestUI.normal(lin + "\n")
+ }
+
+
/** Runs a list of tests.
*
* @param kind The test kind (pos, neg, run, etc.)
@@ -375,6 +382,7 @@ class Worker(val fileManager: FileManager, scalaCheckParentClassLoader: ScalaCla
val writer = new PrintWriter(new FileWriter(logFile), true)
e.printStackTrace(writer)
writer.close()
+ outputLogFile(logFile) // if running the test threw an exception, output log file
succeeded = false
}
@@ -421,7 +429,7 @@ class Worker(val fileManager: FileManager, scalaCheckParentClassLoader: ScalaCla
}
}
- def runTestCommon(file: File, kind: String, expectFailure: Boolean)(onSuccess: (File, File) => Unit): LogContext =
+ def runTestCommon(file: File, kind: String, expectFailure: Boolean)(onSuccess: (File, File) => Unit, onFail: (File, File) => Unit = (logf, outd) => ()): LogContext =
runInContext(file, kind, (logFile: File, outDir: File) => {
if (file.isDirectory) {
@@ -439,6 +447,8 @@ class Worker(val fileManager: FileManager, scalaCheckParentClassLoader: ScalaCla
if (succeeded) // run test
onSuccess(logFile, outDir)
+ else
+ onFail(logFile, outDir)
})
def runJvmTest(file: File, kind: String): LogContext =
@@ -477,14 +487,18 @@ class Worker(val fileManager: FileManager, scalaCheckParentClassLoader: ScalaCla
NestUI.verbose(SFile(logFile).slurp())
// obviously this must be improved upon
+ val lines = SFile(logFile).lines.filter(_.trim != "").toBuffer
succeeded = {
- val lines = SFile(logFile).lines.filter(_.trim != "").toBuffer
val failures = lines filter (_ startsWith "!")
val passedok = lines filter (_ startsWith "+") forall (_ contains "OK")
failures.isEmpty && passedok
}
+ if (!succeeded) {
+ NestUI.normal("ScalaCheck test failed. Output:\n")
+ for (lin <- lines) NestUI.normal(lin + "\n")
+ }
NestUI.verbose("test for '" + file + "' success: " + succeeded)
- })
+ }, (logFile, outDir) => outputLogFile(logFile))
case "pos" =>
runTestCommon(file, kind, expectFailure = false)((_, _) => ())