Skip to content

Commit

Permalink
Fix imports format
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jun 19, 2017
1 parent 9a5a46c commit 711e6f7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
7 changes: 2 additions & 5 deletions tests/idempotency/BootstrapChecker.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import java.nio.file.{Files, Path, Paths}
import java.util.stream.{ Stream => JStream }

import scala.collection.JavaConverters._

object Test {
def main(args: Array[String]): Unit = IdempotencyCheck.checkIdempotency("../out/dotty")
def main(args: Array[String]): Unit =
IdempotencyCheck.checkIdempotency("../out/dotty")
}
5 changes: 0 additions & 5 deletions tests/idempotency/Checker.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@

import java.nio.file.{Files, Path, Paths}
import java.util.stream.{ Stream => JStream }

import scala.collection.JavaConverters._

object Test {
def main(args: Array[String]): Unit =
IdempotencyCheck.checkIdempotency("../out/idempotency")
Expand Down
24 changes: 12 additions & 12 deletions tests/idempotency/IdempotencyCheck.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import java.nio.file.{Files, Path, Paths}
import java.nio.file.{ Files => JFiles, Path => JPath, Paths => JPaths }
import java.util.stream.{ Stream => JStream }

import scala.collection.JavaConverters._
Expand All @@ -17,20 +17,20 @@ object IdempotencyCheck {
var failed = 0
var total = 0

val groupedBytecodeFiles: List[(Path, Path, Path, Path)] = {
val groupedBytecodeFiles: List[(JPath, JPath, JPath, JPath)] = {
val bytecodeFiles = {
def bytecodeFiles(paths: JStream[Path]): List[Path] = {
def bytecodeFiles(paths: JStream[JPath]): List[JPath] = {
def isBytecode(file: String) = file.endsWith(".class") || file.endsWith(".tasty")
paths.iterator.asScala.filter(path => isBytecode(path.toString)).toList
}
val compilerDir1 = Paths.get(dirPrefix + 1)
val compilerDir2 = Paths.get(dirPrefix + 2)
bytecodeFiles(Files.walk(compilerDir1)) ++ bytecodeFiles(Files.walk(compilerDir2))
val compilerDir1 = JPaths.get(dirPrefix + 1)
val compilerDir2 = JPaths.get(dirPrefix + 2)
bytecodeFiles(JFiles.walk(compilerDir1)) ++ bytecodeFiles(JFiles.walk(compilerDir2))
}
val groups = bytecodeFiles.groupBy(f => f.toString.substring(dirPrefix.length + 1, f.toString.length - 6))

groups.filterNot(x => blacklisted(x._1)).valuesIterator.flatMap { g =>
def pred(f: Path, i: Int, isTasty: Boolean) =
def pred(f: JPath, i: Int, isTasty: Boolean) =
f.toString.contains(dirPrefix + i) && f.toString.endsWith(if (isTasty) ".tasty" else ".class")
val class1 = g.find(f => pred(f, 1, isTasty = false))
val class2 = g.find(f => pred(f, 2, isTasty = false))
Expand All @@ -45,18 +45,18 @@ object IdempotencyCheck {

for ((class1, tasty1, class2, tasty2) <- groupedBytecodeFiles) {
total += 1
val bytes1 = Files.readAllBytes(class1)
val bytes2 = Files.readAllBytes(class2)
val bytes1 = JFiles.readAllBytes(class1)
val bytes2 = JFiles.readAllBytes(class2)
if (!java.util.Arrays.equals(bytes1, bytes2)) {
failed += 1
val tastyBytes1 = Files.readAllBytes(tasty1)
val tastyBytes2 = Files.readAllBytes(tasty2)
val tastyBytes1 = JFiles.readAllBytes(tasty1)
val tastyBytes2 = JFiles.readAllBytes(tasty2)
if (java.util.Arrays.equals(tastyBytes1, tastyBytes2))
println(s"Idempotency test failed between $class1 and $class1 (same tasty)")
else
println(s"Idempotency test failed between $tasty1 and $tasty2")
/* Dump bytes to console, could be useful if issue only appears in CI.
* Create the .class locally with Files.write(path, Array[Byte](...)) with the printed array
* Create the .class locally with JFiles.write(path, Array[Byte](...)) with the printed array
*/
// println(bytes1.mkString("Array[Byte](", ",", ")"))
// println(bytes2.mkString("Array[Byte](", ",", ")"))
Expand Down

0 comments on commit 711e6f7

Please sign in to comment.