Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n authored and Friendseeker committed Oct 3, 2024
1 parent 4efdef3 commit b0e2c85
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import sbt.io.IO
import xsbti.compile.{ AnalysisContents, AnalysisStore }
import xsbti.compile.analysis.ReadWriteMappers

// $ cp $HOME/work/scala-modules/scala/target/library/zinc/inc_compile.zip test-data/library.zip
// $ cp $HOME/work/scala-modules/scala/target/reflect/zinc/inc_compile.zip test-data/reflect.zip
// $ cp $HOME/work/scala-modules/scala/target/compiler/zinc/inc_compile.zip test-data/compiler.zip
class ConsistentAnalysisFormatIntegrationSuite extends AnyFunSuite {
val data =
Seq("compiler.zip", "library.zip", "reflect.zip").map(f => new File("../../../test-data", f))

test("Consistent output") {
for (d <- data) {
assert(d.exists())
val api = read(FileAnalysisStore.binary(d))
val api = read(FileAnalysisStore.text(d))
val f1 = write("cbin1.zip", api)
val f2 = write("cbin2.zip", api)
assert(Arrays.equals(IO.readBytes(f1), IO.readBytes(f2)), s"same output for $d")
Expand All @@ -26,7 +29,7 @@ class ConsistentAnalysisFormatIntegrationSuite extends AnyFunSuite {
test("Roundtrip") {
for (d <- data) {
assert(d.exists())
val api = read(FileAnalysisStore.binary(d))
val api = read(FileAnalysisStore.text(d))
val f1 = write("cbin1.zip", api)
val api2 = read(ConsistentFileAnalysisStore.binary(f1, ReadWriteMappers.getEmptyMappers))
val f2 = write("cbin2.zip", api2)
Expand All @@ -37,7 +40,7 @@ class ConsistentAnalysisFormatIntegrationSuite extends AnyFunSuite {
test("Unsorted roundtrip") {
for (d <- data) {
assert(d.exists())
val api = read(FileAnalysisStore.binary(d))
val api = read(FileAnalysisStore.text(d))
val f1 = write("cbin1.zip", api)
val api2 = read(ConsistentFileAnalysisStore.binary(f1, ReadWriteMappers.getEmptyMappers))
val f2 = write("cbin2.zip", api2, sort = false)
Expand Down
Binary file modified test-data/compiler.zip
Binary file not shown.
Binary file modified test-data/library.zip
Binary file not shown.
Binary file modified test-data/reflect.zip
Binary file not shown.
11 changes: 8 additions & 3 deletions zinc/src/test/scala/sbt/inc/MultiProjectIncrementalSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,14 @@ class MultiProjectIncrementalSpec extends BaseCompilerSpec {
val f4 = StringVirtualFile("Z.java", s4)

c1.compile(f1)
val result = c2.compileBoth(f2, f3)
assert(startTimes(result) == startTimes(c2.compileBoth(f2, f3)))
assert(startTimes(result) != startTimes(c2.compileBoth(f2, f4)))
c2.compileBoth(f2, f3)
val noopResult = c2.compileBoth(f2, f3)
// comparing startTime is no longer a good test
assert(!noopResult.hasModified())

// comparing startTime is no longer a good test
val changedResult = c2.compileBoth(f2, f4)
assert(changedResult.hasModified())
} finally {
c1.close()
c2.close()
Expand Down

0 comments on commit b0e2c85

Please sign in to comment.