-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathBootstrappedOnlyCompilationTests.scala
229 lines (201 loc) · 9.94 KB
/
BootstrappedOnlyCompilationTests.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
package dotty
package tools
package dotc
import scala.language.unsafeNulls
import org.junit.{ Test, BeforeClass, AfterClass }
import org.junit.Assert._
import org.junit.Assume._
import org.junit.experimental.categories.Category
import scala.concurrent.duration._
import reporting.TestReporter
import vulpix._
import java.nio.file._
@Category(Array(classOf[BootstrappedOnlyTests]))
class BootstrappedOnlyCompilationTests {
import ParallelTesting._
import TestConfiguration._
import BootstrappedOnlyCompilationTests._
import CompilationTest.aggregateTests
// Positive tests ------------------------------------------------------------
@Test def posMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("compilePosMacros")
aggregateTests(
compileFilesInDir("tests/bench", defaultOptions.without("-Yno-deep-subtypes")),
compileFilesInDir("tests/pos-macros", defaultOptions.and("-Xcheck-macros")),
).checkCompile()
}
@Test def posWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("compilePosWithCompiler")
aggregateTests(
compileFilesInDir("tests/pos-with-compiler", withCompilerOptions),
compileFilesInDir("tests/pos-staging", withStagingOptions),
compileDir("compiler/src/dotty/tools/dotc/ast", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/config", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/core", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/transform", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/parsing", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/printing", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/reporting", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/typer", withCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/util", withCompilerOptions),
compileDir("compiler/src/dotty/tools/io", withCompilerOptions),
compileDir("tasty/src/dotty/tools/tasty", withCompilerOptions),
compileList(
"testIssue6460",
List(
"compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala",
"compiler/src/dotty/tools/dotc/core/Types.scala"
),
withCompilerOptions
),
compileList(
"testIssue6603",
List(
"compiler/src/dotty/tools/dotc/ast/Desugar.scala",
"compiler/src/dotty/tools/dotc/ast/Trees.scala",
"compiler/src/dotty/tools/dotc/core/Types.scala"
),
withCompilerOptions
),
).checkCompile()
}
@Test def posTwiceWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("posTwiceWithCompiler")
aggregateTests(
compileFile("tests/pos-with-compiler/Labels.scala", withCompilerOptions),
compileFile("tests/pos-with-compiler/Patterns.scala", withCompilerOptions),
compileList(
"testNonCyclic",
List(
"compiler/src/dotty/tools/dotc/CompilationUnit.scala",
"compiler/src/dotty/tools/dotc/core/Types.scala",
"compiler/src/dotty/tools/dotc/ast/Trees.scala"
),
withCompilerOptions
),
compileList(
"testIssue34",
List(
"compiler/src/dotty/tools/dotc/config/Properties.scala",
"compiler/src/dotty/tools/dotc/config/PathResolver.scala"
),
withCompilerOptions
)
).times(2).checkCompile()
}
// Negative tests ------------------------------------------------------------
@Test def negMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
compileFilesInDir("tests/neg-macros", defaultOptions.and("-Xcheck-macros"))
.checkExpectedErrors()
}
@Test def negWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
aggregateTests(
compileFilesInDir("tests/neg-with-compiler", withCompilerOptions),
compileFilesInDir("tests/neg-staging", withStagingOptions),
).checkExpectedErrors()
}
// Run tests -----------------------------------------------------------------
@Test def runMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("runMacros")
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"), FileFilter.exclude(TestSources.runMacrosScala2LibraryTastyBlacklisted))
.checkRuns()
}
@Test def runWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
val basicTests = List(
compileFilesInDir("tests/run-with-compiler", withCompilerOptions),
compileFilesInDir("tests/run-staging", withStagingOptions),
compileFilesInDir("tests/run-tasty-inspector", withTastyInspectorOptions)
)
val tests =
if scala.util.Properties.isWin then basicTests
else compileDir("tests/old-tasty-interpreter-prototype", withTastyInspectorOptions) :: basicTests
aggregateTests(tests*).checkRuns()
}
@Test def runScala2LibraryFromTasty: Unit = {
implicit val testGroup: TestGroup = TestGroup("runScala2LibraryFromTasty")
// These tests recompile the entire scala2-library from TASTy,
// they are resource intensive and should not run alongside other tests to avoid timeouts
aggregateTests(
compileFile("tests/run-custom-args/scala2-library-from-tasty-jar.scala", withCompilerOptions),
compileFile("tests/run-custom-args/scala2-library-from-tasty.scala", withCompilerOptions),
).limitThreads(2).checkRuns() // TODO reduce to limitThreads(1) if it still causes problems, this would be around 50% slower based on local benchmarking
}
@Test def runBootstrappedOnly: Unit = {
implicit val testGroup: TestGroup = TestGroup("runBootstrappedOnly")
aggregateTests(
compileFilesInDir("tests/run-bootstrapped", withCompilerOptions),
).checkRuns()
}
// Pickling Tests ------------------------------------------------------------
//
// Pickling tests are very memory intensive and as such need to be run with a
// lower level of concurrency as to not kill their running VMs
@Test def picklingWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("testPicklingWithCompiler")
aggregateTests(
compileDir("compiler/src/dotty/tools", picklingWithCompilerOptions, recursive = false),
compileDir("compiler/src/dotty/tools/dotc", picklingWithCompilerOptions, recursive = false),
compileDir("library/src/scala/runtime/function", picklingWithCompilerOptions),
compileFilesInDir("library/src/scala/runtime", picklingWithCompilerOptions),
compileFilesInDir("compiler/src/dotty/tools/backend/jvm", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/ast", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/core", picklingWithCompilerOptions, recursive = false),
compileDir("compiler/src/dotty/tools/dotc/config", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/parsing", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/printing", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/repl", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/rewrites", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/transform", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/typer", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/util", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/io", picklingWithCompilerOptions),
compileFile("tests/pos/pickleinf.scala", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/core/classfile", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/core/tasty", picklingWithCompilerOptions),
compileDir("compiler/src/dotty/tools/dotc/core/unpickleScala2", picklingWithCompilerOptions),
compileDir("tasty/src/dotty/tools/tasty", picklingWithCompilerOptions)
).limitThreads(4).checkCompile()
}
@Test def testPlugins: Unit = {
implicit val testGroup: TestGroup = TestGroup("testPlugins")
val pluginFile = "plugin.properties"
// 1. hack with absolute path for -Xplugin
// 2. copy `pluginFile` to destination
def compileFilesInDir(dir: String, run: Boolean = false): CompilationTest = {
val outDir = defaultOutputDir + "testPlugins/"
val sourceDir = new java.io.File(dir)
val dirs = sourceDir.listFiles.toList.filter(_.isDirectory)
val targets = dirs.map { dir =>
val compileDir = createOutputDirsForDir(dir, sourceDir, outDir)
Files.copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), StandardCopyOption.REPLACE_EXISTING)
val flags = {
val base = TestFlags(withCompilerClasspath, noCheckOptions).and("-Xplugin:" + compileDir.getAbsolutePath)
if run then base.withRunClasspath(withCompilerClasspath) else base
}
SeparateCompilationSource("testPlugins", dir, flags, compileDir)
}
new CompilationTest(targets)
}
compileFilesInDir("tests/plugins/neg").checkExpectedErrors()
compileDir("tests/plugins/custom/analyzer", withCompilerOptions.and("-Yretain-trees")).checkCompile()
compileFilesInDir("tests/plugins/run", run = true).checkRuns()
}
}
object BootstrappedOnlyCompilationTests extends ParallelTesting {
// Test suite configuration --------------------------------------------------
def maxDuration = 100.seconds
def numberOfSlaves = Runtime.getRuntime().availableProcessors()
def safeMode = Properties.testsSafeMode
def isInteractive = SummaryReport.isInteractive
def testFilter = Properties.testsFilter
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
def failedTests = TestReporter.lastRunFailedTests
implicit val summaryReport: SummaryReporting = new SummaryReport
@AfterClass def tearDown(): Unit = {
super.cleanup()
summaryReport.echoSummary()
}
}