Skip to content

Commit 2994ebb

Browse files
committed
also test java tasty at runtime
1 parent df8b202 commit 2994ebb

File tree

14 files changed

+46
-21
lines changed

14 files changed

+46
-21
lines changed

sbt-test/pipelining/Yjava-tasty-annotation/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ lazy val a = project.in(file("a"))
33
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
44
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-annotation-java-tasty.jar").toString),
55
scalacOptions += "-Ycheck:all",
6-
classDirectory := ((ThisBuild / baseDirectory).value / "a-annotation-classes"), // send classfiles to a different directory
6+
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-annotation-classes"), // send classfiles to a different directory
77
)
88

99
lazy val b = project.in(file("b"))

sbt-test/pipelining/Yjava-tasty-enum/build.sbt

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ lazy val a = project.in(file("a"))
44
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
55
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar").toString),
66
scalacOptions += "-Ycheck:all",
7-
classDirectory := ((ThisBuild / baseDirectory).value / "a-enum-classes"), // send classfiles to a different directory
7+
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-enum-classes"), // send classfiles to a different directory
88
)
99

1010

@@ -13,3 +13,7 @@ lazy val b = project.in(file("b"))
1313
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar")),
1414
scalacOptions += "-Ycheck:all",
1515
)
16+
.settings(
17+
fork := true, // we have to fork the JVM if we actually want to run the code with correct failure semantics
18+
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-enum-classes"), // make sure the java classes are visible at runtime
19+
)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
> a/compile
22
# test depending on a java compiled enum through TASTy
3-
> b/compile
3+
> b/run
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package a;
22

33
public class A {
4-
public static final String VALUE = "A";
4+
public String VALUE = "A";
55
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package b
22

33
object B {
4-
val A: "A" = a.A.VALUE
4+
val A_VALUE = (new a.A).VALUE
5+
6+
@main def test = {
7+
assert(A_VALUE == "A", s"actually was $A_VALUE")
8+
}
59
}

sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt

+9-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ lazy val a = project.in(file("a"))
55
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
66
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar").toString),
77
scalacOptions += "-Ycheck:all",
8-
classDirectory := ((ThisBuild / baseDirectory).value / "a-pre-classes"), // send classfiles to a different directory
8+
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-pre-classes"), // send classfiles to a different directory
99
)
1010

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

2525
lazy val b = project.in(file("b"))
2626
.settings(
27-
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar")),
2827
scalacOptions += "-Ycheck:all",
28+
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar")),
29+
)
30+
.settings(
31+
// we have to fork the JVM if we actually want to run the code with correct failure semantics
32+
fork := true,
33+
// make sure the java classes are visible at runtime
34+
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-pre-classes"),
2935
)

sbt-test/pipelining/Yjava-tasty-from-tasty/test

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# test reading java tasty with -from-tasty
33
> a_from_tasty/compile
44
# test java tasty is still written even with -from-tasty
5-
> b/compile
5+
> b/run

sbt-test/pipelining/Yjava-tasty-generic/b/src/main/scala/b/B.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ class B[T] {
77
}
88

99
object B {
10-
val derived: Int = (new B[Int]).inner.value
10+
@main def test = {
11+
val derived: Int = (new B[Int]).inner.value
12+
assert(derived == 23, s"actually was $derived")
13+
}
1114
}
1215

sbt-test/pipelining/Yjava-tasty-generic/build.sbt

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ lazy val a = project.in(file("a"))
33
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
44
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-generic-java-tasty.jar").toString),
55
scalacOptions += "-Ycheck:all",
6-
classDirectory := ((ThisBuild / baseDirectory).value / "a-generic-classes"), // send classfiles to a different directory
6+
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-generic-classes"), // send classfiles to a different directory
77
)
88

99
lazy val b = project.in(file("b"))
1010
.settings(
1111
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-generic-java-tasty.jar")),
1212
scalacOptions += "-Ycheck:all",
1313
)
14+
.settings(
15+
fork := true, // we have to fork the JVM if we actually want to run the code with correct failure semantics
16+
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-generic-classes"), // make sure the java classes are visible at runtime
17+
)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
> a/compile
22
# Test depending on a java generic class through TASTy
3-
> b/compile
3+
> b/run
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package a;
22

33
public class A {
4-
public static final String VALUE = "A";
4+
public static final String VALUE = "A";
55

6-
public <T> String add(T t) {
7-
return VALUE + t.toString();
8-
}
6+
public <T> String add(T t) {
7+
return VALUE + t.toString();
8+
}
99
}

sbt-test/pipelining/Yjava-tasty-result-types/b/src/main/scala/b/B.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ object B {
99
val a_true: String = (new A()).add(true)
1010

1111
@main def test = {
12-
assert(finalResult == "A")
13-
assert(a_B == "AB")
14-
assert(a_true == "Atrue")
12+
assert(finalResult == "A", s"actually was $finalResult")
13+
assert(a_B == "AB", s"actually was $a_B")
14+
assert(a_true == "Atrue", s"actually was $a_true")
1515
}
1616
}
1717

sbt-test/pipelining/Yjava-tasty-result-types/build.sbt

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ lazy val a = project.in(file("a"))
33
scalacOptions += "-Yjava-tasty", // enable pickling of java signatures
44
scalacOptions ++= Seq("-Yjava-tasty-output", ((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar").toString),
55
scalacOptions += "-Ycheck:all",
6-
classDirectory := ((ThisBuild / baseDirectory).value / "a-result-types-classes"), // send classfiles to a different directory
6+
Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-result-types-classes"), // send classfiles to a different directory
77
)
88

99
lazy val b = project.in(file("b"))
1010
.settings(
1111
Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar")),
1212
scalacOptions += "-Ycheck:all",
1313
)
14+
.settings(
15+
fork := true, // we have to fork the JVM if we actually want to run the code with correct failure semantics
16+
Runtime / unmanagedClasspath += Attributed.blank((ThisBuild / baseDirectory).value / "a-result-types-classes"), // make sure the java classes are visible at runtime
17+
)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
> a/compile
22
# Test depending on a java static final result, and method result through TASTy
3-
> b/compile
3+
> b/run

0 commit comments

Comments
 (0)