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

Simplify how we find resource dir. in tests

parent 00b0139d
No related branches found
No related tags found
No related merge requests found
......@@ -87,9 +87,10 @@ script := {
sourceGenerators in Compile <+= Def.task {
val libFiles = ((baseDirectory.value / "library") ** "*.scala").getPaths
val build = (sourceManaged in Compile).value / "leon" / "Build.scala";
IO.write(build, s"""|package leon;
IO.write(build, s"""|package leon
|
|object Build {
| val baseDirectory = \"${baseDirectory.value.toString}\"
| val libFiles = List(
| ${libFiles.mkString("\"\"\"", "\"\"\",\n \"\"\"", "\"\"\"")}
| )
......
......@@ -19,8 +19,6 @@ class TestCasesCompile extends LeonRegressionSuite {
val baseDir = "regression/testcases/"
val slashes = resourceDir(baseDir).getAbsolutePath.split("/").toList.size
val allTests = (filesIn(baseDir+"repair/") ++
filesIn(baseDir+"runtime/") ++
filesIn(baseDir+"synthesis/") ++
......@@ -28,7 +26,11 @@ class TestCasesCompile extends LeonRegressionSuite {
filesIn(baseDir+"web/")).sortBy(_.getAbsolutePath)
allTests.foreach { f =>
val name = f.getAbsolutePath.split("/").toList.drop(slashes).mkString("/")
val path = f.getAbsolutePath
val index = path.indexOf(baseDir)
val name = path.drop(index)
test("Compiling "+name) {
......
......@@ -5,7 +5,6 @@ package leon.test
import leon._
import leon.utils._
import scala.io.Source
import org.scalatest._
import org.scalatest.time.Span
import org.scalatest.concurrent._
......@@ -15,8 +14,8 @@ import org.scalatest.exceptions.TestFailedException
import java.io.File
trait LeonRegressionSuite extends FunSuite with Timeouts with BeforeAndAfterEach {
// Hard-code resource directory, for Eclipse purposes
val resourceDirHard = "src/test/resources/"
val regressionTestDirectory = "src/test/resources"
def createLeonContext(opts: String*): LeonContext = {
val reporter = new TestSilentReporter
......@@ -66,23 +65,6 @@ trait LeonRegressionSuite extends FunSuite with Timeouts with BeforeAndAfterEach
}
protected val all : String=>Boolean = (s : String) => true
def resourceDir(dir : String) : File = {
val d = this.getClass.getClassLoader.getResource(dir)
if(d == null || d.getProtocol != "file") {
// We are in Eclipse. The only way we are saved is by hard-coding the path
new File(resourceDirHard + dir)
}
else {
new File(d.toURI)
}
}
def scanFilesIn(f: File, filter: String=>Boolean = all, recursive: Boolean = false): Iterable[File] = {
Option(f.listFiles()).getOrElse(Array()).flatMap{f =>
......@@ -96,13 +78,8 @@ trait LeonRegressionSuite extends FunSuite with Timeouts with BeforeAndAfterEach
def filesInResourceDir(dir : String, filter : String=>Boolean = all, recursive: Boolean = false) : Iterable[File] = {
val d = this.getClass.getClassLoader.getResource(dir)
val asFile = if(d == null || d.getProtocol != "file") {
// We are in Eclipse. The only way we are saved is by hard-coding the path
new File(resourceDirHard + dir)
} else new File(d.toURI)
val baseDir = new File(s"${Build.baseDirectory}/$regressionTestDirectory/$dir")
scanFilesIn(asFile, filter, recursive)
scanFilesIn(baseDir, filter, recursive)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment