Skip to content

Commit

Permalink
also test java tasty at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
bishabosha committed Nov 28, 2023
1 parent 3e8e563 commit 9b12e4a
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sbt-test/pipelining/Yjava-tasty-annotation/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ lazy val a = project.in(file("a"))
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-annotation-java-tasty.jar").toString),
scalacOptions += "-Ycheck:all",
classDirectory := ((ThisBuild / baseDirectory).value / "a-annotation-classes"), // send classfiles to a different directory
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-annotation-classes"), // send classfiles to a different directory
)

lazy val b = project.in(file("b"))
Expand Down
6 changes: 5 additions & 1 deletion sbt-test/pipelining/Yjava-tasty-enum/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lazy val a = project.in(file("a"))
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar").toString),
scalacOptions += "-Ycheck:all",
classDirectory := ((ThisBuild / baseDirectory).value / "a-enum-classes"), // send classfiles to a different directory
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-enum-classes"), // send classfiles to a different directory
)


Expand All @@ -13,3 +13,7 @@ lazy val b = project.in(file("b"))
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar")),
scalacOptions += "-Ycheck:all",
)
.settings(
fork := true, // we have to fork the JVM if we actually want to run the code with correct failure semantics
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-enum-classes"), // make sure the java classes are visible at runtime
)
2 changes: 1 addition & 1 deletion sbt-test/pipelining/Yjava-tasty-enum/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
> a/compile
# test depending on a java compiled enum through TASTy
> b/compile
> b/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package a;

public class A {
public static final String VALUE = "A";
public String VALUE = "A";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package b

object B {
val A: "A" = a.A.VALUE
val A_VALUE = (new a.A).VALUE

@main def test = {
assert(A_VALUE == "A", s"actually was $A_VALUE")
}
}
12 changes: 9 additions & 3 deletions sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lazy val a = project.in(file("a"))
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar").toString),
scalacOptions += "-Ycheck:all",
classDirectory := ((ThisBuild / baseDirectory).value / "a-pre-classes"), // send classfiles to a different directory
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-pre-classes"), // send classfiles to a different directory
)

// recompile `a` with `-from-tasty` flag to test idempotent read/write java signatures.
Expand All @@ -19,11 +19,17 @@ lazy val a_from_tasty = project.in(file("a_from_tasty"))
scalacOptions += "-Yallow-outline-from-tasty", // allow outline signatures to be read with -from-tasty
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar").toString),
scalacOptions += "-Ycheck:all",
classDirectory := ((ThisBuild / baseDirectory).value / "a_from_tasty-classes"), // send classfiles to a different directory
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a_from_tasty-classes"), // send classfiles to a different directory
)

lazy val b = project.in(file("b"))
.settings(
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar")),
scalacOptions += "-Ycheck:all",
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar")),
)
.settings(
// we have to fork the JVM if we actually want to run the code with correct failure semantics
fork := true,
// make sure the java classes are visible at runtime
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-pre-classes"),
)
2 changes: 1 addition & 1 deletion sbt-test/pipelining/Yjava-tasty-from-tasty/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# test reading java tasty with -from-tasty
> a_from_tasty/compile
# test java tasty is still written even with -from-tasty
> b/compile
> b/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class B[T] {
}

object B {
val derived: Int = (new B[Int]).inner.value
@main def test = {
val derived: Int = (new B[Int]).inner.value
assert(derived == 23, s"actually was $derived")
}
}

6 changes: 5 additions & 1 deletion sbt-test/pipelining/Yjava-tasty-generic/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ lazy val a = project.in(file("a"))
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-generic-java-tasty.jar").toString),
scalacOptions += "-Ycheck:all",
classDirectory := ((ThisBuild / baseDirectory).value / "a-generic-classes"), // send classfiles to a different directory
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-generic-classes"), // send classfiles to a different directory
)

lazy val b = project.in(file("b"))
.settings(
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-generic-java-tasty.jar")),
scalacOptions += "-Ycheck:all",
)
.settings(
fork := true, // we have to fork the JVM if we actually want to run the code with correct failure semantics
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-generic-classes"), // make sure the java classes are visible at runtime
)
2 changes: 1 addition & 1 deletion sbt-test/pipelining/Yjava-tasty-generic/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
> a/compile
# Test depending on a java generic class through TASTy
> b/compile
> b/run
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ object B {
val a_true: String = (new A()).add(true)

@main def test = {
assert(finalResult == "A")
assert(a_B == "AB")
assert(a_true == "Atrue")
assert(finalResult == "A", s"actually was $finalResult")
assert(a_B == "AB", s"actually was $a_B")
assert(a_true == "Atrue", s"actually was $a_true")
}
}

6 changes: 5 additions & 1 deletion sbt-test/pipelining/Yjava-tasty-result-types/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ lazy val a = project.in(file("a"))
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar").toString),
scalacOptions += "-Ycheck:all",
classDirectory := ((ThisBuild / baseDirectory).value / "a-result-types-classes"), // send classfiles to a different directory
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-result-types-classes"), // send classfiles to a different directory
)

lazy val b = project.in(file("b"))
.settings(
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar")),
scalacOptions += "-Ycheck:all",
)
.settings(
fork := true, // we have to fork the JVM if we actually want to run the code with correct failure semantics
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-result-types-classes"), // make sure the java classes are visible at runtime
)
2 changes: 1 addition & 1 deletion sbt-test/pipelining/Yjava-tasty-result-types/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
> a/compile
# Test depending on a java static final result, and method result through TASTy
> b/compile
> b/run

0 comments on commit 9b12e4a

Please sign in to comment.