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+ }
0 commit comments