@@ -7,48 +7,12 @@ import org.junit.Assert._
7
7
8
8
object StdLibSources {
9
9
10
- /* For debug only */
11
- private val useExplicitWhiteList = false
12
-
13
10
private final val stdLibPath = " scala2-library/src/library/"
14
11
15
12
def blacklistFile : String = " compiler/test/dotc/scala-collections.blacklist"
16
- private def whitelistFile : String = " compiler/test/dotc/scala-collections.whitelist"
17
-
18
- def whitelisted : List [String ] = {
19
- lazy val whitelistBasedOnBlacklist = all.diff(blacklisted)
20
- if (! useExplicitWhiteList) {
21
- whitelistBasedOnBlacklist
22
- } else if (! new File (whitelistFile).exists()) {
23
- genWhitelist(whitelistBasedOnBlacklist.map(_.replace(stdLibPath, " " )))
24
- whitelistBasedOnBlacklist
25
- } else {
26
- loadList(whitelistFile)
27
- }
28
- }
29
13
30
14
def blacklisted : List [String ] = loadList(blacklistFile)
31
15
32
- def all : List [String ] = {
33
- def collectAllFilesInDir (dir : File , acc : List [String ]): List [String ] = {
34
- val files = dir.listFiles()
35
- val acc2 = files.foldLeft(acc)((acc1, file) => if (file.isFile && file.getPath.endsWith(" .scala" )) file.getPath :: acc1 else acc1)
36
- files.foldLeft(acc2)((acc3, file) => if (file.isDirectory) collectAllFilesInDir(file, acc3) else acc3)
37
- }
38
- collectAllFilesInDir(new File (stdLibPath), Nil )
39
- }
40
-
41
- private def genWhitelist (list : List [String ]): Unit = {
42
- println(s " Generating $whitelistFile based on $blacklistFile" )
43
- val whitelist = new File (whitelistFile)
44
- val p = new java.io.PrintWriter (whitelist)
45
- try {
46
- list.foreach(p.println)
47
- } finally {
48
- p.close()
49
- }
50
- }
51
-
52
16
private def loadList (path : String ): List [String ] = Source .fromFile(path, " UTF8" ).getLines()
53
17
.map(_.trim) // allow identation
54
18
.filter(! _.startsWith(" #" )) // allow comment lines prefixed by #
@@ -58,17 +22,3 @@ object StdLibSources {
58
22
.toList
59
23
60
24
}
61
-
62
- class StdLibSources {
63
- @ Test def checkWBLists = {
64
- val stdlibFilesBlackListed = StdLibSources .blacklisted
65
-
66
- val duplicates = stdlibFilesBlackListed.groupBy(x => x).filter(_._2.size > 1 ).filter(_._2.size > 1 )
67
- val msg = duplicates.map(x => s " ' ${x._1}' appears ${x._2.size} times " ).mkString(s " Duplicate entries in ${StdLibSources .blacklistFile}: \n " , " \n " , " \n " )
68
- assertTrue(msg, duplicates.isEmpty)
69
-
70
- val filesNotInStdLib = stdlibFilesBlackListed.toSet -- StdLibSources .all
71
- val msg2 = filesNotInStdLib.map(x => s " ' $x' " ).mkString(s " Entries in ${StdLibSources .blacklistFile} where not found: \n " , " \n " , " \n " )
72
- assertTrue(msg2, filesNotInStdLib.isEmpty)
73
- }
74
- }
0 commit comments