Fix scripted tests

This commit is contained in:
Eugene Yokota 2024-06-09 20:28:32 -04:00
parent 862f4c4bca
commit 40d7c59c54
23 changed files with 77 additions and 57 deletions

View File

@ -19,9 +19,9 @@
## for command cross building you do need crossScalaVerions on root
> set root/crossScalaVersions := Seq("2.12.19", "2.13.12")
> + build
$ exists target/out/jvm/scala-2.12.17/foo
$ exists target/out/jvm/scala-2.13.1/foo
$ exists target/out/jvm/scala-2.12.17/bar
$ exists target/out/jvm/scala-2.13.1/bar
$ exists target/out/jvm/scala-2.12.17/client
$ exists target/out/jvm/scala-2.13.1/client
$ exists target/out/jvm/scala-2.12.19/foo
$ exists target/out/jvm/scala-2.13.12/foo
$ exists target/out/jvm/scala-2.12.19/bar
$ exists target/out/jvm/scala-2.13.12/bar
$ exists target/out/jvm/scala-2.12.19/client
$ exists target/out/jvm/scala-2.13.12/client

View File

@ -1,4 +1,4 @@
lazy val scala3 = "3.2.1"
lazy val scala3 = "3.3.1"
lazy val scala213 = "2.13.1"
crossScalaVersions := Seq(scala3, scala213)
@ -27,3 +27,5 @@ lazy val extrasProj = (project in file("extras"))
.settings(
name := "foo-extras",
)
lazy val externalProj = ProjectRef(file("ref"), "external")

View File

@ -11,7 +11,8 @@ lazy val root = (project in file("."))
lazy val core = (project in file("core"))
.settings(
crossScalaVersions := Seq(scala212, scala213))
crossScalaVersions := Seq(scala212, scala213),
)
lazy val module = (project in file("module"))
.dependsOn(core)

View File

@ -0,0 +1,11 @@
-> ++2.12.0-magic
> ++2.12.19
> clean
> ++2.13.12 compile
$ exists target/out/jvm/scala-2.13.12/core/core_2.13-0.1.0-SNAPSHOT-noresources.jar
-$ exists target/out/jvm/scala-2.13.12/module
-$ exists target/out/jvm/scala-2.12.19/module

View File

@ -1,11 +0,0 @@
-> ++2.12.0-magic
> ++2.12.12
> clean
> ++2.13.12 compile
$ exists target/out/jvm/scala-2.13.1/core/core_2.13-0.1.0-SNAPSHOT-noresources.jar
-$ exists target/out/jvm/scala-2.13.1/module
-$ exists target/out/jvm/scala-2.12.18/module

View File

@ -43,5 +43,5 @@ $ absent target/out/jvm/scala-2.12.19/root/api/index.js
> clean
$ absent target/out/jvm/scala-2.12.19/root/api/A$.html
> doc
$ exists target/out/jvm/scala-2.13.3/root/api/A$.html
$ exists target/out/jvm/scala-2.13.3/root/api/B$.html
$ exists target/out/jvm/scala-2.13.12/root/api/A$.html
$ exists target/out/jvm/scala-2.13.12/root/api/B$.html

View File

@ -1,2 +1,2 @@
> compile
$ exists target/out/jvm/scala-2.12.12/root/src_managed/BuildInfo.scala
$ exists target/out/jvm/scala-2.12.19/root/src_managed/BuildInfo.scala

View File

@ -1,4 +1,4 @@
$ mkdir target/out/jvm/scala-2.12.18/delete-target/delete-target_2.12-0.1.0-SNAPSHOT.jar
$ touch target/out/jvm/scala-2.12.18/delete-target/delete-target_2.12-0.1.0-SNAPSHOT.jar/hello
$ mkdir target/out/jvm/scala-2.12.19/delete-target/delete-target_2.12-0.1.0-SNAPSHOT.jar
$ touch target/out/jvm/scala-2.12.19/delete-target/delete-target_2.12-0.1.0-SNAPSHOT.jar/hello
-> package
$ exists target/out/jvm/scala-2.12.18/delete-target/delete-target_2.12-0.1.0-SNAPSHOT.jar/hello
$ exists target/out/jvm/scala-2.12.19/delete-target/delete-target_2.12-0.1.0-SNAPSHOT.jar/hello

View File

@ -1,3 +1,3 @@
> + compile
$ exists target/out/jvm/scala-2.12.12/foo
$ exists target/out/jvm/scala-2.13.1/foo
$ exists target/out/jvm/scala-2.12.19/foo
$ exists target/out/jvm/scala-2.13.12/foo

View File

@ -87,7 +87,10 @@ lazy val v5 = project
)
def localCache =
ivyPaths := IvyPaths(baseDirectory.value, Some((ThisBuild / baseDirectory).value / "ivy-cache"))
ivyPaths := IvyPaths(
baseDirectory.value.toString,
Some(((ThisBuild / baseDirectory).value / "ivy-cache").toString)
)
lazy val checkUpdate = taskKey[Unit]("check the resolved artifacts")

View File

@ -7,19 +7,23 @@ val commonSettings = Seq[Def.Setting[_]](
organization := "org.example",
version := "1.0-SNAPSHOT",
scalaVersion := "2.11.7",
ivyPaths := IvyPaths((baseDirectory in ThisBuild).value, Some(ivyHome.value)),
ivyPaths := IvyPaths((baseDirectory in ThisBuild).value.toString, Some(ivyHome.value.toString)),
fullResolvers := fullResolvers.value.filterNot(_ == projectResolver.value)
)
lazy val bippy = project settings (
commonSettings,
resolvers += Resolver.file("ivy-local", file(sys.props("user.home")) / ".ivy2" / "local")(Resolver.ivyStylePatterns),
resolvers += Resolver
.file("ivy-local", file(sys.props("user.home")) / ".ivy2" / "local")(Resolver.ivyStylePatterns),
publishTo := Some(Resolver.file("local-repo", localRepo.value))
)
lazy val myapp = project settings (
commonSettings,
resolvers += new MavenRepository("local-repo", localRepo.value.toURL.toString) withLocalIfFile false,
resolvers += new MavenRepository(
"local-repo",
localRepo.value.toURL.toString
) withLocalIfFile false,
libraryDependencies += "org.example" %% "bippy" % "1.0-SNAPSHOT"
)
@ -29,7 +33,8 @@ InputKey[Unit]("check") := {
val jarname = "bippy_2.11-1.0-SNAPSHOT-sources.jar"
val file1 = ivyHome.value / "cache" / "org.example" / "bippy_2.11" / "srcs" / jarname
val file2 = ivyHome.value / "maven-cache" / "org" / "example" / "bippy_2.11" / "1.0-SNAPSHOT" / jarname
val file2 =
ivyHome.value / "maven-cache" / "org" / "example" / "bippy_2.11" / "1.0-SNAPSHOT" / jarname
val file = if (file1.exists()) file1 else if (file2.exists) file2 else sys error s"$jarname MIA"
val jar = new java.util.jar.JarFile(file)
val s = IO readStream jar.getInputStream(jar.getJarEntry("Bippy.scala"))

View File

@ -1,7 +1,7 @@
Configurations.Compile / scalaSource := (sourceDirectory.value / " scala test ")
Configurations.Compile / javaSource := (sourceDirectory.value / " java test ")
TaskKey[Unit]("init") := {
TaskKey[Unit]("init0") := {
val ss = (Configurations.Compile / scalaSource).value
val js = (Configurations.Compile / javaSource).value
import IO._

View File

@ -4,11 +4,13 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
val commonSettings = Seq(
organization := "com.example",
version := "0.1.0",
ivyPaths := IvyPaths((LocalRootProject / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache"))
ivyPaths := IvyPaths(
(LocalRootProject / baseDirectory).value.toString,
Some(((LocalRootProject / target).value / "ivy-cache").toString)
)
)
lazy val app = (project in file("app")).
settings(commonSettings: _*)
lazy val app = (project in file("app")).settings(commonSettings: _*)
name := "generated-root-no-publish"
commonSettings

View File

@ -3,4 +3,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
organization := "com.example"
version := "0.1.0"
ivyPaths := IvyPaths((LocalRootProject / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache"))
ivyPaths := IvyPaths(
(LocalRootProject / baseDirectory).value.toString,
Some(((LocalRootProject / target).value / "ivy-cache").toString)
)

View File

@ -7,12 +7,17 @@ lazy val root = (project in file("."))
)
lazy val commonSettings = Seq(
ivyPaths := IvyPaths((baseDirectory in ThisBuild).value, Some((target in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths(
(baseDirectory in ThisBuild).value.toString,
Some(((target in LocalRootProject).value / "ivy-cache").toString)
),
publishTo := Some(Resolver.file("test-publish", (baseDirectory in ThisBuild).value / "repo/")),
// to get sbt artifacts
resolvers += {
val ivyHome = Classpaths.bootIvyHome(appConfiguration.value) getOrElse sys.error("Launcher did not provide the Ivy home directory.")
Resolver.file("real-local", ivyHome / "local")(Resolver.ivyStylePatterns)
val ivyHome = Classpaths.bootIvyHome(appConfiguration.value) getOrElse sys.error(
"Launcher did not provide the Ivy home directory."
)
Resolver.file("real-local", ivyHome / "local")(Resolver.ivyStylePatterns)
},
resolvers += Resolver.mavenLocal,
resolvers += ("test-repo" at ((baseDirectory in ThisBuild).value / "repo/").asURL.toString)

View File

@ -1,4 +1,4 @@
commandProgress += new ExecuteProgress2 {
commandProgress += new ExecuteProgress2:
override def beforeCommand(cmd: String, state: State): Unit = {
EventLog.logs += (s"BEFORE: $cmd")
// assert that `state` is the current state indeed
@ -7,21 +7,20 @@ commandProgress += new ExecuteProgress2 {
}
override def afterCommand(cmd: String, result: Either[Throwable, State]): Unit = {
EventLog.logs += (s"AFTER: $cmd")
result.left.foreach(EventLog.errors +=)
result.left.foreach(EventLog.errors += _)
}
override def initial(): Unit = {}
override def afterRegistered(
task: Task[_],
allDeps: Iterable[Task[_]],
pendingDeps: Iterable[Task[_]]
): Unit = {}
override def afterReady(task: Task[_]): Unit = {}
override def beforeWork(task: Task[_]): Unit = {}
override def afterWork[A](task: Task[A], result: Either[Task[A], Result[A]]): Unit = {}
override def afterCompleted[A](task: Task[A], result: Result[A]): Unit = {}
override def afterAllCompleted(results: RMap[Task, Result]): Unit = {}
override def stop(): Unit = {}
}
task: TaskId[?],
allDeps: Iterable[TaskId[?]],
pendingDeps: Iterable[TaskId[?]]
): Unit = ()
override def afterReady(task: TaskId[_]): Unit = ()
override def beforeWork(task: TaskId[_]): Unit = ()
override def afterWork[A](task: TaskId[A], result: Either[TaskId[A], Result[A]]): Unit = ()
override def afterCompleted[A](task: TaskId[A], result: Result[A]): Unit = ()
override def afterAllCompleted(results: RMap[TaskId, Result]): Unit = ()
override def stop(): Unit = ()
val check = taskKey[Unit]("Check basic command events")
val checkParseError = taskKey[Unit]("Check that parse error is recorded")

View File

@ -6,14 +6,14 @@ val checkReport = taskKey[Unit]("Check the test reports")
val checkNoReport = taskKey[Unit]("Check that no reports are present")
val oneSecondReportFile =
"target/out/jvm/scala-2.12.18/root/test-reports/TEST-a.pkg.OneSecondTest.xml"
"target/out/jvm/scala-2.12.19/root/test-reports/TEST-a.pkg.OneSecondTest.xml"
val failingReportFile =
"target/out/jvm/scala-2.12.18/root/test-reports/TEST-another.pkg.FailingTest.xml"
"target/out/jvm/scala-2.12.19/root/test-reports/TEST-another.pkg.FailingTest.xml"
val flatSuiteReportFile =
"target/out/jvm/scala-2.12.18/root/test-reports/TEST-my.scalatest.MyFlatSuite.xml"
"target/out/jvm/scala-2.12.19/root/test-reports/TEST-my.scalatest.MyFlatSuite.xml"
val nestedSuitesReportFile =
"target/out/jvm/scala-2.12.18/root/test-reports/TEST-my.scalatest.MyNestedSuites.xml"
"target/out/jvm/scala-2.12.19/root/test-reports/TEST-my.scalatest.MyNestedSuites.xml"
val scalatest = "org.scalatest" %% "scalatest" % "3.0.5"
val junitinterface = "com.novocode" % "junit-interface" % "0.11"