test: integration tests for imports
This commit is contained in:
@@ -26,6 +26,15 @@ class ParallelExamplesSpec extends AsyncFreeSpec with AsyncIOSpec with BeforeAnd
|
||||
} ++
|
||||
allWaccFiles("wacc-examples/invalid/whack").map { p =>
|
||||
(p.toString, List(100, 200))
|
||||
} ++
|
||||
allWaccFiles("extension/examples/valid").map { p =>
|
||||
(p.toString, List(0))
|
||||
} ++
|
||||
allWaccFiles("extension/examples/invalid/syntax").map { p =>
|
||||
(p.toString, List(100))
|
||||
} ++
|
||||
allWaccFiles("extension/examples/invalid/semantics").map { p =>
|
||||
(p.toString, List(200))
|
||||
}
|
||||
|
||||
forEvery(files) { (filename, expectedResult) =>
|
||||
@@ -33,18 +42,21 @@ class ParallelExamplesSpec extends AsyncFreeSpec with AsyncIOSpec with BeforeAnd
|
||||
|
||||
s"$filename" - {
|
||||
"should be compiled with correct result" in {
|
||||
compileWacc(Path.of(filename), outputDir = None, log = false).map { result =>
|
||||
expectedResult should contain(result)
|
||||
}
|
||||
if (fileIsPendingFrontend(filename))
|
||||
IO.pure(pending)
|
||||
else
|
||||
compileWacc(Path.of(filename), outputDir = None, log = false).map { result =>
|
||||
expectedResult should contain(result)
|
||||
}
|
||||
}
|
||||
|
||||
if (expectedResult == List(0)) {
|
||||
"should run with correct result" in {
|
||||
if (fileIsDisallowedBackend(filename))
|
||||
IO.pure(
|
||||
succeed
|
||||
) // TODO: remove when advanced tests removed. not sure how to "pending" this otherwise
|
||||
else {
|
||||
IO.pure(succeed)
|
||||
else if (fileIsPendingBackend(filename))
|
||||
IO.pure(pending)
|
||||
else
|
||||
for {
|
||||
contents <- IO(Source.fromFile(File(filename)).getLines.toList)
|
||||
inputLine = extractInput(contents)
|
||||
@@ -75,7 +87,6 @@ class ParallelExamplesSpec extends AsyncFreeSpec with AsyncIOSpec with BeforeAnd
|
||||
exitCode shouldBe expectedExit
|
||||
normalizeOutput(stdout.toString) shouldBe expectedOutput
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,10 +96,21 @@ class ParallelExamplesSpec extends AsyncFreeSpec with AsyncIOSpec with BeforeAnd
|
||||
val d = java.io.File(dir)
|
||||
os.walk(os.Path(d.getAbsolutePath)).filter(_.ext == "wacc")
|
||||
|
||||
// TODO: eventually remove this I think
|
||||
def fileIsDisallowedBackend(filename: String): Boolean =
|
||||
Seq(
|
||||
"^.*wacc-examples/valid/advanced.*$"
|
||||
private def fileIsDisallowedBackend(filename: String): Boolean =
|
||||
filename.matches("^.*wacc-examples/valid/advanced.*$")
|
||||
|
||||
private def fileIsPendingFrontend(filename: String): Boolean =
|
||||
List(
|
||||
"^.*extension/examples/invalid/syntax/imports/importBadSyntax.*$",
|
||||
"^.*extension/examples/invalid/semantics/imports.*$",
|
||||
"^.*extension/examples/valid/imports.*$"
|
||||
).exists(filename.matches)
|
||||
|
||||
private def fileIsPendingBackend(filename: String): Boolean =
|
||||
List(
|
||||
"^.*extension/examples/invalid/syntax/imports.*$",
|
||||
"^.*extension/examples/invalid/semantics/imports.*$",
|
||||
"^.*extension/examples/valid/imports.*$"
|
||||
).exists(filename.matches)
|
||||
|
||||
private def extractInput(contents: List[String]): String =
|
||||
|
||||
Reference in New Issue
Block a user