Skip to content

Commit 76ce64f

Browse files
fuzzy works
1 parent c22f242 commit 76ce64f

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CompilationTests extends ParallelTesting {
4343
}
4444

4545
@Test def exampleNeg: Unit = {
46-
implicit val testGroup: TestGroup = TestGroup("examplePos")
46+
implicit val testGroup: TestGroup = TestGroup("exampleNeg")
4747
compileFilesInDir("tests/playground/neg", defaultOptions).checkExpectedErrors()
4848
}
4949

@@ -52,6 +52,11 @@ class CompilationTests extends ParallelTesting {
5252
compileFilesInDir("tests/playground/run", defaultOptions).checkRuns()
5353
}
5454

55+
@Test def exampleFuzzy: Unit = {
56+
implicit val testGroup: TestGroup = TestGroup("exampleFuzzy")
57+
compileFilesInDir("tests/playground/fuzzy", defaultOptions).checkNoCrash()
58+
}
59+
5560
@Test def pos: Unit = {
5661
implicit val testGroup: TestGroup = TestGroup("compilePos")
5762
compileList("compileStdLib", TestSources.stdLibSources, scala2Mode.and("-migration", "-Yno-inline")) +

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

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
186186
private trait CompilationLogic { this: Test =>
187187
val suppressErrors = false
188188

189-
final def compileTestSource(testSource: TestSource): List[TestReporter] =
190-
testSource match {
189+
final def compileTestSource(testSource: TestSource): Either[Throwable, List[TestReporter]] =
190+
Try(testSource match {
191191
case testSource @ JointCompilationSource(name, files, flags, outDir, fromTasty, decompilation) =>
192192
val reporter =
193193
if (fromTasty) compileFromTasty( flags, suppressErrors, outDir)
@@ -196,7 +196,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
196196

197197
case testSource @ SeparateCompilationSource(_, dir, flags, outDir) =>
198198
testSource.compilationGroups.map(files => compile(files, flags, suppressErrors, outDir)) // TODO? only `compile` option?
199-
}
199+
}).toEither
200200

201201
final def countErrorsAndWarnings(reporters: Seq[TestReporter]): (Int, Int) =
202202
reporters.foldLeft((0, 0)) { case ((err, warn), r) => (err + r.errorCount, warn + r.warningCount) }
@@ -224,14 +224,16 @@ trait ParallelTesting extends RunnerOrchestration { self =>
224224

225225
def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable { self =>
226226
def checkTestSource(): Unit = tryCompile(testSource) {
227-
val reporters = compileTestSource(testSource)
228-
onComplete(testSource, reporters, self)
227+
val reportersOrCrash = compileTestSource(testSource)
228+
onComplete(testSource, reportersOrCrash, self)
229229
registerCompletion()
230230
}
231231
}
232232

233-
final def onComplete(testSource: TestSource, reporters: Seq[TestReporter], logger: LoggedRunnable): Unit = (
234-
testFailed(testSource, reporters).fold
233+
final def onComplete(testSource: TestSource, reportersOrCrash: Either[Throwable, Seq[TestReporter]], logger: LoggedRunnable): Unit =
234+
reportersOrCrash.fold(
235+
exn => onFailure(testSource, Nil, logger, Some(s"Fatal compiler crash when compiling: ${testSource.title}:\n${exn.getMessage}\n${exn.getStackTrace.mkString("\n")}"))
236+
, reporters => testFailed(testSource, reporters).fold
235237
( onSuccess(testSource, reporters, logger ) )
236238
(msg => onFailure(testSource, reporters, logger, Option(msg).filter(_.nonEmpty)) ) )
237239

@@ -646,7 +648,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
646648
private final class NegTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)(implicit summaryReport: SummaryReporting)
647649
extends Test(testSources, times, threadLimit, suppressAllOutput) {
648650
override val suppressErrors = true
649-
651+
650652
override def testFailed(testSource: TestSource, reporters: Seq[TestReporter]): Option[String] = {
651653
val compilerCrashed = reporters.exists(_.compilerCrashed)
652654
val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(testSource.sourceFiles)
@@ -719,29 +721,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
719721
}
720722

721723
private final class NoCrashTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)(implicit summaryReport: SummaryReporting)
722-
extends Test(testSources, times, threadLimit, suppressAllOutput) {
723-
override def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable {
724-
def checkTestSource(): Unit = tryCompile(testSource) {
725-
def fail(msg: String): Nothing = {
726-
echo(msg)
727-
failTestSource(testSource)
728-
???
729-
}
730-
testSource match {
731-
case testSource@JointCompilationSource(_, files, flags, outDir, fromTasty, decompilation) =>
732-
val sourceFiles = testSource.sourceFiles
733-
val reporter =
734-
try compile(sourceFiles, flags, true, outDir)
735-
catch {
736-
case ex: Throwable => fail(s"Fatal compiler crash when compiling: ${testSource.title}")
737-
}
738-
if (reporter.compilerCrashed)
739-
fail(s"Compiler crashed when compiling: ${testSource.title}")
740-
case testSource@SeparateCompilationSource(_, dir, flags, outDir) => unsupported("NoCrashTest - SeparateCompilationSource")
741-
}
742-
registerCompletion()
743-
}
744-
}
724+
extends Test(testSources, times, threadLimit, suppressAllOutput) {
725+
override val suppressErrors = true
726+
override def testFailed(testSource: TestSource, reporters: Seq[TestReporter]): Option[String] = None
745727
}
746728

747729
def diffMessage(sourceTitle: String, outputLines: Seq[String], checkLines: Seq[String]): Option[String] = {

tests/playground/fuzzy/stuff.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo

tests/playground/fuzzy/works.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
case class Bar(x: Int)

0 commit comments

Comments
 (0)