From 24fe93465bf35d0597a1fd5bf30bca6883316b8e Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 30 Mar 2021 10:04:33 +0200 Subject: [PATCH 1/4] Fix #11885: disable flaky idempotency test on Windows --- tests/idempotency/IdempotencyCheck.scala | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/idempotency/IdempotencyCheck.scala b/tests/idempotency/IdempotencyCheck.scala index 6f9a8de588de..546b13487ff6 100644 --- a/tests/idempotency/IdempotencyCheck.scala +++ b/tests/idempotency/IdempotencyCheck.scala @@ -6,13 +6,12 @@ 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" - ) + val flakyTestsOnWindows = + if scala.util.Properties.isWin + then Set(s"pos${JFile.separator}i6507b") + else Set.empty + + val blacklisted = flakyTestsOnWindows def checkIdempotency(dir1: String, dir2: String): Unit = { var failed = 0 From 667a306f0954f937aa0fa748201429cae8a153a7 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 30 Mar 2021 18:41:27 +0200 Subject: [PATCH 2/4] Fix typo in idempotency test filter --- tests/idempotency/IdempotencyCheck.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/idempotency/IdempotencyCheck.scala b/tests/idempotency/IdempotencyCheck.scala index 546b13487ff6..79f236d3d24a 100644 --- a/tests/idempotency/IdempotencyCheck.scala +++ b/tests/idempotency/IdempotencyCheck.scala @@ -25,7 +25,7 @@ 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) From 9e2e30990b6c5b08cd7a4930974e3505c3dddc41 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 30 Mar 2021 19:49:30 +0200 Subject: [PATCH 3/4] Refactor filter in idempotency test --- compiler/test/dotty/tools/dotc/IdempotencyTests.scala | 8 ++++++-- compiler/test/dotty/tools/vulpix/FileFilter.scala | 4 ++++ tests/idempotency/IdempotencyCheck.scala | 9 +-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala index 30dbb47475ff..980cfee4634a 100644 --- a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala +++ b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala @@ -18,14 +18,18 @@ class IdempotencyTests { import IdempotencyTests._ import CompilationTest.aggregateTests + val filter = FileFilter.exclude( + s"pos${JFile.separator}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 = { diff --git a/compiler/test/dotty/tools/vulpix/FileFilter.scala b/compiler/test/dotty/tools/vulpix/FileFilter.scala index 75c17089a4e1..b2aef8af038e 100644 --- a/compiler/test/dotty/tools/vulpix/FileFilter.scala +++ b/compiler/test/dotty/tools/vulpix/FileFilter.scala @@ -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 diff --git a/tests/idempotency/IdempotencyCheck.scala b/tests/idempotency/IdempotencyCheck.scala index 79f236d3d24a..598f68a8b347 100644 --- a/tests/idempotency/IdempotencyCheck.scala +++ b/tests/idempotency/IdempotencyCheck.scala @@ -6,13 +6,6 @@ import java.util.stream.Stream as JStream import scala.collection.JavaConverters.* object IdempotencyCheck { - val flakyTestsOnWindows = - if scala.util.Properties.isWin - then Set(s"pos${JFile.separator}i6507b") - else Set.empty - - val blacklisted = flakyTestsOnWindows - def checkIdempotency(dir1: String, dir2: String): Unit = { var failed = 0 var total = 0 @@ -32,7 +25,7 @@ object IdempotencyCheck { } 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)) From 20f8308d81b252d0d4d21dfbe6e7cdeeecbed04d Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Fri, 16 Apr 2021 14:11:25 +0200 Subject: [PATCH 4/4] Set file filter correctly File filter only work for names not path. --- compiler/test/dotty/tools/dotc/IdempotencyTests.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala index 980cfee4634a..66988a8f2408 100644 --- a/compiler/test/dotty/tools/dotc/IdempotencyTests.scala +++ b/compiler/test/dotty/tools/dotc/IdempotencyTests.scala @@ -18,9 +18,9 @@ class IdempotencyTests { import IdempotencyTests._ import CompilationTest.aggregateTests - val filter = FileFilter.exclude( - s"pos${JFile.separator}i6507b" - ) + // Flaky test on Windows + // https://github.com/lampepfl/dotty/issues/11885 + val filter = FileFilter.exclude("i6507b") @Category(Array(classOf[SlowTests])) @Test def idempotency: Unit = {