Skip to content

Commit 3815224

Browse files
authored
Merge pull request #5708 from dotty-staging/fix-#4389
Fix #4389: Add test infrastructure for fuzzy tests
2 parents 0c66517 + d4989f5 commit 3815224

File tree

222 files changed

+2701
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+2701
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ class CompilationTests extends ParallelTesting {
167167
compileFile("tests/neg-custom-args/repeatedArgs213.scala", defaultOptions.and("-Ynew-collections"))
168168
}.checkExpectedErrors()
169169

170+
@Test def fuzzyAll: Unit = {
171+
implicit val testGroup: TestGroup = TestGroup("compileFuzzy")
172+
compileFilesInDir("tests/fuzzy", defaultOptions)
173+
}.checkNoCrash()
174+
170175
// Run tests -----------------------------------------------------------------
171176

172177
@Test def runAll: Unit = {

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,32 @@ trait ParallelTesting extends RunnerOrchestration { self =>
813813
}
814814
}
815815

816+
private final class NoCrashTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)(implicit summaryReport: SummaryReporting)
817+
extends Test(testSources, times, threadLimit, suppressAllOutput) {
818+
protected def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable {
819+
def checkTestSource(): Unit = tryCompile(testSource) {
820+
def fail(msg: String): Nothing = {
821+
echo(msg)
822+
failTestSource(testSource)
823+
???
824+
}
825+
testSource match {
826+
case testSource@JointCompilationSource(_, files, flags, outDir, fromTasty, decompilation) =>
827+
val sourceFiles = testSource.sourceFiles
828+
val reporter =
829+
try compile(sourceFiles, flags, true, outDir)
830+
catch {
831+
case ex: Throwable => fail(s"Fatal compiler crash when compiling: ${testSource.title}")
832+
}
833+
if (reporter.compilerCrashed)
834+
fail(s"Compiler crashed when compiling: ${testSource.title}")
835+
case testSource@SeparateCompilationSource(_, dir, flags, outDir) => unsupported("NoCrashTest - SeparateCompilationSource")
836+
}
837+
registerCompletion()
838+
}
839+
}
840+
}
841+
816842
/** The `CompilationTest` is the main interface to `ParallelTesting`, it
817843
* can be instantiated via one of the following methods:
818844
*
@@ -994,6 +1020,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
9941020
this
9951021
}
9961022

1023+
/** Creates a "fuzzy" test run, which makes sure that each test compiles (or not) without crashing */
1024+
def checkNoCrash()(implicit summaryReport: SummaryReporting): this.type = {
1025+
val test = new NoCrashTest(targets, times, threadLimit, shouldSuppressOutput).executeTestSuite()
1026+
1027+
cleanup()
1028+
1029+
if (test.didFail) {
1030+
fail("Neg test should have failed, but did not")
1031+
}
1032+
1033+
this
1034+
}
1035+
9971036
/** Creates a "run" test run, which is a superset of "pos". In addition to
9981037
* making sure that all tests pass compilation and that they do not crash
9991038
* the compiler; it also makes sure that all tests can run with the
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class i0 {
2+
type Int;
3+
val i1 = 2
4+
private val i2 = (List(): List[Int])
5+
import i1.{ () => Double(_)).asInstanceOf[i2]) } else new i0(1)
6+
List(List(1), None)
7+
println(i1(17))
8+
new _
9+
collect i1 :: 2
10+
}
11+
object package {
12+
val i5 = scala { object false => } { class i2; 0 }
13+
}
14+
def i9(i8: String) = {}
15+
def Throwable
16+
trait i11
17+
abstract class i1 {
18+
override implicit def i2(i3: i0.i1) = match {
19+
case i4(i5) => 1
20+
case _ => Console.println() }
21+
}
22+
}
23+
}
24+
trait i7[i10 <: i0, i8 <: i0, i12, i13, i16, i12] {
25+
@Seq[i1] => (i2, main)
26+
type i14[i1, i16 <: i4, <: i62, i18, i9, i18, i19, i20, i13, i19, i19, i14,, i20, 'i18, i14, i10),
27+
i77, 9, i14, i15, i16, i17, i19, i20, [Boolean, i20]): i2[i2] = sys.error()
28+
val i17 = i5[Int](1, )
29+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package i0
2+
package i1
3+
import scala.language.i1
4+
class i2[i3] {
5+
def i4(i5: i3): i4[i5] = null
6+
}
7+
class i8 {
8+
trait i1[i2]
9+
implicit def i6[i7[_]](i8: i0[i3]): i6[i5] = new i7[i9] {
10+
override def i8[i2](i9: i7): i7[i2] = new i5[i3]
11+
def map = i10
12+
}
13+
class i12 extends i1[String] {
14+
def i10(i4: String) = i11(i13, i9)
15+
}
16+
trait i11[i4] {
17+
def i19[i17[_]](i4: i15): i11[Boolean] = i12
18+
def i13[i14[_]](i12: i7[i10], i10: i9[i6]): Unit = ({
19+
val i12 = 1
20+
i1[i10[String]](_
21+
abstract class i1(i2: Int, i3: Int)
22+
class i6() {
23+
def i2(i5: Any) = i3 match {
24+
case (i3: Int, i4: Int) => i3 + i2 i3 1
25+
case _ => case i4 =>
26+
}
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class i0[@specialized i1] {
2+
def i2[i3[_]](i4: i1 => i3[Nothing]): i2[Int] = ???
3+
implicit def i5[i2](i6: i0[i1, i2]) = ???
4+
implicit def i5(implicit i3: i1[Int]): String => String = {
5+
val i6: i2 = new i0[Int] { def i7(i5: Int) = 0 }
6+
val i1 = i2 == i2 match { case i1[i2](i3, i6) =>
7+
def this(i6: Array[String]) = i3 _
8+
}
9+
}
10+
trait i7 { type i5 }
11+
trait i6 extends i5 { type i6 = i4 }
12+
val i7: i3 & i1 = new i1 { type i2 = String }
13+
val i8: String = i6
14+
val i9: i1
15+
final val i11: i3 = ???
16+
implicit def i10(i11: i0[Int, Int]): Unit = {
17+
List(1).asInstanceOf[toString])
18+
println(new i0[Int]())
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object i0 {
2+
def i1(i2: Int): Unit = {
3+
def i3(): Unit = {
4+
def this() = this(0);
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class i0 {
2+
val i1: (Any => String) = ???
3+
}
4+
object i0 {
5+
import Ordering.{ implicitly => } (true: Boolean) match { case _: i1 => true }
6+
def i1(erased i2: Int): Int = { i1: Set[Int] => }
7+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object App {
2+
import i0.{ i1 => false }
3+
def Array(i0: Int => Boolean): Any = ???
4+
}
5+
object i2 {
6+
for (i1 <- i2) i2 match {
7+
case Some(i3) => ??? case i1(_)) => i2
8+
}
9+
val i7: i3 {type i1 = i1; val
10+
) println(i10 + 1) < 96: (List, [Int]) def i13[i12] => Array[try <: i0](i12: Int, i12: => Option[i1]
11+
): Int = (i14: Int) =>
12+
i2(i4)
13+
def i17[i12](i16: => String): List[i10] = i2
14+
def i14[@specialized i4: Option[Any], i8 > k943[assert, Object](i23 Array[Int]) = (i13)i12).isInstanceOf[i3])
15+
implicit def apply[i14[_], i14,i19](i11: i0[i1[new, Int]): Option[i5] = i11 += i11
16+
val i16 = i12
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object i0 {
2+
type i1 = Int val i2: Int = { i2: Int => }
3+
def i3(i4: Int => String) = i4 match { case i3 => () })
4+
trait i5
5+
trait i6
6+
trait i7
7+
implicit def i5: Unit | ((_: String): Int) = ()
8+
val i6 = i2()
9+
val i5: i4.i2 = i4.i1[Nothing]
10+
println()
11+
println()
12+
trait i3 extends i2 {
13+
type i2 = i3
14+
class i4
15+
}
16+
trait i3 extends i0 {
17+
def i1 = classOf
18+
class i1(i0: Int) extends i2(i2)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class i0[i1] {
2+
def i2[i3[_], i4](i5: i1[i2], i6: i0[i4]): i4[i2] = i4
3+
}
4+
object i7 {
5+
val i8: i0[Int] = classOf[Nothing, _ with i5]()
6+
}
7+
object i9 {
8+
def i10[i10](i11: i12[i2]): i1[i2] = new i1[i2] {}
9+
def i15[i15](i11: i7[i13.i1]): i1[i2] = i15 match {
10+
case i15 :: i7 => i10 _ val i17: Symbol = ???
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
case class i0(i1: String, i2: String, i3: String)
2+
class i4(i3: Int) extends i0({ val i1 = new { val i1 = Int; var i3: Int =
3+
if (i2 == 0) {
4+
val i4 = new i0
5+
def i5 = sys.error("")
6+
def i6(i7: Int*) = i7 i4 i3 i4 i7 match {
7+
case i6(_) => 1
8+
case i4: i3 => i5.toString
9+
def this(i5: Int) = i3 * i4
10+
}
11+
def this(i6: Int) = { this(new { def i7 = 0; println(); i3 }
12+
def i6 = { object i7 { 5 + 4 }
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
trait i0[i1] { def i2: Int }
2+
class i3 {
3+
def i4[i1[_]]: i1[i3] = new i1[Int] {}
4+
def i5[i6](i7: i6): i3[i1, i6] = ???
5+
def i8 = new i3.i9()
6+
}
7+
class i2 extends i0[Nothing] {
8+
def i15: Option[(i11 i1]) => String = i13 match {
9+
case i3(i1(i11) => i11)
10+
}
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
abstract class i0 {
2+
type i1
3+
type i2 <: i1
4+
type i3 <: i4 {
5+
type i2 = i3
6+
val i5 = new i3
7+
val i6 = new i2
8+
val i7 = new i3
9+
val i6 = i5 _
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
abstract class i0[i1 <: Nothing] {
2+
def +(i2: String) = {
3+
def this() = this(0)
4+
}
5+
object i3 {
6+
def apply[i2](i3: i2) = new i0("")
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object i0 {
2+
type i1 = Array { def i2 = this }
3+
def main(i3: Array[String]): Unit = {
4+
println();
5+
trait i4 extends i2 with i0 {
6+
def i5: i0 = i1;
7+
class i6(i7: i3) { () =>
8+
i6 foreach { case _: i0.i3 => implicitly[i0] })("i2 " this })
9+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object i0 {
2+
def i1[i2, +i3] = ()
3+
def this(i4: Int = i1 => Int => () == new Any with i3(i4) + 0
4+
def i5[i4](i6: i4) = i6
5+
def i8(i9: Int) = i10(1)
6+
i5(new i1()
7+
def i13[i4](i11: i2 => i1): Unit
8+
def i9(i10: i0): i6[String, String] =
9+
val i9(i10: List[i1]): Int = (1, i10)
10+
def i10(i11: Int) = i23(i13)
11+
def i10[i4](i5: i9[i10, i12]): i1[Int] = { Some(i9" i11 i6 this 12).collect.i32(1 i31(i2 i11)) i12 else () }
12+
trait i11[i15[_]]
13+
object i10 { def unapply[i11](i2: => Option => String): Option[i7] }
14+
class i10 extends i3(i6 + i9) lazy map { case _: i9 => () } new i5[String]
15+
def i14(i15: Int): String = i13.toString
16+
}
17+
val i11: i0 = new i9("")
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object i0 {
2+
def i1(i2: Any, i3: Any, i4: Any => Any) = (i5, i4)
3+
def i6(i5: List[Int]): Int = i6 match {
4+
case _: String @_*i6 match { case _: i7.type
5+
8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object App {
2+
def this(i0: Int = 100) = {
3+
val i1: i0 = 1; case _ => i2(i1) }
4+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object i0 {
2+
type i1 = (=> Int) | (2 => i2)("i3 i4{i5} i6 = i4;
3+
case (i4, i5) => ()
4+
i6
5+
} def main(i4: Array[String]): Unit = {
6+
val i5 = * i6
7+
i5
8+
} else
9+
i6
10+
}
11+
})
12+
object i7 {
13+
import i0.{ classTag, i3 } & (2 -> filter*) }
14+
def i7(i2: Int): i0
15+
val i5 = _
16+
i7 = i0
17+
})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
object i0 {
2+
def i1 = 2
3+
}
4+
trait i2 extends AnyRef {
5+
private object i2 extends i0
6+
trait i1 {
7+
private def i2: Int = 1 implicitly[Int]
8+
}
9+
} final type i3 {
10+
new implicitly[i0, i4]
11+
type i5 = (i5: i0[Int, Nil[i2]], i4: String): Stream[i1 <: Nil] => i2[i0]
12+
}
13+
val i5 = {
14+
implicitly["": i5 with AnyVal] { (i5: Int
15+
object i0 {
16+
def scala[i1](i2: i3.RuntimeException) = {
17+
def this() = this() }
18+
implicit lazy val i4: String =}[i1] {
19+
def i5: Unit =
20+
i4() match { case i3 => 0.map() = this match {
21+
case _ =>
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)