@@ -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
1818
1919class CompilationTests extends 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) +
@@ -218,14 +218,14 @@ class CompilationTests extends ParallelTesting {
218218 )
219219
220220 val libraryDirs = List (Paths .get(" library/src" ), Paths .get(" library/src-bootstrapped" ))
221- val librarySources = libraryDirs.flatMap(d => sources(Files .walk(d) ))
221+ val librarySources = libraryDirs.flatMap(sources(_ ))
222222
223223 val lib =
224224 compileList(" src" , librarySources,
225225 defaultOptions.and(" -Ycheck-reentrant" , " -strict" , " -priorityclasspath" , defaultOutputDir))(libGroup)
226226
227227 val compilerDir = Paths .get(" compiler/src" )
228- val compilerSources = sources(Files .walk( compilerDir) )
228+ val compilerSources = sources(compilerDir)
229229
230230 val backendDir = Paths .get(" scala-backend/src/compiler/scala/tools/nsc/backend" )
231231 val backendJvmDir = Paths .get(" scala-backend/src/compiler/scala/tools/nsc/backend/jvm" )
@@ -238,11 +238,11 @@ class CompilationTests extends ParallelTesting {
238238 List (" BCodeICodeCommon.scala" , " GenASM.scala" , " GenBCode.scala" , " ScalacBackendInterface.scala" , " BackendStats.scala" , " BCodeAsmEncode.scala" )
239239
240240 val backendSources =
241- sources(Files .list( backendDir) , excludedFiles = backendExcluded)
241+ sources(backendDir, excludedFiles = backendExcluded, shallow = true )
242242 val backendJvmSources =
243- sources(Files .list( backendJvmDir) , excludedFiles = backendJvmExcluded)
243+ sources(backendJvmDir, excludedFiles = backendJvmExcluded, shallow = true )
244244 val scalaJSIRSources =
245- sources(Files .list( scalaJSIRDir) )
245+ sources(scalaJSIRDir, shallow = true )
246246
247247 val dotty1 = compileList(" dotty" , compilerSources ++ backendSources ++ backendJvmSources ++ scalaJSIRSources, opt)(dotty1Group)
248248 val dotty2 = compileList(" dotty" , compilerSources ++ backendSources ++ backendJvmSources ++ scalaJSIRSources, opt)(dotty2Group)
@@ -267,9 +267,10 @@ class CompilationTests extends ParallelTesting {
267267 }.keepOutput :: Nil
268268 }.map(_.checkCompile())
269269
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)
270+ def assertExists (path : String ) = assertTrue(Files .exists(Paths .get(path)))
271+ assertExists(s " out/ $dotty1Group/dotty/ " )
272+ assertExists(s " out/ $dotty2Group/dotty/ " )
273+ assertExists(s " out/ $libGroup/src/ " )
273274 compileList(" idempotency" , List (" tests/idempotency/BootstrapChecker.scala" , " tests/idempotency/IdempotencyCheck.scala" ), defaultOptions).checkRuns()
274275
275276 tests.foreach(_.delete())
@@ -282,17 +283,13 @@ class CompilationTests extends ParallelTesting {
282283 // 2. copy `pluginFile` to destination
283284 def compileFilesInDir (dir : String ): CompilationTest = {
284285 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- }
286+ val sourceDir = new java.io.File (dir)
290287
288+ val dirs = sourceDir.listFiles.toList.filter(_.isDirectory)
291289 val targets = dirs.map { dir =>
292290 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)
291+ Files .copy(dir.toPath.resolve(pluginFile), compileDir.toPath.resolve(pluginFile), StandardCopyOption .REPLACE_EXISTING )
292+ val flags = TestFlags (withCompilerClasspath, noCheckOptions).and(" -Xplugin:" + compileDir.getAbsolutePath)
296293 SeparateCompilationSource (" testPlugins" , dir, flags, compileDir)
297294 }
298295
@@ -306,15 +303,4 @@ class CompilationTests extends ParallelTesting {
306303object CompilationTests {
307304 implicit val summaryReport : SummaryReporting = new SummaryReport
308305 @ 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- }
320306}
0 commit comments