Skip to content

Instantly share code, notes, and snippets.

@milessabin
Last active October 6, 2018 18:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save milessabin/830ffc50a02bc11fb33504ce78ab39dc to your computer and use it in GitHub Desktop.
Save milessabin/830ffc50a02bc11fb33504ce78ab39dc to your computer and use it in GitHub Desktop.
Setup for local integration (ie. compile pos/neg/run) tests for lampepfl/dotty
import Build._
import Modes._
addCommandAlias("local-tests", "local-tests/test")
lazy val `local-tests` = project.in(file("local") / "localtests")
.asDottyCompiler(NonBootstrapped)
.dependsOn(`dotty-compiler` % "compile->compile;test->test")
.settings(Seq(
baseDirectory in (Compile, run) := baseDirectory.value / ".." / "..",
baseDirectory in Test := baseDirectory.value / ".." / ".."
))
// local/localtests/test/localtests/LocalTests.scala
package localtests
import java.nio.file._
import java.util.stream.{ Stream => JStream }
import org.junit.{ AfterClass, Test }
import scala.collection.JavaConverters._
import scala.concurrent.duration._
import dotty.Properties
import dotty.tools.dotc.CompilationTests
import dotty.tools.vulpix._
class LocalCompilationTests extends ParallelTesting {
import TestConfiguration._
import LocalCompilationTests._
// Test suite configuration --------------------------------------------------
def maxDuration = 30.seconds
def numberOfSlaves = 5
def safeMode = Properties.testsSafeMode
def isInteractive = false // SummaryReport.isInteractive
def testFilter = Properties.testsFilter
@Test def pos: Unit = {
implicit val testGroup: TestGroup = TestGroup("pos")
compileFile("tests/pos/byname-implicits-1.scala", defaultOptions.and(
"-Xmin-implicit-search-depth", "10"
))
}.checkCompile()
@Test def neg: Unit = {
implicit val testGroup: TestGroup = TestGroup("neg")
compileFile("tests/neg/implicitDivergenc.scala", defaultOptions.and(
"-Xmin-implicit-search-depth", "5"
))
}.checkExpectedErrors()
}
object LocalCompilationTests {
implicit val summaryReport: SummaryReporting = new SummaryReport
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
def sources(paths: JStream[Path], excludedFiles: List[String] = Nil): List[String] = {
val sources = paths.iterator().asScala
.filter(path =>
(path.toString.endsWith(".scala") || path.toString.endsWith(".java"))
&& !excludedFiles.contains(path.getFileName.toString))
.map(_.toString).toList
paths.close()
sources
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment