Skip to content

Backport: Set file filter correctly #12119

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 4 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions compiler/test/dotty/tools/dotc/IdempotencyTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ class IdempotencyTests {
import IdempotencyTests._
import CompilationTest.aggregateTests

// Flaky test on Windows
// https://github.com/lampepfl/dotty/issues/11885
val filter = FileFilter.exclude("i6507b")

@Category(Array(classOf[SlowTests]))
@Test def idempotency: Unit = {
implicit val testGroup: TestGroup = TestGroup("idempotency")
val opt = defaultOptions

val posIdempotency = aggregateTests(
compileFilesInDir("tests/pos", opt)(TestGroup("idempotency/posIdempotency1")),
compileFilesInDir("tests/pos", opt)(TestGroup("idempotency/posIdempotency2")),
compileFilesInDir("tests/pos", opt, filter)(TestGroup("idempotency/posIdempotency1")),
compileFilesInDir("tests/pos", opt, filter)(TestGroup("idempotency/posIdempotency2")),
)

val orderIdempotency = {
Expand Down
4 changes: 4 additions & 0 deletions compiler/test/dotty/tools/vulpix/FileFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ sealed trait FileFilter {
}

object FileFilter {
def exclude(file: String): FileFilter = exclude(file :: Nil)

def exclude(file: String, files: String*): FileFilter =
exclude(file :: files.toList)

def exclude(files: List[String]): FileFilter = new FileFilter {
private val blackList = files.toSet
Expand Down
12 changes: 2 additions & 10 deletions tests/idempotency/IdempotencyCheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import java.util.stream.Stream as JStream
import scala.collection.JavaConverters.*

object IdempotencyCheck {
val blacklisted = Set(
// No fix needed. Bridges on collections in different order. Second one in scala2 order.
s"pos{JFile.separator}Map{JFile.separator}scala{JFile.separator}collection{JFile.separator}immutable/Map",
s"pos{JFile.separator}Map{JFile.separator}scala{JFile.separator}collection{JFile.separator}immutable{JFile.separator}AbstractMap",
s"pos{JFile.separator}t1203a/NodeSeq",
s"pos{JFile.separator}i2345{JFile.separator}Whatever"
)

def checkIdempotency(dir1: String, dir2: String): Unit = {
var failed = 0
var total = 0
Expand All @@ -26,14 +18,14 @@ object IdempotencyCheck {
val bytecodeFiles = {
def bytecodeFiles(paths: JStream[JPath], dir: String): List[(String, JPath)] = {
def isBytecode(file: String) = file.endsWith(".class") || file.endsWith(".tasty")
def tupleWithName(f: JPath) = (f.toString.substring(dir.length + 1, f.toString.length - 6), f)
def tupleWithName(f: JPath) = (f.toString.substring(dir.length, f.toString.length - 6), f)
paths.iterator.asScala.filter(path => isBytecode(path.toString)).map(tupleWithName).toList
}
bytecodeFiles(JFiles.walk(dir1Path), dir1String) ++ bytecodeFiles(JFiles.walk(dir2Path), dir2String)
}
val groups = bytecodeFiles.groupBy(_._1).mapValues(_.map(_._2))

groups.filterNot(x => blacklisted(x._1)).iterator.flatMap { g =>
groups.iterator.flatMap { g =>
def pred(f: JPath, dir: String, isTasty: Boolean) =
f.toString.contains(dir) && f.toString.endsWith(if (isTasty) ".tasty" else ".class")
val class1 = g._2.find(f => pred(f, dir1String, isTasty = false))
Expand Down