Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run no-valgrind tests, except those that segfault #757

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions effekt/jvm/src/test/scala/effekt/EffektTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ trait EffektTests extends munit.FunSuite {

def negatives: List[File] = List()

def runTestFor(input: File, expected: String): Unit =
test(input.getPath + s" (${backendName})") {
assertNoDiff(run(input), expected)
}

// one shared driver for all tests in this test runner
object driver extends effekt.Driver

Expand All @@ -59,7 +54,7 @@ trait EffektTests extends munit.FunSuite {
compiler.compileFile(input.getPath, configs)
compiler.context.backup

def run(input: File): String =
def run(input: File, valgrind: Boolean, debug: Boolean): String =
val compiler = driver
var options = Seq(
"--Koutput", "string",
Expand Down Expand Up @@ -90,28 +85,28 @@ trait EffektTests extends munit.FunSuite {
compiler.messaging.get.toList


def runTests() =
def runTests(valgrind: Boolean, debug: Boolean, ignored: List[File]) =
Backend.backend(backendName).runner.checkSetup() match {
case Left(msg) => test(s"${this.getClass.getName}: ${msg}".ignore) { () }
case Right(value) =>
negatives.foreach(runNegativeTestsIn)
positives.foreach(runPositiveTestsIn)
negatives.foreach(runNegativeTestsIn(valgrind, debug, ignored))
positives.foreach(runPositiveTestsIn(valgrind, debug, ignored))
}

def runPositiveTestsIn(dir: File): Unit =
foreachFileIn(dir) {
def runPositiveTestsIn(valgrind: Boolean, debug: Boolean, ignored: List[File])(dir: File): Unit =
foreachFileIn(dir, ignored) {
case (f, None) => sys error s"Missing checkfile for ${f.getPath}"
case (f, Some(expected)) =>
test(s"${f.getPath} (${backendName})") {
assertNoDiff(run(f), expected)
assertNoDiff(run(f, valgrind, debug), expected)
}
}

def runNegativeTestsIn(dir: File): Unit =
foreachFileIn(dir) {
def runNegativeTestsIn(valgrind: Boolean, debug: Boolean, ignored: List[File])(dir: File): Unit =
foreachFileIn(dir, ignored) {
case (f, Some(expected)) =>
test(s"${f.getPath} (${backendName})") {
assertNoDiff(run(f), expected)
assertNoDiff(run(f, valgrind, debug), expected)
}

case (f, None) =>
Expand Down Expand Up @@ -158,24 +153,23 @@ trait EffektTests extends munit.FunSuite {

assert(messages.nonEmpty)

def foreachFileIn(file: File)(test: (File, Option[String]) => Unit): Unit =
def expectedResultFor(f: File): Option[String] = {
val path = f.getParentFile
val baseName = f.getName.stripSuffix(".md").stripSuffix(".effekt")
val checkfile = path / (baseName + ".check")
if checkfile.exists() then Some(IO.read(checkfile)) else None
}

def foreachFileIn(file: File, ignored: List[File])(test: (File, Option[String]) => Unit): Unit =
file match {
case f if f.isDirectory && !ignored.contains(f) =>
f.listFiles.foreach(foreachFileIn(_)(test))
f.listFiles.foreach(f => foreachFileIn(f, ignored)(test))
case f if f.getName.endsWith(".effekt") || f.getName.endsWith(".effekt.md") =>
val path = f.getParentFile
val baseName = f.getName.stripSuffix(".md").stripSuffix(".effekt")

if (ignored.contains(f)) {
ignored.contains(f)
} else {
val checkfile = path / (baseName + ".check")
val expected = if checkfile.exists() then Some(IO.read(checkfile)) else None

test(f, expected)
if (!ignored.contains(f)) {
test(f, expectedResultFor(f))
}
case _ => ()
}

runTests()
runTests(valgrind, debug, ignored)
}
2 changes: 1 addition & 1 deletion effekt/jvm/src/test/scala/effekt/JavaScriptTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object TestUtils {
val shouldGenerate = regenerateAll || f.lastModified() > checkfile.lastModified()
if (!isIgnored && shouldGenerate) {
println(s"Writing checkfile for ${f}")
val out = run(f)
val out = run(f, valgrind, debug)

// Save checkfile in source folder (e.g. examples/)
// We remove ansi colors to make check files human-readable.
Expand Down
17 changes: 12 additions & 5 deletions effekt/jvm/src/test/scala/effekt/LLVMTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ class LLVMTests extends EffektTests {
// names not sanitized (even?)
examplesDir / "pos" / "special_names.effekt",

// segfault
examplesDir / "benchmarks" / "input_output" / "word_count_ascii.effekt",
examplesDir / "benchmarks" / "input_output" / "word_count_utf8.effekt",
examplesDir / "benchmarks" / "input_output" / "dyck_one.effekt",
examplesDir / "benchmarks" / "input_output" / "number_matrix.effekt",
)

lazy val noValgrind: List[File] = List(
// sanitizer/valgrind: segfault
examplesDir / "pos" / "parametrized.effekt",

Expand All @@ -37,10 +45,6 @@ class LLVMTests extends EffektTests {
examplesDir / "benchmarks" / "are_we_fast_yet" / "towers.effekt",
examplesDir / "benchmarks" / "are_we_fast_yet" / "permute.effekt",
examplesDir / "benchmarks" / "are_we_fast_yet" / "queens.effekt",
examplesDir / "benchmarks" / "input_output" / "word_count_ascii.effekt",
examplesDir / "benchmarks" / "input_output" / "word_count_utf8.effekt",
examplesDir / "benchmarks" / "input_output" / "dyck_one.effekt",
examplesDir / "benchmarks" / "input_output" / "number_matrix.effekt",
)

/**
Expand Down Expand Up @@ -101,5 +105,8 @@ class LLVMTests extends EffektTests {
examplesDir / "pos" / "issue733.effekt",
)

override lazy val ignored: List[File] = bugs ++ missingFeatures
override lazy val ignored: List[File] = bugs ++ missingFeatures ++ noValgrind

// Also run the no-valgrind tests with valgrind disabled.
noValgrind.foreach(runPositiveTestsIn(valgrind = false, debug = debug, ignored = Nil))
}
Loading