Skip to content

Commit 4c407aa

Browse files
Add meta tests for vulpix
This new test checks that the framework rejects incorrect pos/neg and run test. I think addition meta tests should rather be added as part of the unit test infrastructure, given than this is rather heavy to maintain. (Note that sbt-output.check is manually annotated with "SKIP" lines)
1 parent d0a461c commit 4c407aa

File tree

8 files changed

+108
-1
lines changed

8 files changed

+108
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package dotty.tools
2+
package vulpix
3+
4+
import org.junit.Test
5+
import org.junit.experimental.categories.Category
6+
import scala.concurrent.duration._
7+
import dotty.Properties
8+
import TestConfiguration._
9+
10+
/** Meta tests for the Vulpix test suite. This test follows the structure of
11+
* CompilationTests.scala. It is ment to be called from bash to diff with
12+
* output againts an expected result.
13+
*/
14+
@Category(Array(classOf[dotty.VulpixMetaTests]))
15+
class VulpixMetaTests extends ParallelTesting {
16+
def maxDuration = 1.seconds
17+
def numberOfSlaves = 5
18+
def safeMode = Properties.testsSafeMode
19+
def isInteractive = SummaryReport.isInteractive
20+
def testFilter = Properties.testsFilter
21+
implicit val summaryReport: SummaryReporting = new SummaryReport
22+
implicit def testGroup: TestGroup = TestGroup("VulpixMetaTests")
23+
24+
@Test def compilePos: Unit = compileFilesInDir("../tests/meta-tests/pos", defaultOptions).checkCompile()
25+
@Test def compileNeg: Unit = compileFilesInDir("../tests/meta-tests/neg", defaultOptions).checkExpectedErrors()
26+
@Test def runAll: Unit = compileFilesInDir("../tests/meta-tests/run", defaultOptions).checkRuns()
27+
}

compiler/test/dotty/tools/vulpix/VulpixTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.junit.Test
77
import scala.concurrent.duration._
88
import scala.util.control.NonFatal
99

10-
/** Meta tests for the Vulpix test suite */
10+
/** Unit tests for the Vulpix test suite */
1111
class VulpixTests extends ParallelTesting {
1212
import TestConfiguration._
1313

project/scripts/cmdTests

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,22 @@ mkdir -p out/scriptedtest2
9292

9393
# echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI
9494
mkdir -p _site && ./bin/dotd -project Hello -siteroot _site tests/run/hello.scala
95+
96+
echo "running Vulpix meta test"
97+
tmp=$(mktemp)
98+
if sbt "dotty-compiler/testOnly dotty.tools.vulpix.VulpixMetaTests" > "$tmp" 2>&1; then
99+
echo "failed: sbt exited without error on VulpixMetaTests, these tests are expected to fail"
100+
exit -1
101+
fi
102+
tmp1=$(mktemp)
103+
cat "$tmp" | sed '/Test run started/,$!d' > "$tmp1"
104+
while read actual <&3 && read expected <&4; do
105+
if [[ "$expected" != *"SKIP" ]]; then
106+
if [ "$actual" != "$expected" ]; then
107+
echo "failed Vulpix meta: the output of sbt differs from the expected output"
108+
echo "expected : $expected"
109+
echo "actual : $actual"
110+
exit -1
111+
fi
112+
fi
113+
done 3<"$tmp1" 4<"./tests/meta-tests/sbt-output.check"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class MissingErrorAnnotation {
2+
// Missing annotation for the following unbound identifier:
3+
a
4+
5+
// Another one (to check that both of them get reported)
6+
b
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class NegTest {
2+
a // Does not compile
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hello
2+
world
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
println("world")
4+
println("hello") // Out of order
5+
}
6+
}

tests/meta-tests/sbt-output.check

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[info] Test run started
2+
[info] Test dotty.tools.vulpix.VulpixMetaTests.runAll started
3+
Testing ../tests/meta-tests/run/wrong-check-file.scala
4+
Output from '../tests/meta-tests/run/wrong-check-file.scala' did not match check file.
5+
Diff (expected on the left, actual right):
6+
hello | world
7+
world | hello
8+
EOF | EOF
9+
10+
[error] Test dotty.tools.vulpix.VulpixMetaTests.runAll failed: java.lang.AssertionError: Run test failed, but should not, reasons:
11+
[error] , took 1.673 sec SKIP
12+
[error]  at dotty.tools.vulpix.ParallelTesting$CompilationTest.checkRuns(ParallelTesting.scala:1000)
13+
[error]  at dotty.tools.vulpix.VulpixMetaTests.runAll(VulpixMetaTests.scala:26)
14+
[error]  ...
15+
[info] Test dotty.tools.vulpix.VulpixMetaTests.compileNeg started
16+
Testing ../tests/meta-tests/neg/missing-error-annotation.scala
17+
18+
Wrong number of errors encountered when compiling ../out/VulpixMetaTests/neg/missing-error-annotation, expected: 0, actual: 2
19+
20+
[error] Test dotty.tools.vulpix.VulpixMetaTests.compileNeg failed: java.lang.AssertionError: Neg test shouldn't have failed, but did. Reasons:
21+
[error] 
22+
[error]  - encountered 2 error(s), took 0.072 sec SKIP
23+
[error]  at dotty.tools.vulpix.ParallelTesting$CompilationTest.checkExpectedErrors(ParallelTesting.scala:982)
24+
[error]  at dotty.tools.vulpix.VulpixMetaTests.compileNeg(VulpixMetaTests.scala:25)
25+
[error]  ...
26+
[info] Test dotty.tools.vulpix.VulpixMetaTests.compilePos started
27+
Testing ../tests/meta-tests/pos/does-not-compile.scala
28+
-- [E006] Unbound Identifier Error: /home/olivier/workspace/dotty/compiler/../tests/meta-tests/pos/does-not-compile.scala:2:2 SKIP
29+
2 | a // Does not compile
30+
| ^
31+
| not found: a
32+
[error] Test dotty.tools.vulpix.VulpixMetaTests.compilePos failed: java.lang.AssertionError: Expected no errors when compiling, failed for the following reason(s):
33+
[error] 
34+
[error]  - encountered 1 error(s), took 0.069 sec SKIP
35+
[error]  at dotty.tools.vulpix.ParallelTesting$CompilationTest.checkCompile(ParallelTesting.scala:965)
36+
[error]  at dotty.tools.vulpix.VulpixMetaTests.compilePos(VulpixMetaTests.scala:24)
37+
[error]  ...
38+
[info] Test run finished: 3 failed, 0 ignored, 3 total, 1.964s SKIP
39+
[error] Failed: Total 3, Failed 3, Errors 0, Passed 0
40+
[error] Failed tests:
41+
[error]  dotty.tools.vulpix.VulpixMetaTests
42+
[error] (dotty-compiler/test:testOnly) sbt.TestsFailedException: Tests unsuccessful
43+
[error] Total time: 3 s, completed Feb 5, 2018 10:08:08 AM SKIP

0 commit comments

Comments
 (0)