Skip to content

Commit 3321209

Browse files
authored
Run tests without optimization (#851)
Closes #846 This runs every test without optimization *in addition* to running them with optimization. While this is good for testing, we should change this once it's mergable so our CI doesn't take ~~twice as long~~ much longer. There are many new errors now. I've spent some time investigating and they generally fall into these two categories: - no block info (unsoundness in the optimizer) - unsupported LLVM feature (toplevel object definitions, reached hole (no LLVM FFI for extern definition)), which were somehow optimized away - valgrind error
1 parent 12fc073 commit 3321209

File tree

4 files changed

+81
-5
lines changed

4 files changed

+81
-5
lines changed

effekt/jvm/src/test/scala/effekt/EffektTests.scala

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ trait EffektTests extends munit.FunSuite {
3636

3737
def negatives: List[File] = List()
3838

39+
// Test files that should be run with optimizations disabled
40+
def withoutOptimizations: List[File] = List()
41+
3942
def runTestFor(input: File, expected: String): Unit =
4043
test(input.getPath + s" (${backendName})") {
41-
assertNoDiff(run(input), expected)
44+
assertNoDiff(run(input, true), expected)
4245
}
4346

4447
// one shared driver for all tests in this test runner
@@ -59,7 +62,7 @@ trait EffektTests extends munit.FunSuite {
5962
compiler.compileFile(input.getPath, configs)
6063
compiler.context.backup
6164

62-
def run(input: File): String =
65+
def run(input: File, optimizations: Boolean): String =
6366
val compiler = driver
6467
var options = Seq(
6568
"--Koutput", "string",
@@ -68,6 +71,7 @@ trait EffektTests extends munit.FunSuite {
6871
)
6972
if (valgrind) options = options :+ "--valgrind"
7073
if (debug) options = options :+ "--debug"
74+
if (!optimizations) options = options :+ "--no-optimize"
7175
val configs = compiler.createConfig(options)
7276
configs.verify()
7377

@@ -96,22 +100,32 @@ trait EffektTests extends munit.FunSuite {
96100
case Right(value) =>
97101
negatives.foreach(runNegativeTestsIn)
98102
positives.foreach(runPositiveTestsIn)
103+
withoutOptimizations.foreach(runWithoutOptimizations)
104+
}
105+
106+
def runWithoutOptimizations(dir: File): Unit =
107+
foreachFileIn(dir) {
108+
case (f, None) => sys error s"Missing checkfile for ${f.getPath}"
109+
case (f, Some(expected)) =>
110+
test(s"${f.getPath} (${backendName})") {
111+
assertNoDiff(run(f, false), expected)
112+
}
99113
}
100114

101115
def runPositiveTestsIn(dir: File): Unit =
102116
foreachFileIn(dir) {
103117
case (f, None) => sys error s"Missing checkfile for ${f.getPath}"
104118
case (f, Some(expected)) =>
105119
test(s"${f.getPath} (${backendName})") {
106-
assertNoDiff(run(f), expected)
120+
assertNoDiff(run(f, true), expected)
107121
}
108122
}
109123

110124
def runNegativeTestsIn(dir: File): Unit =
111125
foreachFileIn(dir) {
112126
case (f, Some(expected)) =>
113127
test(s"${f.getPath} (${backendName})") {
114-
assertNoDiff(run(f), expected)
128+
assertNoDiff(run(f, true), expected)
115129
}
116130

117131
case (f, None) =>

effekt/jvm/src/test/scala/effekt/JavaScriptTests.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ class JavaScriptTests extends EffektTests {
2424
examplesDir / "neg"
2525
)
2626

27+
override lazy val withoutOptimizations: List[File] = List(
28+
// contifying under reset
29+
//examplesDir / "pos" / "issue842.effekt",
30+
//examplesDir / "pos" / "issue861.effekt",
31+
32+
// syntax error (multiple declaration)
33+
//examplesDir / "char" / "ascii_isalphanumeric.effekt",
34+
//examplesDir / "char" / "ascii_iswhitespace.effekt",
35+
//examplesDir / "pos" / "parser.effekt",
36+
//examplesDir / "pos" / "probabilistic.effekt",
37+
)
38+
2739
override def ignored: List[File] = List(
2840
// unsafe cont
2941
examplesDir / "pos" / "propagators.effekt"
@@ -58,7 +70,7 @@ object TestUtils {
5870
val shouldGenerate = regenerateAll || f.lastModified() > checkfile.lastModified()
5971
if (!isIgnored && shouldGenerate) {
6072
println(s"Writing checkfile for ${f}")
61-
val out = run(f)
73+
val out = run(f, true)
6274

6375
// Save checkfile in source folder (e.g. examples/)
6476
// We remove ansi colors to make check files human-readable.

effekt/jvm/src/test/scala/effekt/LLVMTests.scala

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,32 @@ class LLVMTests extends EffektTests {
5353
examplesDir / "pos" / "issue733.effekt",
5454
)
5555

56+
override lazy val withoutOptimizations: List[File] = List(
57+
// contifying under reset
58+
//examplesDir / "pos" / "issue842.effekt",
59+
//examplesDir / "pos" / "issue861.effekt",
60+
61+
// top-level object definition
62+
//examplesDir / "pos" / "object" / "if_control_effect.effekt",
63+
//examplesDir / "pos" / "lambdas" / "toplevel_objects.effekt",
64+
//examplesDir / "pos" / "type_omission_op.effekt",
65+
//examplesDir / "pos" / "bidirectional" / "higherorderobject.effekt",
66+
//examplesDir / "pos" / "bidirectional" / "res_obj_boxed.effekt",
67+
//examplesDir / "pos" / "bidirectional" / "effectfulobject.effekt",
68+
69+
// no block info
70+
//examplesDir / "pos" / "capture" / "regions.effekt",
71+
//examplesDir / "pos" / "capture" / "selfregion.effekt",
72+
//examplesDir / "benchmarks" / "other" / "generator.effekt",
73+
74+
// hole
75+
//examplesDir / "pos" / "bidirectional" / "typeparametric.effekt",
76+
77+
// segfault
78+
//examplesDir / "benchmarks" / "are_we_fast_yet" / "permute.effekt",
79+
//examplesDir / "benchmarks" / "are_we_fast_yet" / "storage.effekt",
80+
)
81+
5682
override lazy val ignored: List[File] = missingFeatures ++ noValgrind(examplesDir)
5783
}
5884

effekt/jvm/src/test/scala/effekt/StdlibTests.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,33 @@ abstract class StdlibTests extends EffektTests {
1212
)
1313

1414
override def ignored: List[File] = List()
15+
16+
override def withoutOptimizations: List[File] = List()
1517
}
1618

1719
class StdlibJavaScriptTests extends StdlibTests {
1820
def backendName: String = "js"
1921

22+
override def withoutOptimizations: List[File] = List(
23+
examplesDir / "stdlib" / "acme.effekt",
24+
25+
//examplesDir / "stdlib" / "json.effekt",
26+
//examplesDir / "stdlib" / "exception" / "combinators.effekt",
27+
28+
// reference error (k is not defined)
29+
//examplesDir / "stdlib" / "stream" / "fibonacci.effekt",
30+
//examplesDir / "stdlib" / "list" / "flatmap.effekt",
31+
//examplesDir / "stdlib" / "list" / "sortBy.effekt",
32+
//examplesDir / "stdlib" / "stream" / "zip.effekt",
33+
//examplesDir / "stdlib" / "stream" / "characters.effekt",
34+
35+
// oom
36+
//examplesDir / "stdlib" / "list" / "deleteat.effekt",
37+
)
38+
2039
override def ignored: List[File] = List()
2140
}
41+
2242
abstract class StdlibChezTests extends StdlibTests {
2343
override def ignored: List[File] = List(
2444
// Not implemented yet
@@ -39,6 +59,10 @@ class StdlibLLVMTests extends StdlibTests {
3959
override def valgrind = sys.env.get("EFFEKT_VALGRIND").nonEmpty
4060
override def debug = sys.env.get("EFFEKT_DEBUG").nonEmpty
4161

62+
override def withoutOptimizations: List[File] = List(
63+
examplesDir / "stdlib" / "acme.effekt",
64+
)
65+
4266
override def ignored: List[File] = List(
4367
// String comparison using `<`, `<=`, `>`, `>=` is not implemented yet on LLVM
4468
examplesDir / "stdlib" / "string" / "compare.effekt",

0 commit comments

Comments
 (0)