From 55021f7c18979e461c4ffbe181bc38a7bc03f9e1 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 4 Feb 2024 03:55:28 -0500 Subject: [PATCH] Restore scala3-tasty-management test --- .../scala3-tasty-management/build.sbt | 24 +++++++++++++++++++ .../src/main/scala/A.scala | 3 +++ .../src/main/scala/B.scala | 3 +++ .../scala3-tasty-management/test | 10 ++++++++ 4 files changed, 40 insertions(+) create mode 100644 sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt create mode 100644 sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/A.scala create mode 100644 sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/B.scala create mode 100644 sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test diff --git a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt new file mode 100644 index 00000000000..8264fcba022 --- /dev/null +++ b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/build.sbt @@ -0,0 +1,24 @@ +import sbt.io.Using +import xsbti.compile.TastyFiles + +ThisBuild / scalaVersion := "3.3.1" + +TaskKey[Unit]("check") := { + assert((Compile / auxiliaryClassFiles).value == Seq(TastyFiles.instance)) + assert((Test / auxiliaryClassFiles).value == Seq(TastyFiles.instance)) +} + +TaskKey[Unit]("check2") := checkTastyFiles(true, true).value + +TaskKey[Unit]("check3") := checkTastyFiles(true, false).value + +def checkTastyFiles(aExists: Boolean, bExists: Boolean) = Def.task { + val p = (Compile / packageBin).value + val c = fileConverter.value + Using.jarFile(false)(c.toPath(p).toFile()): jar => + if aExists then assert(jar.getJarEntry("A.tasty") ne null) + else assert(jar.getJarEntry("A.tasty") eq null) + + if bExists then assert(jar.getJarEntry("B.tasty") ne null) + else assert(jar.getJarEntry("B.tasty") eq null) +} diff --git a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/A.scala b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/A.scala new file mode 100644 index 00000000000..c52c4580821 --- /dev/null +++ b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/A.scala @@ -0,0 +1,3 @@ +class A { + def initialized: Boolean = false +} diff --git a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/B.scala b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/B.scala new file mode 100644 index 00000000000..066d5fc591c --- /dev/null +++ b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/src/main/scala/B.scala @@ -0,0 +1,3 @@ +class B { + def foo(a: A): Boolean = a.initialized +} diff --git a/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test new file mode 100644 index 00000000000..ee22444ea4e --- /dev/null +++ b/sbt-app/src/sbt-test/compiler-project/scala3-tasty-management/test @@ -0,0 +1,10 @@ +> check + +> check2 + +$ delete src/main/scala/B.scala + +> check3 + +# $ exists target/scala-3.0.0-M3/classes/A.tasty +# -$ exists target/scala-3.0.0-M3/classes/B.tasty