Skip to content

Fix #4389: Add test infrastructure for fuzzy tests #5708

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

Merged
merged 1 commit into from
Jan 15, 2019
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
5 changes: 5 additions & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ class CompilationTests extends ParallelTesting {
compileFile("tests/neg-custom-args/repeatedArgs213.scala", defaultOptions.and("-Ynew-collections"))
}.checkExpectedErrors()

@Test def fuzzyAll: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileFuzzy")
compileFilesInDir("tests/fuzzy", defaultOptions)
}.checkNoCrash()

// Run tests -----------------------------------------------------------------

@Test def runAll: Unit = {
Expand Down
39 changes: 39 additions & 0 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,32 @@ trait ParallelTesting extends RunnerOrchestration { self =>
}
}

private final class NoCrashTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)(implicit summaryReport: SummaryReporting)
extends Test(testSources, times, threadLimit, suppressAllOutput) {
protected def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable {
def checkTestSource(): Unit = tryCompile(testSource) {
def fail(msg: String): Nothing = {
echo(msg)
failTestSource(testSource)
???
}
testSource match {
case testSource@JointCompilationSource(_, files, flags, outDir, fromTasty, decompilation) =>
val sourceFiles = testSource.sourceFiles
val reporter =
try compile(sourceFiles, flags, true, outDir)
catch {
case ex: Throwable => fail(s"Fatal compiler crash when compiling: ${testSource.title}")
}
if (reporter.compilerCrashed)
fail(s"Compiler crashed when compiling: ${testSource.title}")
case testSource@SeparateCompilationSource(_, dir, flags, outDir) => unsupported("NoCrashTest - SeparateCompilationSource")
}
registerCompletion()
}
}
}

/** The `CompilationTest` is the main interface to `ParallelTesting`, it
* can be instantiated via one of the following methods:
*
Expand Down Expand Up @@ -994,6 +1020,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
this
}

/** Creates a "fuzzy" test run, which makes sure that each test compiles (or not) without crashing */
def checkNoCrash()(implicit summaryReport: SummaryReporting): this.type = {
val test = new NoCrashTest(targets, times, threadLimit, shouldSuppressOutput).executeTestSuite()

cleanup()

if (test.didFail) {
fail("Neg test should have failed, but did not")
}

this
}

/** Creates a "run" test run, which is a superset of "pos". In addition to
* making sure that all tests pass compilation and that they do not crash
* the compiler; it also makes sure that all tests can run with the
Expand Down
29 changes: 29 additions & 0 deletions tests/fuzzy/015ea9cf2d07b27200a33c4451bfc4c93afe213e.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class i0 {
type Int;
val i1 = 2
private val i2 = (List(): List[Int])
import i1.{ () => Double(_)).asInstanceOf[i2]) } else new i0(1)
List(List(1), None)
println(i1(17))
new _
collect i1 :: 2
}
object package {
val i5 = scala { object false => } { class i2; 0 }
}
def i9(i8: String) = {}
def Throwable
trait i11
abstract class i1 {
override implicit def i2(i3: i0.i1) = match {
case i4(i5) => 1
case _ => Console.println() }
}
}
}
trait i7[i10 <: i0, i8 <: i0, i12, i13, i16, i12] {
@Seq[i1] => (i2, main)
type i14[i1, i16 <: i4, <: i62, i18, i9, i18, i19, i20, i13, i19, i19, i14,, i20, 'i18, i14, i10),
i77, 9, i14, i15, i16, i17, i19, i20, [Boolean, i20]): i2[i2] = sys.error()
val i17 = i5[Int](1, )
}
27 changes: 27 additions & 0 deletions tests/fuzzy/028127de3ac8c2ee6ccde25072d765581dbd06f9.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package i0
package i1
import scala.language.i1
class i2[i3] {
def i4(i5: i3): i4[i5] = null
}
class i8 {
trait i1[i2]
implicit def i6[i7[_]](i8: i0[i3]): i6[i5] = new i7[i9] {
override def i8[i2](i9: i7): i7[i2] = new i5[i3]
def map = i10
}
class i12 extends i1[String] {
def i10(i4: String) = i11(i13, i9)
}
trait i11[i4] {
def i19[i17[_]](i4: i15): i11[Boolean] = i12
def i13[i14[_]](i12: i7[i10], i10: i9[i6]): Unit = ({
val i12 = 1
i1[i10[String]](_
abstract class i1(i2: Int, i3: Int)
class i6() {
def i2(i5: Any) = i3 match {
case (i3: Int, i4: Int) => i3 + i2 i3 1
case _ => case i4 =>
}
}
19 changes: 19 additions & 0 deletions tests/fuzzy/048e0594728ea7cdff7497c4e90bf702f220b206.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class i0[@specialized i1] {
def i2[i3[_]](i4: i1 => i3[Nothing]): i2[Int] = ???
implicit def i5[i2](i6: i0[i1, i2]) = ???
implicit def i5(implicit i3: i1[Int]): String => String = {
val i6: i2 = new i0[Int] { def i7(i5: Int) = 0 }
val i1 = i2 == i2 match { case i1[i2](i3, i6) =>
def this(i6: Array[String]) = i3 _
}
}
trait i7 { type i5 }
trait i6 extends i5 { type i6 = i4 }
val i7: i3 & i1 = new i1 { type i2 = String }
val i8: String = i6
val i9: i1
final val i11: i3 = ???
implicit def i10(i11: i0[Int, Int]): Unit = {
List(1).asInstanceOf[toString])
println(new i0[Int]())
}
6 changes: 6 additions & 0 deletions tests/fuzzy/06abe47b5828fec1c1975aae63202b4f93cf0bac.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object i0 {
def i1(i2: Int): Unit = {
def i3(): Unit = {
def this() = this(0);
}
}
7 changes: 7 additions & 0 deletions tests/fuzzy/14b960e57195554a6a085eae8e039a949e8b106d.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class i0 {
val i1: (Any => String) = ???
}
object i0 {
import Ordering.{ implicitly => } (true: Boolean) match { case _: i1 => true }
def i1(erased i2: Int): Int = { i1: Set[Int] => }
}
17 changes: 17 additions & 0 deletions tests/fuzzy/1d1f57703bbd37dd850480cb5d99130930be08c9.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
object App {
import i0.{ i1 => false }
def Array(i0: Int => Boolean): Any = ???
}
object i2 {
for (i1 <- i2) i2 match {
case Some(i3) => ??? case i1(_)) => i2
}
val i7: i3 {type i1 = i1; val
) println(i10 + 1) < 96: (List, [Int]) def i13[i12] => Array[try <: i0](i12: Int, i12: => Option[i1]
): Int = (i14: Int) =>
i2(i4)
def i17[i12](i16: => String): List[i10] = i2
def i14[@specialized i4: Option[Any], i8 > k943[assert, Object](i23 Array[Int]) = (i13)i12).isInstanceOf[i3])
implicit def apply[i14[_], i14,i19](i11: i0[i1[new, Int]): Option[i5] = i11 += i11
val i16 = i12
}
18 changes: 18 additions & 0 deletions tests/fuzzy/1e3ef21bb17fbe13bf3beaf13a18ca382b52a469.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
object i0 {
type i1 = Int val i2: Int = { i2: Int => }
def i3(i4: Int => String) = i4 match { case i3 => () })
trait i5
trait i6
trait i7
implicit def i5: Unit | ((_: String): Int) = ()
val i6 = i2()
val i5: i4.i2 = i4.i1[Nothing]
println()
println()
trait i3 extends i2 {
type i2 = i3
class i4
}
trait i3 extends i0 {
def i1 = classOf
class i1(i0: Int) extends i2(i2)
12 changes: 12 additions & 0 deletions tests/fuzzy/28752b8fb9b6db06fff4c606c3a402dc12b0ee06.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class i0[i1] {
def i2[i3[_], i4](i5: i1[i2], i6: i0[i4]): i4[i2] = i4
}
object i7 {
val i8: i0[Int] = classOf[Nothing, _ with i5]()
}
object i9 {
def i10[i10](i11: i12[i2]): i1[i2] = new i1[i2] {}
def i15[i15](i11: i7[i13.i1]): i1[i2] = i15 match {
case i15 :: i7 => i10 _ val i17: Symbol = ???
}
}
13 changes: 13 additions & 0 deletions tests/fuzzy/2bd7cd0e80b641fa33d269c737c79e9d38f3bd64.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
case class i0(i1: String, i2: String, i3: String)
class i4(i3: Int) extends i0({ val i1 = new { val i1 = Int; var i3: Int =
if (i2 == 0) {
val i4 = new i0
def i5 = sys.error("")
def i6(i7: Int*) = i7 i4 i3 i4 i7 match {
case i6(_) => 1
case i4: i3 => i5.toString
def this(i5: Int) = i3 * i4
}
def this(i6: Int) = { this(new { def i7 = 0; println(); i3 }
def i6 = { object i7 { 5 + 4 }
}
12 changes: 12 additions & 0 deletions tests/fuzzy/31fe0d61224c99962a43598263b06c0435aae202.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait i0[i1] { def i2: Int }
class i3 {
def i4[i1[_]]: i1[i3] = new i1[Int] {}
def i5[i6](i7: i6): i3[i1, i6] = ???
def i8 = new i3.i9()
}
class i2 extends i0[Nothing] {
def i15: Option[(i11 i1]) => String = i13 match {
case i3(i1(i11) => i11)
}
}
}
10 changes: 10 additions & 0 deletions tests/fuzzy/34d778fcc0ad3dccec0fa7b83b3333868bda8251.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
abstract class i0 {
type i1
type i2 <: i1
type i3 <: i4 {
type i2 = i3
val i5 = new i3
val i6 = new i2
val i7 = new i3
val i6 = i5 _
}
7 changes: 7 additions & 0 deletions tests/fuzzy/35089d35a316726b914741884113b859aa6bfeb5.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
abstract class i0[i1 <: Nothing] {
def +(i2: String) = {
def this() = this(0)
}
object i3 {
def apply[i2](i3: i2) = new i0("")
}
9 changes: 9 additions & 0 deletions tests/fuzzy/366525577470a6e3ecac0b77b1dcdc58405156ed.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object i0 {
type i1 = Array { def i2 = this }
def main(i3: Array[String]): Unit = {
println();
trait i4 extends i2 with i0 {
def i5: i0 = i1;
class i6(i7: i3) { () =>
i6 foreach { case _: i0.i3 => implicitly[i0] })("i2 " this })
}
18 changes: 18 additions & 0 deletions tests/fuzzy/36e924e6d37279c86a4420f3a80810e419bd31dd.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
object i0 {
def i1[i2, +i3] = ()
def this(i4: Int = i1 => Int => () == new Any with i3(i4) + 0
def i5[i4](i6: i4) = i6
def i8(i9: Int) = i10(1)
i5(new i1()
def i13[i4](i11: i2 => i1): Unit
def i9(i10: i0): i6[String, String] =
val i9(i10: List[i1]): Int = (1, i10)
def i10(i11: Int) = i23(i13)
def i10[i4](i5: i9[i10, i12]): i1[Int] = { Some(i9" i11 i6 this 12).collect.i32(1 i31(i2 i11)) i12 else () }
trait i11[i15[_]]
object i10 { def unapply[i11](i2: => Option => String): Option[i7] }
class i10 extends i3(i6 + i9) lazy map { case _: i9 => () } new i5[String]
def i14(i15: Int): String = i13.toString
}
val i11: i0 = new i9("")
}
5 changes: 5 additions & 0 deletions tests/fuzzy/3760adc72d035a66641c59926dcfa5e2130479a4.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object i0 {
def i1(i2: Any, i3: Any, i4: Any => Any) = (i5, i4)
def i6(i5: List[Int]): Int = i6 match {
case _: String @_*i6 match { case _: i7.type
8
4 changes: 4 additions & 0 deletions tests/fuzzy/37e5de7d6a0fa8cc9123fd570d9fd82d1fc5767f.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object App {
def this(i0: Int = 100) = {
val i1: i0 = 1; case _ => i2(i1) }
}
17 changes: 17 additions & 0 deletions tests/fuzzy/39bf335240b828efaa825fa242422f0eaa6d7ca2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
object i0 {
type i1 = (=> Int) | (2 => i2)("i3 i4{i5} i6 = i4;
case (i4, i5) => ()
i6
} def main(i4: Array[String]): Unit = {
val i5 = * i6
i5
} else
i6
}
})
object i7 {
import i0.{ classTag, i3 } & (2 -> filter*) }
def i7(i2: Int): i0
val i5 = _
i7 = i0
})
24 changes: 24 additions & 0 deletions tests/fuzzy/3cd12b064ca064177c035ef58d3a9cbe90980d7e.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
object i0 {
def i1 = 2
}
trait i2 extends AnyRef {
private object i2 extends i0
trait i1 {
private def i2: Int = 1 implicitly[Int]
}
} final type i3 {
new implicitly[i0, i4]
type i5 = (i5: i0[Int, Nil[i2]], i4: String): Stream[i1 <: Nil] => i2[i0]
}
val i5 = {
implicitly["": i5 with AnyVal] { (i5: Int
object i0 {
def scala[i1](i2: i3.RuntimeException) = {
def this() = this() }
implicit lazy val i4: String =}[i1] {
def i5: Unit =
i4() match { case i3 => 0.map() = this match {
case _ =>
}
}
}
Loading