@@ -4,19 +4,31 @@ import java.util.stream.{ Stream => JStream }
44
55import scala .collection .JavaConverters ._
66
7- object Test {
8-
9- def main (args : Array [String ]): Unit = checkIdempotency()
10-
11- val blacklisted = Set (
12- // Bridges on collections in different order. Second one in scala2 order.
7+ object IdempotencyCheck {
8+ val blacklistedSet = Set (
9+ // No fix needed. Bridges on collections in different order. Second one in scala2 order.
1310 " pos/Map/scala/collection/immutable/Map" ,
1411 " pos/Map/scala/collection/immutable/AbstractMap" ,
1512 " pos/t1203a/NodeSeq" ,
1613 " pos/i2345/Whatever"
1714 )
1815
19- def checkIdempotency (): Unit = {
16+ def blacklisted (s : String ) = {
17+ blacklistedSet(s) ||
18+ // FIXME: non-deterministic method/class names
19+ s.contains(" $$anon$" ) ||
20+ s.contains(" $$anonfun$" ) ||
21+ s.contains(" $accu$" ) ||
22+ s.contains(" $accum$" ) ||
23+ s.startsWith(" /dotty/dotty/tools/dotc/sbt/ExtractAPICollector$classFirstSort$" ) ||
24+ s.startsWith(" /dotty/dotty/tools/dotc/transform/PatternMatcher$Translator$TreeMakers$IntEqualityTestTreeMaker$" ) ||
25+ s.startsWith(" /dotty/dotty/tools/dotc/typer/RefChecks$MixinOverrideError$" ) ||
26+ s.startsWith(" /dotty/dotty/tools/dotc/typer/ImplicitRunInfo$liftToClasses$" ) ||
27+ s.startsWith(" /dotty/dotty/tools/dotc/typer/Inliner$addAccessors$" ) ||
28+ s.startsWith(" /dotty/dotty/tools/dotc/typer/ErrorReporting$reported$" )
29+ }
30+
31+ def checkIdempotency (dirPrefix : String ): Unit = {
2032 var failed = 0
2133 var total = 0
2234
@@ -26,20 +38,21 @@ object Test {
2638 def isBytecode (file : String ) = file.endsWith(" .class" ) || file.endsWith(" .tasty" )
2739 paths.iterator.asScala.filter(path => isBytecode(path.toString)).toList
2840 }
29- val compilerDir1 = Paths .get(" ../out/idempotency1 " )
30- val compilerDir2 = Paths .get(" ../out/idempotency2 " )
41+ val compilerDir1 = Paths .get(dirPrefix + 1 )
42+ val compilerDir2 = Paths .get(dirPrefix + 2 )
3143 bytecodeFiles(Files .walk(compilerDir1)) ++ bytecodeFiles(Files .walk(compilerDir2))
3244 }
33- val groups = bytecodeFiles.groupBy(f => f.toString.substring(" ../out/idempotencyN/" .length, f.toString.length - 6 ))
45+ val groups = bytecodeFiles.groupBy(f => f.toString.substring(dirPrefix.length + 1 , f.toString.length - 6 ))
46+
3447 groups.filterNot(x => blacklisted(x._1)).valuesIterator.flatMap { g =>
3548 def pred (f : Path , i : Int , isTasty : Boolean ) =
36- f.toString.contains(" idempotency " + i) && f.toString.endsWith(if (isTasty) " .tasty" else " .class" )
49+ f.toString.contains(dirPrefix + i) && f.toString.endsWith(if (isTasty) " .tasty" else " .class" )
3750 val class1 = g.find(f => pred(f, 1 , isTasty = false ))
3851 val class2 = g.find(f => pred(f, 2 , isTasty = false ))
3952 val tasty1 = g.find(f => pred(f, 1 , isTasty = true ))
4053 val tasty2 = g.find(f => pred(f, 2 , isTasty = true ))
41- assert(class1.isDefined, " Could not find class in idempotency1 for " + class2)
42- assert(class2.isDefined, " Could not find class in idempotency2 for " + class1)
54+ assert(class1.isDefined, s " Could not find class in ${dirPrefix + 1 } for $ class2" )
55+ assert(class2.isDefined, s " Could not find class in ${dirPrefix + 2 } for $ class1" )
4356 if (tasty1.isEmpty || tasty2.isEmpty) Nil
4457 else List (Tuple4 (class1.get, tasty1.get, class2.get, tasty2.get))
4558 }.toList
0 commit comments