Skip to content

Remove debug code for stdlib whitelist #4793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions compiler/test/dotty/tools/StdLibSources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,11 @@ import org.junit.Assert._

object StdLibSources {

/* For debug only */
private val useExplicitWhiteList = false

private final val stdLibPath = "scala2-library/src/library/"

def blacklistFile: String = "compiler/test/dotc/scala-collections.blacklist"
private def whitelistFile: String = "compiler/test/dotc/scala-collections.whitelist"

def whitelisted: List[String] = {
lazy val whitelistBasedOnBlacklist = all.diff(blacklisted)
if (!useExplicitWhiteList) {
whitelistBasedOnBlacklist
} else if (!new File(whitelistFile).exists()) {
genWhitelist(whitelistBasedOnBlacklist.map(_.replace(stdLibPath, "")))
whitelistBasedOnBlacklist
} else {
loadList(whitelistFile)
}
}

def whitelisted: List[String] = all.diff(blacklisted)
def blacklisted: List[String] = loadList(blacklistFile)

def all: List[String] = {
Expand All @@ -38,17 +23,6 @@ object StdLibSources {
collectAllFilesInDir(new File(stdLibPath), Nil)
}

private def genWhitelist(list: List[String]): Unit = {
println(s"Generating $whitelistFile based on $blacklistFile")
val whitelist = new File(whitelistFile)
val p = new java.io.PrintWriter(whitelist)
try {
list.foreach(p.println)
} finally {
p.close()
}
}

private def loadList(path: String): List[String] = Source.fromFile(path, "UTF8").getLines()
.map(_.trim) // allow identation
.filter(!_.startsWith("#")) // allow comment lines prefixed by #
Expand All @@ -58,17 +32,3 @@ object StdLibSources {
.toList

}

class StdLibSources {
@Test def checkWBLists = {
val stdlibFilesBlackListed = StdLibSources.blacklisted

val duplicates = stdlibFilesBlackListed.groupBy(x => x).filter(_._2.size > 1).filter(_._2.size > 1)
val msg = duplicates.map(x => s"'${x._1}' appears ${x._2.size} times").mkString(s"Duplicate entries in ${StdLibSources.blacklistFile}:\n", "\n", "\n")
assertTrue(msg, duplicates.isEmpty)

val filesNotInStdLib = stdlibFilesBlackListed.toSet -- StdLibSources.all
val msg2 = filesNotInStdLib.map(x => s"'$x'").mkString(s"Entries in ${StdLibSources.blacklistFile} where not found:\n", "\n", "\n")
assertTrue(msg2, filesNotInStdLib.isEmpty)
}
}