Skip to content

Commit a028ffb

Browse files
committed
Move tastyBootstrap to a new test file
The test "tastyBootstrap" is different to the rest of the compilation tests because it actually recompiles the compiler sources, which can interfer when using CompilationTests.
1 parent 6565219 commit a028ffb

File tree

2 files changed

+121
-78
lines changed

2 files changed

+121
-78
lines changed

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

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -232,84 +232,6 @@ class CompilationTests {
232232
).checkCompile()
233233
}
234234

235-
/** The purpose of this test is three-fold, being able to compile dotty
236-
* bootstrapped, and making sure that TASTY can link against a compiled
237-
* version of Dotty, and compiling the compiler using the SemanticDB generation
238-
*/
239-
@Test def tastyBootstrap: Unit = {
240-
implicit val testGroup: TestGroup = TestGroup("tastyBootstrap/tests")
241-
val libGroup = TestGroup("tastyBootstrap/lib")
242-
val tastyCoreGroup = TestGroup("tastyBootstrap/tastyCore")
243-
val dotty1Group = TestGroup("tastyBootstrap/dotty1")
244-
val dotty2Group = TestGroup("tastyBootstrap/dotty2")
245-
246-
// Make sure that the directory is clean
247-
dotty.tools.io.Directory(defaultOutputDir + "tastyBootstrap").deleteRecursively()
248-
249-
val opt = TestFlags(
250-
List(
251-
// compile with bootstrapped library on cp:
252-
defaultOutputDir + libGroup + "/lib/",
253-
// and bootstrapped tasty-core:
254-
defaultOutputDir + tastyCoreGroup + "/tastyCore/",
255-
// as well as bootstrapped compiler:
256-
defaultOutputDir + dotty1Group + "/dotty1/",
257-
// and the other compiler dependencies:
258-
Properties.compilerInterface, Properties.scalaLibrary, Properties.scalaAsm,
259-
Properties.dottyInterfaces, Properties.jlineTerminal, Properties.jlineReader,
260-
).mkString(File.pathSeparator),
261-
Array("-Ycheck-reentrant", "-language:postfixOps", "-Xsemanticdb")
262-
)
263-
264-
val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped"))
265-
val librarySources = libraryDirs.flatMap(sources(_))
266-
267-
val lib =
268-
compileList("lib", librarySources,
269-
defaultOptions.and("-Ycheck-reentrant",
270-
"-language:experimental.erasedDefinitions", // support declaration of scala.compiletime.erasedValue
271-
// "-source", "future", // TODO: re-enable once we allow : @unchecked in pattern definitions. Right now, lots of narrowing pattern definitions fail.
272-
))(libGroup)
273-
274-
val tastyCoreSources = sources(Paths.get("tasty/src"))
275-
val tastyCore = compileList("tastyCore", tastyCoreSources, opt)(tastyCoreGroup)
276-
277-
val compilerSources = sources(Paths.get("compiler/src")) ++ sources(Paths.get("compiler/src-bootstrapped"))
278-
val compilerManagedSources = sources(Properties.dottyCompilerManagedSources)
279-
280-
val dotty1 = compileList("dotty1", compilerSources ++ compilerManagedSources, opt)(dotty1Group)
281-
val dotty2 = compileList("dotty2", compilerSources ++ compilerManagedSources, opt)(dotty2Group)
282-
283-
val tests = {
284-
lib.keepOutput :: tastyCore.keepOutput :: dotty1.keepOutput :: aggregateTests(
285-
dotty2,
286-
compileShallowFilesInDir("compiler/src/dotty/tools", opt),
287-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc", opt),
288-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/ast", opt),
289-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/config", opt),
290-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/parsing", opt),
291-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/printing", opt),
292-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/reporting", opt),
293-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/rewrites", opt),
294-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/transform", opt),
295-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/typer", opt),
296-
compileShallowFilesInDir("compiler/src/dotty/tools/dotc/util", opt),
297-
compileShallowFilesInDir("compiler/src/dotty/tools/backend", opt),
298-
compileShallowFilesInDir("compiler/src/dotty/tools/backend/jvm", opt),
299-
compileList("managed-sources", compilerManagedSources, opt)
300-
).keepOutput :: Nil
301-
}.map(_.checkCompile())
302-
303-
def assertExists(path: String) = assertTrue(Files.exists(Paths.get(path)))
304-
assertExists(s"out/$libGroup/lib/")
305-
assertExists(s"out/$tastyCoreGroup/tastyCore/")
306-
assertExists(s"out/$dotty1Group/dotty1/")
307-
assertExists(s"out/$dotty2Group/dotty2/")
308-
compileList("idempotency", List("tests/idempotency/BootstrapChecker.scala", "tests/idempotency/IdempotencyCheck.scala"), defaultOptions).checkRuns()
309-
310-
tests.foreach(_.delete())
311-
}
312-
313235
// Explicit nulls tests
314236
@Test def explicitNullsNeg: Unit = {
315237
implicit val testGroup: TestGroup = TestGroup("explicitNullsNeg")
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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

Comments
 (0)