1
1
2
- import java .nio .file .{Files , Path , Paths }
2
+ import java .nio .file .{ Files => JFiles , Path => JPath , Paths => JPaths }
3
3
import java .util .stream .{ Stream => JStream }
4
4
5
5
import scala .collection .JavaConverters ._
@@ -17,20 +17,20 @@ object IdempotencyCheck {
17
17
var failed = 0
18
18
var total = 0
19
19
20
- val groupedBytecodeFiles : List [(Path , Path , Path , Path )] = {
20
+ val groupedBytecodeFiles : List [(JPath , JPath , JPath , JPath )] = {
21
21
val bytecodeFiles = {
22
- def bytecodeFiles (paths : JStream [Path ]): List [Path ] = {
22
+ def bytecodeFiles (paths : JStream [JPath ]): List [JPath ] = {
23
23
def isBytecode (file : String ) = file.endsWith(" .class" ) || file.endsWith(" .tasty" )
24
24
paths.iterator.asScala.filter(path => isBytecode(path.toString)).toList
25
25
}
26
- val compilerDir1 = Paths .get(dirPrefix + 1 )
27
- val compilerDir2 = Paths .get(dirPrefix + 2 )
28
- bytecodeFiles(Files .walk(compilerDir1)) ++ bytecodeFiles(Files .walk(compilerDir2))
26
+ val compilerDir1 = JPaths .get(dirPrefix + 1 )
27
+ val compilerDir2 = JPaths .get(dirPrefix + 2 )
28
+ bytecodeFiles(JFiles .walk(compilerDir1)) ++ bytecodeFiles(JFiles .walk(compilerDir2))
29
29
}
30
30
val groups = bytecodeFiles.groupBy(f => f.toString.substring(dirPrefix.length + 1 , f.toString.length - 6 ))
31
31
32
32
groups.filterNot(x => blacklisted(x._1)).valuesIterator.flatMap { g =>
33
- def pred (f : Path , i : Int , isTasty : Boolean ) =
33
+ def pred (f : JPath , i : Int , isTasty : Boolean ) =
34
34
f.toString.contains(dirPrefix + i) && f.toString.endsWith(if (isTasty) " .tasty" else " .class" )
35
35
val class1 = g.find(f => pred(f, 1 , isTasty = false ))
36
36
val class2 = g.find(f => pred(f, 2 , isTasty = false ))
@@ -45,18 +45,18 @@ object IdempotencyCheck {
45
45
46
46
for ((class1, tasty1, class2, tasty2) <- groupedBytecodeFiles) {
47
47
total += 1
48
- val bytes1 = Files .readAllBytes(class1)
49
- val bytes2 = Files .readAllBytes(class2)
48
+ val bytes1 = JFiles .readAllBytes(class1)
49
+ val bytes2 = JFiles .readAllBytes(class2)
50
50
if (! java.util.Arrays .equals(bytes1, bytes2)) {
51
51
failed += 1
52
- val tastyBytes1 = Files .readAllBytes(tasty1)
53
- val tastyBytes2 = Files .readAllBytes(tasty2)
52
+ val tastyBytes1 = JFiles .readAllBytes(tasty1)
53
+ val tastyBytes2 = JFiles .readAllBytes(tasty2)
54
54
if (java.util.Arrays .equals(tastyBytes1, tastyBytes2))
55
55
println(s " Idempotency test failed between $class1 and $class1 (same tasty) " )
56
56
else
57
57
println(s " Idempotency test failed between $tasty1 and $tasty2" )
58
58
/* Dump bytes to console, could be useful if issue only appears in CI.
59
- * Create the .class locally with Files .write(path, Array[Byte](...)) with the printed array
59
+ * Create the .class locally with JFiles .write(path, Array[Byte](...)) with the printed array
60
60
*/
61
61
// println(bytes1.mkString("Array[Byte](", ",", ")"))
62
62
// println(bytes2.mkString("Array[Byte](", ",", ")"))
0 commit comments