Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Scala 3 Next RC to 3.5.0-RC3 #3002

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1967,156 +1967,157 @@ abstract class RunTestDefinitions
}
}

test("offline mode should fail on missing artifacts") {
// Kill bloop deamon to test scalac fallback
os.proc(TestUtil.cli, "--power", "bloop", "exit")
.call(cwd = os.pwd)

val depScalaVersion = actualScalaVersion match {
case sv if sv.startsWith("2.12") => "2.12"
case sv if sv.startsWith("2.13") => "2.13"
case _ => "3"
}
if (!actualScalaVersion.contains("RC"))
test("offline mode should fail on missing artifacts") {
// Kill bloop deamon to test scalac fallback
os.proc(TestUtil.cli, "--power", "bloop", "exit")
.call(cwd = os.pwd)

val depScalaVersion = actualScalaVersion match {
case sv if sv.startsWith("2.12") => "2.12"
case sv if sv.startsWith("2.13") => "2.13"
case _ => "3"
}

val dep = s"com.lihaoyi:os-lib_$depScalaVersion:0.10.2"
val inputs = TestInputs(
os.rel / "NoDeps.scala" ->
"""//> using jvm zulu:11
|object NoDeps extends App {
| println("Hello from NoDeps")
|}
|""".stripMargin,
os.rel / "WithDeps.scala" ->
s"""//> using jvm zulu:11
|//> using dep $dep
|
|object WithDeps extends App {
| println("Hello from WithDeps")
|}
|""".stripMargin
)
inputs.fromRoot { root =>
val cachePath = root / ".cache"
os.makeDir(cachePath)
val dep = s"com.lihaoyi:os-lib_$depScalaVersion:0.10.2"
val inputs = TestInputs(
os.rel / "NoDeps.scala" ->
"""//> using jvm zulu:11
|object NoDeps extends App {
| println("Hello from NoDeps")
|}
|""".stripMargin,
os.rel / "WithDeps.scala" ->
s"""//> using jvm zulu:11
|//> using dep $dep
|
|object WithDeps extends App {
| println("Hello from WithDeps")
|}
|""".stripMargin
)
inputs.fromRoot { root =>
val cachePath = root / ".cache"
os.makeDir(cachePath)

val extraEnv = Map("COURSIER_CACHE" -> cachePath.toString)
val extraEnv = Map("COURSIER_CACHE" -> cachePath.toString)

val emptyCacheWalkSize = os.walk(cachePath).size
val emptyCacheWalkSize = os.walk(cachePath).size

val noArtifactsRes = os.proc(
TestUtil.cli,
"--power",
"NoDeps.scala",
extraOptions,
"--offline",
"--cache",
cachePath.toString
)
.call(cwd = root, check = false, mergeErrIntoOut = true)
expect(noArtifactsRes.exitCode == 1)

// Cache unchanged
expect(emptyCacheWalkSize == os.walk(cachePath).size)

// Download the artifacts for scala
os.proc(TestUtil.cs, "install", s"scala:$actualScalaVersion")
.call(cwd = root, env = extraEnv)
os.proc(TestUtil.cs, "install", s"scalac:$actualScalaVersion")
.call(cwd = root, env = extraEnv)
(if (actualScalaVersion.startsWith("3")) Some("scala3-sbt-bridge")
else if (
actualScalaVersion.startsWith("2.13.") &&
actualScalaVersion.coursierVersion >= "2.13.12".coursierVersion
)
Some("scala2-sbt-bridge")
else None)
.foreach { bridgeArtifactName =>
os.proc(TestUtil.cs, "fetch", s"org.scala-lang:$bridgeArtifactName:$actualScalaVersion")
.call(cwd = root, env = extraEnv)
}

// Download JVM that won't suit Bloop, also no Bloop artifacts are present
os.proc(TestUtil.cs, "java-home", "--jvm", "zulu:11")
.call(cwd = root, env = extraEnv)
val noArtifactsRes = os.proc(
TestUtil.cli,
"--power",
"NoDeps.scala",
extraOptions,
"--offline",
"--cache",
cachePath.toString
)
.call(cwd = root, check = false, mergeErrIntoOut = true)
expect(noArtifactsRes.exitCode == 1)

val scalaJvmCacheWalkSize = os.walk(cachePath).size
// Cache unchanged
expect(emptyCacheWalkSize == os.walk(cachePath).size)

// Download the artifacts for scala
os.proc(TestUtil.cs, "install", s"scala:$actualScalaVersion")
.call(cwd = root, env = extraEnv)
os.proc(TestUtil.cs, "install", s"scalac:$actualScalaVersion")
.call(cwd = root, env = extraEnv)
(if (actualScalaVersion.startsWith("3")) Some("scala3-sbt-bridge")
else if (
actualScalaVersion.startsWith("2.13.") &&
actualScalaVersion.coursierVersion >= "2.13.12".coursierVersion
)
Some("scala2-sbt-bridge")
else None)
.foreach { bridgeArtifactName =>
os.proc(TestUtil.cs, "fetch", s"org.scala-lang:$bridgeArtifactName:$actualScalaVersion")
.call(cwd = root, env = extraEnv)
}

val scalaAndJvmRes = os.proc(
TestUtil.cli,
"--power",
"NoDeps.scala",
extraOptions,
"--offline",
"--cache",
cachePath.toString,
"-v",
"-v"
)
.call(cwd = root, mergeErrIntoOut = true)
expect(scalaAndJvmRes.exitCode == 0)
expect(scalaAndJvmRes.out.trim().contains(
"Offline mode is ON and Bloop could not be fetched from the local cache, using scalac as fallback"
))
expect(scalaAndJvmRes.out.trim().contains("Hello from NoDeps"))
// Download JVM that won't suit Bloop, also no Bloop artifacts are present
os.proc(TestUtil.cs, "java-home", "--jvm", "zulu:11")
.call(cwd = root, env = extraEnv)

// Cache unchanged
expect(scalaJvmCacheWalkSize == os.walk(cachePath).size)
val scalaJvmCacheWalkSize = os.walk(cachePath).size

// Missing dependencies
for {
(cliOption, extraEnvMode) <- Seq(
"--offline" -> Map.empty[String, String],
"-Dcoursier.mode=offline" -> Map.empty[String, String],
"" -> Map("COURSIER_MODE" -> "offline")
)
} {
val missingDepsRes = os.proc(
val scalaAndJvmRes = os.proc(
TestUtil.cli,
"--power",
cliOption,
"WithDeps.scala",
"NoDeps.scala",
extraOptions,
"--offline",
"--cache",
cachePath.toString
cachePath.toString,
"-v",
"-v"
)
.call(cwd = root, check = false, mergeErrIntoOut = true, env = extraEnvMode)
expect(missingDepsRes.exitCode == 1)
expect(missingDepsRes.out.trim().contains("Error downloading com.lihaoyi:os-lib"))
.call(cwd = root, mergeErrIntoOut = true)
expect(scalaAndJvmRes.exitCode == 0)
expect(scalaAndJvmRes.out.trim().contains(
"Offline mode is ON and Bloop could not be fetched from the local cache, using scalac as fallback"
))
expect(scalaAndJvmRes.out.trim().contains("Hello from NoDeps"))

// Cache unchanged
expect(scalaJvmCacheWalkSize == os.walk(cachePath).size)
}

// Download dependencies
os.proc(TestUtil.cs, "fetch", dep)
.call(cwd = root, env = extraEnv)
// Missing dependencies
for {
(cliOption, extraEnvMode) <- Seq(
"--offline" -> Map.empty[String, String],
"-Dcoursier.mode=offline" -> Map.empty[String, String],
"" -> Map("COURSIER_MODE" -> "offline")
)
} {
val missingDepsRes = os.proc(
TestUtil.cli,
"--power",
cliOption,
"WithDeps.scala",
extraOptions,
"--cache",
cachePath.toString
)
.call(cwd = root, check = false, mergeErrIntoOut = true, env = extraEnvMode)
expect(missingDepsRes.exitCode == 1)
expect(missingDepsRes.out.trim().contains("Error downloading com.lihaoyi:os-lib"))

val withDependencyCacheWalkSize = os.walk(cachePath).size
// Cache unchanged
expect(scalaJvmCacheWalkSize == os.walk(cachePath).size)
}

val depsRes = os.proc(
TestUtil.cli,
"--power",
"WithDeps.scala",
extraOptions,
"--offline",
"--cache",
cachePath.toString,
"-v",
"-v"
)
.call(cwd = root, mergeErrIntoOut = true)
expect(depsRes.exitCode == 0)
expect(
depsRes.out.trim().contains(
"Offline mode is ON and Bloop could not be fetched from the local cache, using scalac as fallback"
// Download dependencies
os.proc(TestUtil.cs, "fetch", dep)
.call(cwd = root, env = extraEnv)

val withDependencyCacheWalkSize = os.walk(cachePath).size

val depsRes = os.proc(
TestUtil.cli,
"--power",
"WithDeps.scala",
extraOptions,
"--offline",
"--cache",
cachePath.toString,
"-v",
"-v"
)
)
expect(depsRes.out.trim().contains("Hello from WithDeps"))
.call(cwd = root, mergeErrIntoOut = true)
expect(depsRes.exitCode == 0)
expect(
depsRes.out.trim().contains(
"Offline mode is ON and Bloop could not be fetched from the local cache, using scalac as fallback"
)
)
expect(depsRes.out.trim().contains("Hello from WithDeps"))

// Cache changed
expect(withDependencyCacheWalkSize == os.walk(cachePath).size)
// Cache changed
expect(withDependencyCacheWalkSize == os.walk(cachePath).size)
}
}
}

test("JVM id is printed with compilation info correctly") {
val msg = "Hello"
Expand Down
2 changes: 1 addition & 1 deletion project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Scala {
def scala3LtsPrefix = "3.3" // used for the LTS version tags
def scala3Lts = s"$scala3LtsPrefix.3" // the LTS version currently used in the build
def scala3Next = "3.4.2" // the newest/next version of Scala
def scala3NextRc = "3.5.0-RC2" // the latest RC version of Scala Next
def scala3NextRc = "3.5.0-RC3" // the latest RC version of Scala Next

// The Scala version used to build the CLI itself.
def defaultInternal = sys.props.get("scala.version.internal").getOrElse(scala3Lts)
Expand Down
Loading