Skip to content

[Vulpix] Abort compilation after maxCompileTime #2318

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

Closed
Closed
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
1 change: 1 addition & 0 deletions compiler/test/dotc/comptest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import scala.concurrent.duration._
object comptest extends ParallelTesting {

def maxDuration = 3.seconds
def maxCompileTime = 1.minute
def numberOfSlaves = 5
def safeMode = false
def isInteractive = true
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CompilationTests extends ParallelTesting {

// Test suite configuration --------------------------------------------------

def maxCompileTime = 9.minutes
def maxDuration = 30.seconds
def numberOfSlaves = 5
def safeMode = Properties.testsSafeMode
Expand Down
13 changes: 12 additions & 1 deletion compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import scala.util.Try
import scala.collection.mutable
import scala.util.matching.Regex
import scala.util.Random
import scala.concurrent.duration.Duration
import scala.concurrent.{ Await, Future }
import scala.concurrent.ExecutionContext.Implicits.global

import dotc.core.Contexts._
import dotc.reporting.{ Reporter, TestReporter }
Expand Down Expand Up @@ -44,6 +47,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
*/
def testFilter: Option[String]

/** To ensure that compilation is not run infinitely, we await it for this
* duration
*/
def maxCompileTime: Duration

/** A test source whose files or directory of files is to be compiled
* in a specific way defined by the `Test`
*/
Expand Down Expand Up @@ -373,13 +381,16 @@ trait ParallelTesting extends RunnerOrchestration { self =>
val allArgs = addOutDir(flags)

// Compile with a try to catch any StackTrace generated by the compiler:
try {
val compilation = Future {
driver.process(allArgs ++ files.map(_.getAbsolutePath), reporter = reporter)

val javaFiles = files.filter(_.getName.endsWith(".java")).map(_.getAbsolutePath)
assert(compileWithJavac(javaFiles), s"java compilation failed for ${javaFiles.mkString(", ")}")
}

try Await.result(compilation, maxCompileTime)
catch {
case ex: TimeoutException => throw ex
case NonFatal(ex) => reporter.logStackTrace(ex)
}

Expand Down
7 changes: 7 additions & 0 deletions compiler/test/dotty/tools/vulpix/VulpixTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class VulpixTests extends ParallelTesting {
implicit val _: SummaryReporting = new NoSummaryReport

def maxDuration = 3.seconds
def maxCompileTime= 10.seconds
def numberOfSlaves = 5
def safeMode = sys.env.get("SAFEMODE").isDefined
def isInteractive = !sys.env.contains("DRONE")
Expand Down Expand Up @@ -73,4 +74,10 @@ class VulpixTests extends ParallelTesting {

@Test def deadlock: Unit =
compileFile("../tests/partest-test/deadlock.scala", defaultOptions).expectFailure.checkRuns()

/** We alow for maximum 10 seconds of compile time, compiling the standard
* library takes a biiiit longer (> 30 seconds)
*/
@Test def infiniteCompile: Unit =
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline")).expectFailure.checkCompile()
}