@@ -12,8 +12,8 @@ import java.util.stream.{ Stream => JStream }
12
12
import scala .collection .JavaConverters ._
13
13
import scala .util .matching .Regex
14
14
import scala .concurrent .duration ._
15
+ import TestSources .sources
15
16
import vulpix ._
16
- import dotty .tools .io .JFile
17
17
18
18
class CompilationTests extends ParallelTesting {
19
19
import ParallelTesting ._
@@ -34,12 +34,12 @@ class CompilationTests extends ParallelTesting {
34
34
// @Test // enable to test compileStdLib separately with detailed stats
35
35
def compileStdLibOnly : Unit = {
36
36
implicit val testGroup : TestGroup = TestGroup (" compileStdLibOnly" )
37
- compileList(" compileStdLib" , TestSources .stdLibWhitelisted , scala2Mode.and(" -migration" , " -Yno-inline" , " -Ydetailed-stats" ))
37
+ compileList(" compileStdLib" , TestSources .stdLibSources , scala2Mode.and(" -migration" , " -Yno-inline" , " -Ydetailed-stats" ))
38
38
}.checkCompile()
39
39
40
40
@ Test def pos : Unit = {
41
41
implicit val testGroup : TestGroup = TestGroup (" compilePos" )
42
- compileList(" compileStdLib" , TestSources .stdLibWhitelisted , scala2Mode.and(" -migration" , " -Yno-inline" )) +
42
+ compileList(" compileStdLib" , TestSources .stdLibSources , scala2Mode.and(" -migration" , " -Yno-inline" )) +
43
43
compileFile(" tests/pos/nullarify.scala" , defaultOptions.and(" -Ycheck:nullarify" )) +
44
44
compileFile(" tests/pos-scala2/rewrites.scala" , scala2Mode.and(" -rewrite" )).copyToTarget() +
45
45
compileFile(" tests/pos-special/utf8encoded.scala" , explicitUTF8) +
@@ -232,17 +232,16 @@ class CompilationTests extends ParallelTesting {
232
232
)
233
233
234
234
val libraryDirs = List (Paths .get(" library/src" ), Paths .get(" library/src-bootstrapped" ))
235
- val librarySources = libraryDirs.flatMap(d => sources(Files .walk(d) ))
235
+ val librarySources = libraryDirs.flatMap(sources(_ ))
236
236
237
237
val lib =
238
238
compileList(" src" , librarySources,
239
239
defaultOptions.and(" -Ycheck-reentrant" , " -strict" , " -priorityclasspath" , defaultOutputDir))(libGroup)
240
240
241
- val compilerDir = Paths .get(" compiler/src" )
242
- val compilerSources = sources(Files .walk(compilerDir))
241
+ val compilerSources = sources(Paths .get(" compiler/src" ))
243
242
244
243
val scalaJSIRDir = Paths .get(" compiler/target/scala-2.12/src_managed/main/scalajs-ir-src/org/scalajs/ir" )
245
- val scalaJSIRSources = sources(Files .list( scalaJSIRDir) )
244
+ val scalaJSIRSources = sources(scalaJSIRDir, shallow = true )
246
245
247
246
val dotty1 = compileList(" dotty" , compilerSources ++ scalaJSIRSources, opt)(dotty1Group)
248
247
val dotty2 = compileList(" dotty" , compilerSources ++ scalaJSIRSources, opt)(dotty2Group)
@@ -267,9 +266,10 @@ class CompilationTests extends ParallelTesting {
267
266
}.keepOutput :: Nil
268
267
}.map(_.checkCompile())
269
268
270
- assert(new java.io.File (s " out/ $dotty1Group/dotty/ " ).exists)
271
- assert(new java.io.File (s " out/ $dotty2Group/dotty/ " ).exists)
272
- assert(new java.io.File (s " out/ $libGroup/src/ " ).exists)
269
+ def assertExists (path : String ) = assertTrue(Files .exists(Paths .get(path)))
270
+ assertExists(s " out/ $dotty1Group/dotty/ " )
271
+ assertExists(s " out/ $dotty2Group/dotty/ " )
272
+ assertExists(s " out/ $libGroup/src/ " )
273
273
compileList(" idempotency" , List (" tests/idempotency/BootstrapChecker.scala" , " tests/idempotency/IdempotencyCheck.scala" ), defaultOptions).checkRuns()
274
274
275
275
tests.foreach(_.delete())
@@ -282,17 +282,13 @@ class CompilationTests extends ParallelTesting {
282
282
// 2. copy `pluginFile` to destination
283
283
def compileFilesInDir (dir : String ): CompilationTest = {
284
284
val outDir = defaultOutputDir + " testPlugins/"
285
- val sourceDir = new JFile (dir)
286
-
287
- val dirs = sourceDir.listFiles.foldLeft(List .empty[JFile ]) { case (dirs, f) =>
288
- if (f.isDirectory) f :: dirs else dirs
289
- }
285
+ val sourceDir = new java.io.File (dir)
290
286
287
+ val dirs = sourceDir.listFiles.toList.filter(_.isDirectory)
291
288
val targets = dirs.map { dir =>
292
289
val compileDir = createOutputDirsForDir(dir, sourceDir, outDir)
293
- import java .nio .file .StandardCopyOption .REPLACE_EXISTING
294
- Files .copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), REPLACE_EXISTING )
295
- val flags = TestFlags (withCompilerClasspath, noCheckOptions) and (" -Xplugin:" + compileDir.getAbsolutePath)
290
+ Files .copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), StandardCopyOption .REPLACE_EXISTING )
291
+ val flags = TestFlags (withCompilerClasspath, noCheckOptions).and(" -Xplugin:" + compileDir.getAbsolutePath)
296
292
SeparateCompilationSource (" testPlugins" , dir, flags, compileDir)
297
293
}
298
294
@@ -306,15 +302,4 @@ class CompilationTests extends ParallelTesting {
306
302
object CompilationTests {
307
303
implicit val summaryReport : SummaryReporting = new SummaryReport
308
304
@ AfterClass def cleanup (): Unit = summaryReport.echoSummary()
309
-
310
- def sources (paths : JStream [Path ], excludedFiles : List [String ] = Nil ): List [String ] = {
311
- val sources = paths.iterator().asScala
312
- .filter(path =>
313
- (path.toString.endsWith(" .scala" ) || path.toString.endsWith(" .java" ))
314
- && ! excludedFiles.contains(path.getFileName.toString))
315
- .map(_.toString).toList
316
-
317
- paths.close()
318
- sources
319
- }
320
305
}
0 commit comments