Skip to content
Merged
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
4 changes: 2 additions & 2 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1352,14 +1352,14 @@ trait ParallelTesting extends RunnerOrchestration:
* This behaviour is mainly needed for the tests that test the test suite.
*/
def expectFailure: CompilationTest =
new CompilationTest(targets, times, shouldDelete, threadLimit, true, shouldSuppressOutput)
new CompilationTest(targets, times, shouldDelete, threadLimit, shouldFail = true, shouldSuppressOutput)
Copy link
Member

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.

Copy link
Contributor Author

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.


/** Builds a `CompilationTest` where all output is suppressed
*
* This behaviour is mainly needed for the tests that test the test suite.
*/
def suppressAllOutput: CompilationTest =
new CompilationTest(targets, times, shouldDelete, threadLimit, shouldFail, true)
new CompilationTest(targets, times, shouldDelete, threadLimit, shouldFail, shouldSuppressOutput = true)

/** Delete all output files generated by this `CompilationTest` */
def delete(): Unit = targets.foreach(t => delete(t.outDir))
Expand Down
137 changes: 64 additions & 73 deletions compiler/test/dotty/tools/vulpix/VulpixUnitTests.scala
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}
Copy link
Member

Choose a reason for hiding this comment

The 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 @test or tearDown, they’ll need to check the import to realize these are actually JUnit’s @Test and @AfterClass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand All @@ -110,6 +102,5 @@ object VulpixUnitTests extends ParallelTesting {
def updateCheckFiles: Boolean = false
def failedTests = None

@AfterClass
def tearDown() = this.cleanup()
}
@tearDown
def tearDown() = cleanup()
Loading