|
| 1 | +package dotty.tools |
| 2 | +package vulpix |
| 3 | + |
| 4 | +import org.junit.Assert._ |
| 5 | +import org.junit.Test |
| 6 | + |
| 7 | +import scala.concurrent.duration._ |
| 8 | +import scala.util.control.NonFatal |
| 9 | + |
| 10 | +/** Unit tests for the Vulpix test suite */ |
| 11 | +class VulpixUnitTests extends ParallelTesting { |
| 12 | + import TestConfiguration._ |
| 13 | + |
| 14 | + implicit val _: SummaryReporting = new NoSummaryReport |
| 15 | + |
| 16 | + implicit def testGroup: TestGroup = TestGroup("VulpixTests") |
| 17 | + |
| 18 | + def maxDuration = 3.seconds |
| 19 | + def numberOfSlaves = 5 |
| 20 | + def safeMode = sys.env.get("SAFEMODE").isDefined |
| 21 | + def isInteractive = !sys.env.contains("DRONE") |
| 22 | + def testFilter = None |
| 23 | + |
| 24 | + // To fail with something else than an AssertionError |
| 25 | + def fail(): Unit = throw new Exception("didn't fail properly") |
| 26 | + |
| 27 | + @Test def missingFile: Unit = |
| 28 | + try { |
| 29 | + compileFile("tests/vulpix-tests/unit/i-dont-exist.scala", defaultOptions).expectFailure.checkExpectedErrors() |
| 30 | + fail() |
| 31 | + } catch { |
| 32 | + case _: IllegalArgumentException => // pass! |
| 33 | + } |
| 34 | + |
| 35 | + @Test def pos1Error: Unit = |
| 36 | + compileFile("tests/vulpix-tests/unit/posFail1Error.scala", defaultOptions).expectFailure.checkCompile() |
| 37 | + |
| 38 | + @Test def negMissingAnnot: Unit = |
| 39 | + compileFile("tests/vulpix-tests/unit/negMissingAnnot.scala", defaultOptions).expectFailure.checkExpectedErrors() |
| 40 | + |
| 41 | + @Test def negAnnotWrongLine: Unit = |
| 42 | + compileFile("tests/vulpix-tests/unit/negAnnotWrongLine.scala", defaultOptions).expectFailure.checkExpectedErrors() |
| 43 | + |
| 44 | + @Test def negTooManyAnnots: Unit = |
| 45 | + compileFile("tests/vulpix-tests/unit/negTooManyAnnots.scala", defaultOptions).expectFailure.checkExpectedErrors() |
| 46 | + |
| 47 | + @Test def negNoPositionAnnot: Unit = |
| 48 | + compileFile("tests/vulpix-tests/unit/negNoPositionAnnots.scala", defaultOptions).expectFailure.checkExpectedErrors() |
| 49 | + |
| 50 | + @Test def runCompileFail: Unit = |
| 51 | + compileFile("tests/vulpix-tests/unit/posFail1Error.scala", defaultOptions).expectFailure.checkRuns() |
| 52 | + |
| 53 | + @Test def runWrongOutput1: Unit = |
| 54 | + compileFile("tests/vulpix-tests/unit/runWrongOutput1.scala", defaultOptions).expectFailure.checkRuns() |
| 55 | + |
| 56 | + @Test def runWrongOutput2: Unit = |
| 57 | + compileFile("tests/vulpix-tests/unit/runWrongOutput2.scala", defaultOptions).expectFailure.checkRuns() |
| 58 | + |
| 59 | + @Test def runDiffOutput1: Unit = |
| 60 | + compileFile("tests/vulpix-tests/unit/runDiffOutput1.scala", defaultOptions).expectFailure.checkRuns() |
| 61 | + |
| 62 | + @Test def runStackOverflow: Unit = |
| 63 | + compileFile("tests/vulpix-tests/unit/stackOverflow.scala", defaultOptions).expectFailure.checkRuns() |
| 64 | + |
| 65 | + @Test def runOutRedirects: Unit = |
| 66 | + compileFile("tests/vulpix-tests/unit/i2147.scala", defaultOptions).expectFailure.checkRuns() |
| 67 | + |
| 68 | + @Test def infiteNonRec: Unit = |
| 69 | + compileFile("tests/vulpix-tests/unit/infinite.scala", defaultOptions).expectFailure.checkRuns() |
| 70 | + |
| 71 | + @Test def infiteTailRec: Unit = |
| 72 | + compileFile("tests/vulpix-tests/unit/infiniteTail.scala", defaultOptions).expectFailure.checkRuns() |
| 73 | + |
| 74 | + @Test def infiniteAlloc: Unit = |
| 75 | + compileFile("tests/vulpix-tests/unit/infiniteAlloc.scala", defaultOptions).expectFailure.checkRuns() |
| 76 | + |
| 77 | + @Test def deadlock: Unit = |
| 78 | + compileFile("tests/vulpix-tests/unit/deadlock.scala", defaultOptions).expectFailure.checkRuns() |
| 79 | + |
| 80 | + @Test def badJava: Unit = |
| 81 | + try { |
| 82 | + compileFile("tests/vulpix-tests/unit/BadJava.java", defaultOptions).suppressAllOutput.checkCompile() |
| 83 | + fail() |
| 84 | + } catch { |
| 85 | + case ae: AssertionError => assertTrue(ae.getMessage.contains("java compilation failed")) |
| 86 | + } |
| 87 | + |
| 88 | + @Test def runTimeout: Unit = { |
| 89 | + try { |
| 90 | + compileFile("tests/vulpix-tests/unit/timeout.scala", defaultOptions).checkRuns() |
| 91 | + fail() |
| 92 | + } catch { |
| 93 | + case ae: AssertionError => |
| 94 | + assertEquals(ae.getMessage, "Run test failed, but should not, reasons:\n - test 'tests/vulpix-tests/unit/timeout.scala' timed out") |
| 95 | + } |
| 96 | + } |
| 97 | +} |
0 commit comments