@@ -12,8 +12,8 @@ import java.util.stream.{ Stream => JStream }
1212import scala .collection .JavaConverters ._
1313import scala .util .matching .Regex
1414import scala .concurrent .duration ._
15+ import TestSources .sources
1516import vulpix ._
16- import dotty .tools .io .JFile
1717
1818class CompilationTests extends ParallelTesting {
1919 import ParallelTesting ._
@@ -34,12 +34,12 @@ class CompilationTests extends ParallelTesting {
3434 // @Test // enable to test compileStdLib separately with detailed stats
3535 def compileStdLibOnly : Unit = {
3636 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" ))
3838 }.checkCompile()
3939
4040 @ Test def pos : Unit = {
4141 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" )) +
4343 compileFile(" tests/pos/nullarify.scala" , defaultOptions.and(" -Ycheck:nullarify" )) +
4444 compileFile(" tests/pos-scala2/rewrites.scala" , scala2Mode.and(" -rewrite" )).copyToTarget() +
4545 compileFile(" tests/pos-special/utf8encoded.scala" , explicitUTF8) +
@@ -232,17 +232,16 @@ class CompilationTests extends ParallelTesting {
232232 )
233233
234234 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(_ ))
236236
237237 val lib =
238238 compileList(" src" , librarySources,
239239 defaultOptions.and(" -Ycheck-reentrant" , " -strict" , " -priorityclasspath" , defaultOutputDir))(libGroup)
240240
241- val compilerDir = Paths .get(" compiler/src" )
242- val compilerSources = sources(Files .walk(compilerDir))
241+ val compilerSources = sources(Paths .get(" compiler/src" ))
243242
244243 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 )
246245
247246 val dotty1 = compileList(" dotty" , compilerSources ++ scalaJSIRSources, opt)(dotty1Group)
248247 val dotty2 = compileList(" dotty" , compilerSources ++ scalaJSIRSources, opt)(dotty2Group)
@@ -267,9 +266,10 @@ class CompilationTests extends ParallelTesting {
267266 }.keepOutput :: Nil
268267 }.map(_.checkCompile())
269268
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/ " )
273273 compileList(" idempotency" , List (" tests/idempotency/BootstrapChecker.scala" , " tests/idempotency/IdempotencyCheck.scala" ), defaultOptions).checkRuns()
274274
275275 tests.foreach(_.delete())
@@ -282,17 +282,13 @@ class CompilationTests extends ParallelTesting {
282282 // 2. copy `pluginFile` to destination
283283 def compileFilesInDir (dir : String ): CompilationTest = {
284284 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)
290286
287+ val dirs = sourceDir.listFiles.toList.filter(_.isDirectory)
291288 val targets = dirs.map { dir =>
292289 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)
296292 SeparateCompilationSource (" testPlugins" , dir, flags, compileDir)
297293 }
298294
@@ -306,15 +302,4 @@ class CompilationTests extends ParallelTesting {
306302object CompilationTests {
307303 implicit val summaryReport : SummaryReporting = new SummaryReport
308304 @ 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- }
320305}
0 commit comments