|
| 1 | +package dotty |
| 2 | +package tools |
| 3 | +package dotc |
| 4 | + |
| 5 | +import org.junit.{ Test, BeforeClass, AfterClass } |
| 6 | +import org.junit.Assert._ |
| 7 | +import org.junit.Assume._ |
| 8 | +import org.junit.experimental.categories.Category |
| 9 | + |
| 10 | +import java.io.File |
| 11 | +import java.nio.file._ |
| 12 | +import java.util.stream.{ Stream => JStream } |
| 13 | +import scala.collection.JavaConverters._ |
| 14 | +import scala.util.matching.Regex |
| 15 | +import scala.concurrent.duration._ |
| 16 | +import TestSources.sources |
| 17 | +import vulpix._ |
| 18 | + |
| 19 | +class TastyBootstrapTests { |
| 20 | + import ParallelTesting._ |
| 21 | + import TestConfiguration._ |
| 22 | + import CompilationTests._ |
| 23 | + import CompilationTest.aggregateTests |
| 24 | + |
| 25 | + /** The purpose of this test is three-fold, being able to compile dotty |
| 26 | + * bootstrapped, and making sure that TASTY can link against a compiled |
| 27 | + * version of Dotty, and compiling the compiler using the SemanticDB generation |
| 28 | + */ |
| 29 | + @Test def tastyBootstrap: Unit = { |
| 30 | + implicit val testGroup: TestGroup = TestGroup("tastyBootstrap/tests") |
| 31 | + val libGroup = TestGroup("tastyBootstrap/lib") |
| 32 | + val tastyCoreGroup = TestGroup("tastyBootstrap/tastyCore") |
| 33 | + val dotty1Group = TestGroup("tastyBootstrap/dotty1") |
| 34 | + val dotty2Group = TestGroup("tastyBootstrap/dotty2") |
| 35 | + |
| 36 | + // Make sure that the directory is clean |
| 37 | + dotty.tools.io.Directory(defaultOutputDir + "tastyBootstrap").deleteRecursively() |
| 38 | + |
| 39 | + val opt = TestFlags( |
| 40 | + List( |
| 41 | + // compile with bootstrapped library on cp: |
| 42 | + defaultOutputDir + libGroup + "/lib/", |
| 43 | + // and bootstrapped tasty-core: |
| 44 | + defaultOutputDir + tastyCoreGroup + "/tastyCore/", |
| 45 | + // as well as bootstrapped compiler: |
| 46 | + defaultOutputDir + dotty1Group + "/dotty1/", |
| 47 | + // and the other compiler dependencies: |
| 48 | + Properties.compilerInterface, Properties.scalaLibrary, Properties.scalaAsm, |
| 49 | + Properties.dottyInterfaces, Properties.jlineTerminal, Properties.jlineReader, |
| 50 | + ).mkString(File.pathSeparator), |
| 51 | + Array("-Ycheck-reentrant", "-language:postfixOps", "-Xsemanticdb") |
| 52 | + ) |
| 53 | + |
| 54 | + val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped")) |
| 55 | + val librarySources = libraryDirs.flatMap(sources(_)) |
| 56 | + |
| 57 | + val lib = |
| 58 | + compileList("lib", librarySources, |
| 59 | + defaultOptions.and("-Ycheck-reentrant", |
| 60 | + "-language:experimental.erasedDefinitions", // support declaration of scala.compiletime.erasedValue |
| 61 | + // "-source", "future", // TODO: re-enable once we allow : @unchecked in pattern definitions. Right now, lots of narrowing pattern definitions fail. |
| 62 | + ))(libGroup) |
| 63 | + |
| 64 | + val tastyCoreSources = sources(Paths.get("tasty/src")) |
| 65 | + val tastyCore = compileList("tastyCore", tastyCoreSources, opt)(tastyCoreGroup) |
| 66 | + |
| 67 | + val compilerSources = sources(Paths.get("compiler/src")) ++ sources(Paths.get("compiler/src-bootstrapped")) |
| 68 | + val compilerManagedSources = Properties.dottyCompilerManagedSources match |
| 69 | + case p if Files.isDirectory(p) => sources(p) |
| 70 | + case _ => Nil |
| 71 | + |
| 72 | + val dotty1 = compileList("dotty1", compilerSources ++ compilerManagedSources, opt)(dotty1Group) |
| 73 | + val dotty2 = compileList("dotty2", compilerSources ++ compilerManagedSources, opt)(dotty2Group) |
| 74 | + |
| 75 | + val tests = { |
| 76 | + lib.keepOutput :: tastyCore.keepOutput :: dotty1.keepOutput :: aggregateTests( |
| 77 | + dotty2, |
| 78 | + compileShallowFilesInDir("compiler/src/dotty/tools", opt), |
| 79 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc", opt), |
| 80 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/ast", opt), |
| 81 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/config", opt), |
| 82 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/parsing", opt), |
| 83 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/printing", opt), |
| 84 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/reporting", opt), |
| 85 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/rewrites", opt), |
| 86 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/transform", opt), |
| 87 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/typer", opt), |
| 88 | + compileShallowFilesInDir("compiler/src/dotty/tools/dotc/util", opt), |
| 89 | + compileShallowFilesInDir("compiler/src/dotty/tools/backend", opt), |
| 90 | + compileShallowFilesInDir("compiler/src/dotty/tools/backend/jvm", opt), |
| 91 | + compileList("managed-sources", compilerManagedSources, opt) |
| 92 | + ).keepOutput :: Nil |
| 93 | + }.map(_.checkCompile()) |
| 94 | + |
| 95 | + def assertExists(path: String) = assertTrue(Files.exists(Paths.get(path))) |
| 96 | + assertExists(s"out/$libGroup/lib/") |
| 97 | + assertExists(s"out/$tastyCoreGroup/tastyCore/") |
| 98 | + assertExists(s"out/$dotty1Group/dotty1/") |
| 99 | + assertExists(s"out/$dotty2Group/dotty2/") |
| 100 | + compileList("idempotency", List("tests/idempotency/BootstrapChecker.scala", "tests/idempotency/IdempotencyCheck.scala"), defaultOptions).checkRuns() |
| 101 | + |
| 102 | + tests.foreach(_.delete()) |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +object TastyBootstrapTests extends ParallelTesting { |
| 107 | + // Test suite configuration -------------------------------------------------- |
| 108 | + |
| 109 | + def maxDuration = 45.seconds |
| 110 | + def numberOfSlaves = Runtime.getRuntime.availableProcessors() |
| 111 | + def safeMode = Properties.testsSafeMode |
| 112 | + def isInteractive = SummaryReport.isInteractive |
| 113 | + def testFilter = Properties.testsFilter |
| 114 | + def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile |
| 115 | + |
| 116 | + implicit val summaryReport: SummaryReporting = new SummaryReport |
| 117 | + @AfterClass def tearDown(): Unit = { |
| 118 | + super.cleanup() |
| 119 | + summaryReport.echoSummary() |
| 120 | + } |
| 121 | +} |
0 commit comments