Skip to content
Snippets Groups Projects
Commit f5895876 authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Fail tests with better errors

parent 74a62d6e
No related branches found
No related tags found
No related merge requests found
...@@ -39,8 +39,8 @@ class TestCasesCompile extends LeonRegressionSuite { ...@@ -39,8 +39,8 @@ class TestCasesCompile extends LeonRegressionSuite {
try { try {
pipeline.run(ctx, List(f.getAbsolutePath)) pipeline.run(ctx, List(f.getAbsolutePath))
} catch { } catch {
case _: LeonFatalError => case fe: LeonFatalError =>
fail(" Failed to compile "+name) fail(ctx, s"Failed to compile $name", fe)
} }
} }
} }
......
...@@ -66,16 +66,10 @@ trait VerificationSuite extends LeonRegressionSuite { ...@@ -66,16 +66,10 @@ trait VerificationSuite extends LeonRegressionSuite {
} }
} }
} catch { } catch {
case _: LeonFatalError => case fe: LeonFatalError =>
ctx.reporter match { test("Compilation") {
case sr: TestSilentReporter => fail(ctx, "Unexpected fatal error while setting up tests", fe)
println("Unexpected fatal error:")
for (e <- sr.lastErrors) {
println(" "+e)
}
case _ =>
} }
test("Compilation of test files in " + testDir + cat)(fail("Failed to compile"))
} }
} }
......
...@@ -39,7 +39,7 @@ trait LeonRegressionSuite extends FunSuite with Timeouts { ...@@ -39,7 +39,7 @@ trait LeonRegressionSuite extends FunSuite with Timeouts {
} }
protected val all : String=>Boolean = (s : String) => true protected val all : String=>Boolean = (s : String) => true
def scanFilesIn(f: File, filter: String=>Boolean = all, recursive: Boolean = false): Iterable[File] = { def scanFilesIn(f: File, filter: String=>Boolean = all, recursive: Boolean = false): Iterable[File] = {
Option(f.listFiles()).getOrElse(Array()).flatMap{f => Option(f.listFiles()).getOrElse(Array()).flatMap{f =>
if (f.isDirectory && recursive) { if (f.isDirectory && recursive) {
...@@ -56,4 +56,21 @@ trait LeonRegressionSuite extends FunSuite with Timeouts { ...@@ -56,4 +56,21 @@ trait LeonRegressionSuite extends FunSuite with Timeouts {
scanFilesIn(baseDir, filter, recursive) scanFilesIn(baseDir, filter, recursive)
} }
protected def fail(ctx: LeonContext, reason: String, fe: LeonFatalError): Nothing = {
val omsg = ctx.reporter match {
case sr: TestSilentReporter =>
sr.lastErrors ++= fe.msg
Some((sr.lastErrors ++ fe.msg).mkString("\n"))
case _ =>
fe.msg
}
val fullError = omsg match {
case Some(msg) => s"$reason:\n$msg"
case None => s"$reason"
}
throw new TestFailedException(fullError, fe, 5)
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment