@@ -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
19
19
class CompilationTests extends 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) +
@@ -218,14 +218,14 @@ class CompilationTests extends ParallelTesting {
218
218
)
219
219
220
220
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(_ ))
222
222
223
223
val lib =
224
224
compileList(" src" , librarySources,
225
225
defaultOptions.and(" -Ycheck-reentrant" , " -strict" , " -priorityclasspath" , defaultOutputDir))(libGroup)
226
226
227
227
val compilerDir = Paths .get(" compiler/src" )
228
- val compilerSources = sources(Files .walk( compilerDir) )
228
+ val compilerSources = sources(compilerDir)
229
229
230
230
val backendDir = Paths .get(" scala-backend/src/compiler/scala/tools/nsc/backend" )
231
231
val backendJvmDir = Paths .get(" scala-backend/src/compiler/scala/tools/nsc/backend/jvm" )
@@ -238,11 +238,11 @@ class CompilationTests extends ParallelTesting {
238
238
List (" BCodeICodeCommon.scala" , " GenASM.scala" , " GenBCode.scala" , " ScalacBackendInterface.scala" , " BackendStats.scala" , " BCodeAsmEncode.scala" )
239
239
240
240
val backendSources =
241
- sources(Files .list( backendDir) , excludedFiles = backendExcluded)
241
+ sources(backendDir, excludedFiles = backendExcluded, shallow = true )
242
242
val backendJvmSources =
243
- sources(Files .list( backendJvmDir) , excludedFiles = backendJvmExcluded)
243
+ sources(backendJvmDir, excludedFiles = backendJvmExcluded, shallow = true )
244
244
val scalaJSIRSources =
245
- sources(Files .list( scalaJSIRDir) )
245
+ sources(scalaJSIRDir, shallow = true )
246
246
247
247
val dotty1 = compileList(" dotty" , compilerSources ++ backendSources ++ backendJvmSources ++ scalaJSIRSources, opt)(dotty1Group)
248
248
val dotty2 = compileList(" dotty" , compilerSources ++ backendSources ++ backendJvmSources ++ scalaJSIRSources, opt)(dotty2Group)
@@ -267,9 +267,10 @@ class CompilationTests extends ParallelTesting {
267
267
}.keepOutput :: Nil
268
268
}.map(_.checkCompile())
269
269
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/ " )
273
274
compileList(" idempotency" , List (" tests/idempotency/BootstrapChecker.scala" , " tests/idempotency/IdempotencyCheck.scala" ), defaultOptions).checkRuns()
274
275
275
276
tests.foreach(_.delete())
@@ -282,17 +283,13 @@ class CompilationTests extends ParallelTesting {
282
283
// 2. copy `pluginFile` to destination
283
284
def compileFilesInDir (dir : String ): CompilationTest = {
284
285
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)
290
287
288
+ val dirs = sourceDir.listFiles.toList.filter(_.isDirectory)
291
289
val targets = dirs.map { dir =>
292
290
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)
296
293
SeparateCompilationSource (" testPlugins" , dir, flags, compileDir)
297
294
}
298
295
@@ -306,15 +303,4 @@ class CompilationTests extends ParallelTesting {
306
303
object CompilationTests {
307
304
implicit val summaryReport : SummaryReporting = new SummaryReport
308
305
@ 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
306
}
0 commit comments