Skip to content

Commit 3c5d4ea

Browse files
committed
Place all tests source lists in TestSources
1 parent fdcc7f2 commit 3c5d4ea

File tree

7 files changed

+65
-72
lines changed

7 files changed

+65
-72
lines changed

compiler/test/dotty/tools/FromTastySources.scala

Lines changed: 0 additions & 26 deletions
This file was deleted.

compiler/test/dotty/tools/ListOfSources.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

compiler/test/dotty/tools/StdLibSources.scala

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package dotty.tools
2+
3+
import java.io.File
4+
5+
import scala.io.Source
6+
7+
object TestSources {
8+
9+
// Std Lib
10+
11+
private final val stdLibPath = "scala2-library/src/library/"
12+
13+
private def blacklistFile: String = "compiler/test/dotc/scala-collections.blacklist"
14+
15+
def stdLibWhitelisted: List[String] = all.diff(stdLibBlacklisted)
16+
def stdLibBlacklisted: List[String] = loadList(blacklistFile).map(stdLibPath + _)
17+
18+
private def all: List[String] = {
19+
def collectAllFilesInDir(dir: File, acc: List[String]): List[String] = {
20+
val files = dir.listFiles()
21+
val acc2 = files.foldLeft(acc)((acc1, file) => if (file.isFile && file.getPath.endsWith(".scala")) file.getPath :: acc1 else acc1)
22+
files.foldLeft(acc2)((acc3, file) => if (file.isDirectory) collectAllFilesInDir(file, acc3) else acc3)
23+
}
24+
collectAllFilesInDir(new File(stdLibPath), Nil)
25+
}
26+
27+
// pos tests lists
28+
29+
def posFromTastyBlacklistFile: String = "compiler/test/dotc/pos-from-tasty.blacklist"
30+
def posDecompilationBlacklistFile: String = "compiler/test/dotc/pos-decompilation.blacklist"
31+
def posRecompilationWhitelistFile: String = "compiler/test/dotc/pos-recompilation.whitelist"
32+
33+
def posFromTastyBlacklisted: List[String] = loadList(posFromTastyBlacklistFile)
34+
def posDecompilationBlacklisted: List[String] = loadList(posDecompilationBlacklistFile)
35+
def posRecompilationWhitelist: List[String] = loadList(posRecompilationWhitelistFile)
36+
37+
// run tests lists
38+
39+
def runFromTastyBlacklistFile: String = "compiler/test/dotc/run-from-tasty.blacklist"
40+
def runDecompilationBlacklistFile: String = "compiler/test/dotc/run-decompilation.blacklist"
41+
def runRecompilationWhitelistFile: String = "compiler/test/dotc/run-recompilation.whitelist"
42+
43+
def runFromTastyBlacklisted: List[String] = loadList(runFromTastyBlacklistFile)
44+
def runDecompilationBlacklisted: List[String] = loadList(runDecompilationBlacklistFile)
45+
def runRecompilationWhitelist: List[String] = loadList(runRecompilationWhitelistFile)
46+
47+
// load lists
48+
49+
private def loadList(path: String): List[String] = Source.fromFile(path, "UTF8").getLines()
50+
.map(_.trim) // allow identation
51+
.filter(!_.startsWith("#")) // allow comment lines prefixed by #
52+
.map(_.takeWhile(_ != '#').trim) // allow comments in the end of line
53+
.filter(_.nonEmpty)
54+
.toList
55+
56+
}

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline", "-Ydetailed-stats"))
37+
compileList("compileStdLib", TestSources.stdLibWhitelisted, scala2Mode.and("-migration", "-Yno-inline", "-Ydetailed-stats"))
3838
}.checkCompile()
3939

4040
@Test def compilePos: Unit = {
4141
implicit val testGroup: TestGroup = TestGroup("compilePos")
42-
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline")) +
42+
compileList("compileStdLib", TestSources.stdLibWhitelisted, scala2Mode.and("-migration", "-Yno-inline")) +
4343
compileDir("compiler/src/dotty/tools/dotc/ast", defaultOptions) +
4444
compileDir("compiler/src/dotty/tools/dotc/config", defaultOptions) +
4545
compileDir("compiler/src/dotty/tools/dotc/core", defaultOptions) +

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class FromTastyTests extends ParallelTesting {
2727

2828
implicit val testGroup: TestGroup = TestGroup("posTestFromTasty")
2929
compileTastyInDir("tests/pos", defaultOptions,
30-
fromTastyFilter = FileFilter.exclude(FromTastySources.posFromTastyBlacklisted),
31-
decompilationFilter = FileFilter.exclude(FromTastySources.posDecompilationBlacklisted),
32-
recompilationFilter = FileFilter.include(FromTastySources.posRecompilationWhitelist)
30+
fromTastyFilter = FileFilter.exclude(TestSources.posFromTastyBlacklisted),
31+
decompilationFilter = FileFilter.exclude(TestSources.posDecompilationBlacklisted),
32+
recompilationFilter = FileFilter.include(TestSources.posRecompilationWhitelist)
3333
).checkCompile()
3434
}
3535

@@ -41,9 +41,9 @@ class FromTastyTests extends ParallelTesting {
4141

4242
implicit val testGroup: TestGroup = TestGroup("runTestFromTasty")
4343
compileTastyInDir("tests/run", defaultOptions,
44-
fromTastyFilter = FileFilter.exclude(FromTastySources.runFromTastyBlacklisted),
45-
decompilationFilter = FileFilter.exclude(FromTastySources.runDecompilationBlacklisted),
46-
recompilationFilter = FileFilter.include(FromTastySources.runRecompilationWhitelist)
44+
fromTastyFilter = FileFilter.exclude(TestSources.runFromTastyBlacklisted),
45+
decompilationFilter = FileFilter.exclude(TestSources.runDecompilationBlacklisted),
46+
recompilationFilter = FileFilter.include(TestSources.runRecompilationWhitelist)
4747
).checkRuns()
4848
}
4949
}

doc-tool/test/WhitelistedStdLib.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ class TestWhitelistedCollections extends DottyDocTest {
3232

3333
object TestWhitelistedCollections {
3434
val files: List[String] =
35-
StdLibSources.whitelisted
35+
TestSources.stdLibWhitelisted
3636
.filterNot(_.endsWith("package.scala"))
3737
}

0 commit comments

Comments
 (0)