-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Cleaner, quieter test rig tests #24073
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,99 @@ | ||
package dotty.tools | ||
package vulpix | ||
|
||
import scala.language.unsafeNulls | ||
|
||
import java.io.{File => JFile} | ||
import org.junit.Assert._ | ||
import org.junit.{ Test, AfterClass } | ||
|
||
import scala.concurrent.duration._ | ||
import scala.util.control.NonFatal | ||
import org.junit.{Test as test, AfterClass as tearDown} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find that confusing. Aliases here makes the code harder to follow: each time someone sees There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I borrowed that idiom from bishabosha, I think. I just saw it recently and fell in love. However, I am not wedded to it (at present). |
||
|
||
/** Unit tests for the Vulpix test suite */ | ||
class VulpixUnitTests { | ||
import VulpixUnitTests._ | ||
import TestConfiguration._ | ||
class VulpixUnitTests: | ||
import VulpixUnitTests.* | ||
import TestConfiguration.* | ||
|
||
implicit val _: SummaryReporting = new NoSummaryReport | ||
given SummaryReporting = new NoSummaryReport | ||
|
||
implicit def testGroup: TestGroup = TestGroup("VulpixTests") | ||
given TestGroup = TestGroup("VulpixTests") | ||
|
||
// To fail with something else than an AssertionError | ||
def fail(): Unit = throw new Exception("didn't fail properly") | ||
|
||
@Test def missingFile: Unit = | ||
try { | ||
@test def missingFile: Unit = | ||
assertThrows[IllegalArgumentException](_ => true): | ||
compileFile("tests/vulpix-tests/unit/i-dont-exist.scala", defaultOptions).expectFailure.checkExpectedErrors() | ||
fail() | ||
} catch { | ||
case _: IllegalArgumentException => // pass! | ||
} | ||
|
||
@Test def pos1Error: Unit = | ||
@test def pos1Error: Unit = | ||
compileFile("tests/vulpix-tests/unit/posFail1Error.scala", defaultOptions).expectFailure.checkCompile() | ||
|
||
@Test def negMissingAnnot: Unit = | ||
compileFile("tests/vulpix-tests/unit/negMissingAnnot.scala", defaultOptions).expectFailure.checkExpectedErrors() | ||
|
||
@Test def negAnnotWrongLine: Unit = | ||
compileFile("tests/vulpix-tests/unit/negAnnotWrongLine.scala", defaultOptions).expectFailure.checkExpectedErrors() | ||
|
||
@Test def negTooManyAnnots: Unit = | ||
compileFile("tests/vulpix-tests/unit/negTooManyAnnots.scala", defaultOptions).expectFailure.checkExpectedErrors() | ||
|
||
@Test def negNoPositionAnnot: Unit = | ||
compileFile("tests/vulpix-tests/unit/negNoPositionAnnots.scala", defaultOptions).expectFailure.checkExpectedErrors() | ||
|
||
@Test def negAnyPositionAnnot: Unit = | ||
compileFile("tests/vulpix-tests/unit/negAnyPositionAnnots.scala", defaultOptions).checkExpectedErrors() | ||
|
||
@Test def runCompileFail: Unit = | ||
@test def negMissingAnnot: Unit = | ||
compileFile("tests/vulpix-tests/unit/negMissingAnnot.scala", defaultOptions) | ||
.suppressAllOutput | ||
.expectFailure | ||
.checkExpectedErrors() | ||
|
||
@test def negAnnotWrongLine: Unit = | ||
compileFile("tests/vulpix-tests/unit/negAnnotWrongLine.scala", defaultOptions) | ||
.suppressAllOutput | ||
.expectFailure | ||
.checkExpectedErrors() | ||
|
||
@test def negTooManyAnnots: Unit = | ||
compileFile("tests/vulpix-tests/unit/negTooManyAnnots.scala", defaultOptions) | ||
.suppressAllOutput | ||
.expectFailure | ||
.checkExpectedErrors() | ||
|
||
@test def negNoPositionAnnot: Unit = | ||
compileFile("tests/vulpix-tests/unit/negNoPositionAnnots.scala", defaultOptions) | ||
.suppressAllOutput | ||
.expectFailure | ||
.checkExpectedErrors() | ||
|
||
@test def negAnyPositionAnnot: Unit = | ||
compileFile("tests/vulpix-tests/unit/negAnyPositionAnnots.scala", defaultOptions) | ||
.suppressAllOutput | ||
.checkExpectedErrors() | ||
|
||
@test def runCompileFail: Unit = | ||
compileFile("tests/vulpix-tests/unit/posFail1Error.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def runWrongOutput1: Unit = | ||
@test def runWrongOutput1: Unit = | ||
compileFile("tests/vulpix-tests/unit/runWrongOutput1.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def runWrongOutput2: Unit = | ||
@test def runWrongOutput2: Unit = | ||
compileFile("tests/vulpix-tests/unit/runWrongOutput2.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def runDiffOutput1: Unit = | ||
@test def runDiffOutput1: Unit = | ||
compileFile("tests/vulpix-tests/unit/runDiffOutput1.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def runStackOverflow: Unit = | ||
@test def runStackOverflow: Unit = | ||
compileFile("tests/vulpix-tests/unit/stackOverflow.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def runOutRedirects: Unit = | ||
@test def runOutRedirects: Unit = | ||
compileFile("tests/vulpix-tests/unit/i2147.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def infiteNonRec: Unit = | ||
@test def infiniteNonRec: Unit = | ||
compileFile("tests/vulpix-tests/unit/infinite.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def infiteTailRec: Unit = | ||
@test def infiniteTailRec: Unit = | ||
compileFile("tests/vulpix-tests/unit/infiniteTail.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def infiniteAlloc: Unit = | ||
@test def infiniteAlloc: Unit = | ||
compileFile("tests/vulpix-tests/unit/infiniteAlloc.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def deadlock: Unit = | ||
@test def deadlock: Unit = | ||
compileFile("tests/vulpix-tests/unit/deadlock.scala", defaultOptions).expectFailure.checkRuns() | ||
|
||
@Test def badJava: Unit = | ||
try { | ||
compileFile("tests/vulpix-tests/unit/BadJava.java", defaultOptions).suppressAllOutput.checkCompile() | ||
fail() | ||
} catch { | ||
case ae: AssertionError => assertTrue(ae.getMessage.contains("java compilation failed")) | ||
} | ||
@test def badJava: Unit = | ||
assertThrows[AssertionError](_.getMessage.contains("java compilation failed")): | ||
compileFile("tests/vulpix-tests/unit/BadJava.java", defaultOptions) | ||
.suppressAllOutput | ||
.checkCompile() | ||
|
||
@Test def runTimeout: Unit = { | ||
@test def runTimeout: Unit = | ||
val fileName = s"tests/vulpix-tests/unit/timeout.scala" | ||
try { | ||
compileFile(fileName, defaultOptions).checkRuns() | ||
fail() | ||
} catch { | ||
case ae: AssertionError => | ||
val expect = """(?m).*test '.+' timed out.*""" | ||
val actual = ae.getMessage.linesIterator.toList.last | ||
assert(actual.matches(expect), "actual = " + actual) | ||
} | ||
} | ||
} | ||
|
||
|
||
object VulpixUnitTests extends ParallelTesting { | ||
val expect = """(?m).*test '.+' timed out.*""" | ||
assertThrows[AssertionError](_.getMessage.linesIterator.toList.last.matches(expect)): | ||
compileFile(fileName, defaultOptions) | ||
.suppressAllOutput | ||
.checkRuns() | ||
|
||
object VulpixUnitTests extends ParallelTesting: | ||
import scala.concurrent.duration.* | ||
def maxDuration = 3.seconds | ||
def numberOfSlaves = 5 | ||
def safeMode = sys.env.get("SAFEMODE").isDefined | ||
|
@@ -110,6 +102,5 @@ object VulpixUnitTests extends ParallelTesting { | |
def updateCheckFiles: Boolean = false | ||
def failedTests = None | ||
|
||
@AfterClass | ||
def tearDown() = this.cleanup() | ||
} | ||
@tearDown | ||
def tearDown() = cleanup() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of mixing named parameters with unnamed parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boolean literals always get a name. Scala 2 has
-Wunnamed-boolean-literal
.