aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotc/tests.scala
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-01-12 16:18:20 +0700
committerGitHub <noreply@github.com>2017-01-12 16:18:20 +0700
commit36237cbc7449079574b4171a85bc7dccf19e371d (patch)
tree45bf3fd30f0ad343268f2dadba365cbb67f3c227 /compiler/test/dotc/tests.scala
parentba7e12999dc645dbcba04cf365dfd4d621ee4662 (diff)
parent783a80d0d8f726f7169022457152d4301779244f (diff)
downloaddotty-36237cbc7449079574b4171a85bc7dccf19e371d.tar.gz
dotty-36237cbc7449079574b4171a85bc7dccf19e371d.tar.bz2
dotty-36237cbc7449079574b4171a85bc7dccf19e371d.zip
Merge pull request #1880 from dotty-staging/improve-whitelist-infrastructure
Improve whitelist infrastructure.
Diffstat (limited to 'compiler/test/dotc/tests.scala')
-rw-r--r--compiler/test/dotc/tests.scala49
1 files changed, 10 insertions, 39 deletions
diff --git a/compiler/test/dotc/tests.scala b/compiler/test/dotc/tests.scala
index a7961d937..608132bca 100644
--- a/compiler/test/dotc/tests.scala
+++ b/compiler/test/dotc/tests.scala
@@ -2,6 +2,7 @@ package dotc
import dotty.Jars
import dotty.tools.dotc.CompilerTest
+import dotty.tools.StdLibSources
import org.junit.{Before, Test}
import org.junit.Assert._
@@ -201,50 +202,20 @@ class tests extends CompilerTest {
@Test def run_all = runFiles(runDir)
- def loadList(path: String) = Source.fromFile(path, "UTF8").getLines()
- .map(_.trim) // allow identation
- .filter(!_.startsWith("#")) // allow comment lines prefixed by #
- .map(_.takeWhile(_ != '#').trim) // allow comments in the end of line
- .filter(_.nonEmpty)
- .toList
+ private val stdlibFiles: List[String] = StdLibSources.whitelisted
- private def stdlibWhitelistFile = "./test/dotc/scala-collections.whitelist"
- private def stdlibBlackFile = "./test/dotc/scala-collections.blacklist"
+ @Test def checkWBLists = {
+ val stdlibFilesBlackListed = StdLibSources.blacklisted
- private val stdlibFiles: List[String] = loadList(stdlibWhitelistFile)
+ 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)
- @Test def checkWBLists = {
- val stdlibFilesBlackListed = loadList(stdlibBlackFile)
-
- def checkForRepeated(list: List[String], listFile: String) = {
- val duplicates = list.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 $listFile:\n", "\n", "\n")
- assertTrue(msg, duplicates.isEmpty)
- }
- checkForRepeated(stdlibFiles, stdlibWhitelistFile)
- checkForRepeated(stdlibFilesBlackListed, stdlibBlackFile)
-
- val whitelistSet = stdlibFiles.toSet
- val blacklistSet = stdlibFilesBlackListed.toSet
-
- val intersection = whitelistSet.intersect(blacklistSet)
- val msgIntersection =
- intersection.map(x => s"'$x'").mkString(s"Entries where found in both $stdlibWhitelistFile and $stdlibBlackFile:\n", "\n", "\n")
- assertTrue(msgIntersection, intersection.isEmpty)
-
- def collectAllFilesInDir(dir: JFile, acc: List[String]): List[String] = {
- val files = dir.listFiles()
- val acc2 = files.foldLeft(acc)((acc1, file) => if (file.isFile && file.getPath.endsWith(".scala")) file.getPath :: acc1 else acc1)
- files.foldLeft(acc2)((acc3, file) => if (file.isDirectory) collectAllFilesInDir(file, acc3) else acc3)
- }
- val filesInStdLib = collectAllFilesInDir(new JFile("../scala-scala/src/library/"), Nil)
- val missingFiles = filesInStdLib.toSet -- whitelistSet -- blacklistSet
- val msgMissing =
- missingFiles.map(x => s"'$x'").mkString(s"Entries are missing in $stdlibWhitelistFile or $stdlibBlackFile:\n", "\n", "\n")
- assertTrue(msgMissing, missingFiles.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)
}
-
@Test def compileStdLib = compileList("compileStdLib", stdlibFiles, "-migration" :: "-Yno-inline" :: scala2mode)
@Test def compileMixed = compileLine(
"""../tests/pos/B.scala