Skip to content
Snippets Groups Projects
Commit 74a62d6e authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

Simplify tests

parent 2163b315
No related branches found
No related tags found
No related merge requests found
...@@ -82,9 +82,9 @@ class SynthesisSuite extends LeonRegressionSuite { ...@@ -82,9 +82,9 @@ class SynthesisSuite extends LeonRegressionSuite {
} }
def forProgram(title: String, opts: Seq[LeonOption[Any]] = Nil)(content: String)(strats: PartialFunction[String, SynStrat]) { def forProgram(title: String, opts: Seq[String] = Nil)(content: String)(strats: PartialFunction[String, SynStrat]) {
test(f"Synthesizing ${nextInt()}%3d: [$title]") { test(f"Synthesizing ${nextInt()}%3d: [$title]") {
val ctx = testContext.copy(options = opts ++ testContext.options) val ctx = createLeonContext(opts: _*)
val pipeline = leon.utils.TemporaryInputPhase andThen val pipeline = leon.utils.TemporaryInputPhase andThen
leon.frontends.scalac.ExtractionPhase andThen leon.frontends.scalac.ExtractionPhase andThen
...@@ -118,7 +118,7 @@ class SynthesisSuite extends LeonRegressionSuite { ...@@ -118,7 +118,7 @@ class SynthesisSuite extends LeonRegressionSuite {
} }
} }
forProgram("Ground Enum", Seq(LeonOption(SharedOptions.optSelectedSolvers)(Set("enum"))))( forProgram("Ground Enum", Seq("--solvers=enum"))(
""" """
import leon.annotation._ import leon.annotation._
import leon.lang._ import leon.lang._
......
...@@ -22,7 +22,7 @@ class TerminationSuite extends LeonRegressionSuite { ...@@ -22,7 +22,7 @@ class TerminationSuite extends LeonRegressionSuite {
new leon.utils.PreprocessingPhase andThen new leon.utils.PreprocessingPhase andThen
leon.termination.TerminationPhase leon.termination.TerminationPhase
private def mkTest(file : File, leonOptions: Seq[LeonOption[Any]], forError: Boolean)(block: Output=>Unit) = { private def mkTest(file : File, leonOptions: Seq[String], forError: Boolean)(block: Output=>Unit) = {
val fullName = file.getPath val fullName = file.getPath
val start = fullName.indexOf("regression") val start = fullName.indexOf("regression")
...@@ -38,7 +38,7 @@ class TerminationSuite extends LeonRegressionSuite { ...@@ -38,7 +38,7 @@ class TerminationSuite extends LeonRegressionSuite {
"verification/purescala/valid/InductiveQuantification.scala" "verification/purescala/valid/InductiveQuantification.scala"
) )
val t = if (ignored.exists(displayName endsWith _)) { val t = if (ignored.exists(displayName.endsWith)) {
ignore _ ignore _
} else { } else {
test _ test _
...@@ -48,10 +48,7 @@ class TerminationSuite extends LeonRegressionSuite { ...@@ -48,10 +48,7 @@ class TerminationSuite extends LeonRegressionSuite {
assert(file.exists && file.isFile && file.canRead, assert(file.exists && file.isFile && file.canRead,
s"Benchmark $displayName is not a readable file") s"Benchmark $displayName is not a readable file")
val ctx = testContext.copy( val ctx = createLeonContext((leonOptions ++ List(file.getAbsolutePath)): _* )
options = leonOptions,
files = List(file)
)
val pipeline = mkPipeline val pipeline = mkPipeline
......
...@@ -6,14 +6,12 @@ import leon._ ...@@ -6,14 +6,12 @@ import leon._
import leon.utils._ import leon.utils._
import org.scalatest._ import org.scalatest._
import org.scalatest.time.Span
import org.scalatest.concurrent._ import org.scalatest.concurrent._
import org.scalatest.time.SpanSugar._
import org.scalatest.exceptions.TestFailedException import org.scalatest.exceptions.TestFailedException
import java.io.File import java.io.File
trait LeonRegressionSuite extends FunSuite with Timeouts with BeforeAndAfterEach { trait LeonRegressionSuite extends FunSuite with Timeouts {
val regressionTestDirectory = "src/test/resources" val regressionTestDirectory = "src/test/resources"
...@@ -23,47 +21,23 @@ trait LeonRegressionSuite extends FunSuite with Timeouts with BeforeAndAfterEach ...@@ -23,47 +21,23 @@ trait LeonRegressionSuite extends FunSuite with Timeouts with BeforeAndAfterEach
Main.processOptions(opts.toList).copy(reporter = reporter, interruptManager = new InterruptManager(reporter)) Main.processOptions(opts.toList).copy(reporter = reporter, interruptManager = new InterruptManager(reporter))
} }
var testContext: LeonContext = null
override def beforeEach() = {
testContext = createLeonContext()
super.beforeEach()
}
def testIdentifier(name: String): String = { def testIdentifier(name: String): String = {
def sanitize(s: String) = s.replaceAll("[^0-9a-zA-Z-]", "") def sanitize(s: String) = s.replaceAll("[^0-9a-zA-Z-]", "")
sanitize(this.getClass.getName)+"/"+sanitize(name) sanitize(this.getClass.getName)+"/"+sanitize(name)
} }
override implicit val defaultInterruptor = new Interruptor { override def test(name: String, tags: Tag*)(body: => Unit) {
def apply(t: Thread) {
testContext.interruptManager.interrupt()
}
}
def testWithTimeout(name: String, timeout: Span)(body: => Unit) {
super.test(name) { super.test(name) {
failAfter(timeout) { try {
try { body
body } catch {
} catch { case fe: LeonFatalError =>
case fe: LeonFatalError => throw new TestFailedException("", fe, 5)
testContext.reporter match {
case sr: TestSilentReporter =>
sr.lastErrors ++= fe.msg
throw new TestFailedException(sr.lastErrors.mkString("\n"), fe, 5)
}
}
} }
} }
} }
override def test(name: String, tags: Tag*)(body: => Unit) {
testWithTimeout(name, 5.minutes)(body)
}
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] = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment