Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ jobs:
- name: Print version
run: ./mill -i show project.publish.finalPublishVersion
- name: Publish to Sonatype Central
run: ./mill mill.scalalib.SonatypeCentralPublishModule/ --publishArtifacts '{__[],_,test-runner[2.13.17],test-runner[2.12.20],runner[2.13.17],runner[2.12.20]}.publishArtifacts'
run: ./mill mill.scalalib.SonatypeCentralPublishModule/ --publishArtifacts '{__[],_}.publishArtifacts'
if: env.SHOULD_PUBLISH == 'true'
env:
MILL_PGP_SECRET_BASE64: ${{ secrets.PGP_SECRET }}
Expand Down
63 changes: 31 additions & 32 deletions build.mill.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ object directives extends Cross[Directives](Scala.scala3MainVersions)
object core extends Cross[Core](Scala.scala3MainVersions) with CrossScalaDefaultToInternal
object `build-module` extends Cross[Build](Scala.scala3MainVersions)
with CrossScalaDefaultToInternal
object runner extends Cross[Runner](Scala.runnerScalaVersions) with CrossScalaDefaultToRunner
object `test-runner` extends Cross[TestRunner](Scala.testRunnerScalaVersions)
with CrossScalaDefaultToRunner
object `tasty-lib` extends Cross[TastyLib](Scala.all) with CrossScalaDefaultToInternal
object runner extends Runner
object `test-runner` extends TestRunner
object `tasty-lib` extends Cross[TastyLib](Scala.scala3MainVersions)
with CrossScalaDefaultToInternal
// Runtime classes used within native image on Scala 3 replacing runtime from Scala
object `scala3-runtime` extends Cross[Scala3Runtime](Scala.scala3MainVersions)
with CrossScalaDefaultToInternal
Expand Down Expand Up @@ -437,16 +437,16 @@ trait Core extends ScalaCliCrossSbtModule
def constantsFile: T[PathRef] = Task(persistent = true) {
val dir = Task.dest / "constants"
val dest = dir / "Constants.scala"
val testRunnerMainClass = `test-runner`(Scala.runnerScala3)
val testRunnerMainClass = `test-runner`
.mainClass()
.getOrElse(sys.error("No main class defined for test-runner"))
val runnerMainClass = build.runner(Scala.runnerScala3)
val runnerMainClass = build.runner
.mainClass()
.getOrElse(sys.error("No main class defined for runner"))
val detailedVersionValue =
if (`local-repo`.developingOnStubModules) s"""Some("${vcsState()}")"""
else "None"
val testRunnerOrganization = `test-runner`(Scala.runnerScala3)
val testRunnerOrganization = `test-runner`
.pomSettings()
.organization
val code =
Expand All @@ -466,14 +466,15 @@ trait Core extends ScalaCliCrossSbtModule
| def scalaNativeVersion = "${Deps.Versions.scalaNative}"
|
| def testRunnerOrganization = "$testRunnerOrganization"
| def testRunnerModuleName = "${`test-runner`(Scala.runnerScala3).artifactName()}"
| def testRunnerVersion = "${`test-runner`(Scala.runnerScala3).publishVersion()}"
| def testRunnerModuleName = "${`test-runner`.artifactName()}"
| def testRunnerVersion = "${`test-runner`.publishVersion()}"
| def testRunnerMainClass = "$testRunnerMainClass"
|
| def runnerOrganization = "${build.runner(Scala.runnerScala3).pomSettings().organization}"
| def runnerModuleName = "${build.runner(Scala.runnerScala3).artifactName()}"
| def runnerVersion = "${build.runner(Scala.runnerScala3).publishVersion()}"
| def runnerLegacyVersion = "${Cli.runnerLegacyVersion}"
| def runnerOrganization = "${build.runner.pomSettings().organization}"
| def runnerModuleName = "${build.runner.artifactName()}"
| def runnerVersion = "${build.runner.publishVersion()}"
| def runnerScala30LegacyVersion = "${Cli.runnerScala30LegacyVersion}"
| def runnerScala2LegacyVersion = "${Cli.runnerScala2LegacyVersion}"
| def runnerMainClass = "$runnerMainClass"
|
| def semanticDbPluginOrganization = "${Deps.semanticDbScalac.dep.module.organization
Expand Down Expand Up @@ -744,7 +745,7 @@ trait Build extends ScalaCliCrossSbtModule
options(crossScalaVersion),
directives(crossScalaVersion),
`scala-cli-bsp`,
`test-runner`(crossScalaVersion),
`test-runner`,
`tasty-lib`(crossScalaVersion)
)
override def scalacOptions: T[Seq[String]] = Task {
Expand Down Expand Up @@ -1095,7 +1096,8 @@ trait CliIntegration extends SbtModule with ScalaCliPublishModule with HasTests
| def ammoniteVersion = "${Deps.ammonite.dep.versionConstraint.asString}"
| def defaultGraalVMJavaVersion = "${deps.graalVmJavaVersion}"
| def defaultGraalVMVersion = "${deps.graalVmVersion}"
| def runnerLegacyVersion = "${Cli.runnerLegacyVersion}"
| def runnerScala30LegacyVersion = "${Cli.runnerScala30LegacyVersion}"
| def runnerScala2LegacyVersion = "${Cli.runnerScala2LegacyVersion}"
| def scalaPyVersion = "${Deps.scalaPy.dep.versionConstraint.asString}"
| def scalaPyMaxScalaNative = "${Deps.Versions.maxScalaNativeForScalaPy}"
| def bloopVersion = "${Deps.bloopRifle.dep.versionConstraint.asString}"
Expand Down Expand Up @@ -1275,19 +1277,19 @@ trait CliIntegrationDocker extends SbtModule with ScalaCliPublishModule with Has
)
}

trait Runner extends ScalaCliCrossSbtModule
trait Runner extends SbtModule
with ScalaCliPublishModule
with ScalaCliScalafixLegacyModule {
override def crossScalaVersion: String = crossValue
with ScalaCliScalafixModule {
override def scalaVersion: T[String] = Scala.scala3Lts
override def scalacOptions: T[Seq[String]] = Task {
super.scalacOptions() ++ Seq("-release", "8")
super.scalacOptions() ++ Seq("-release", "8", "-deprecation")
}
override def mainClass: T[Option[String]] = Some("scala.cli.runner.Runner")
override def sources: T[Seq[PathRef]] = Task.Sources {
val scala3DirNames =
if (crossScalaVersion.startsWith("3.")) {
if (scalaVersion().startsWith("3.")) {
val name =
if (crossScalaVersion.contains("-RC")) "scala-3-unstable"
if (scalaVersion().contains("-RC")) "scala-3-unstable"
else "scala-3-stable"
Seq(name)
}
Expand All @@ -1298,12 +1300,12 @@ trait Runner extends ScalaCliCrossSbtModule
}
}

trait TestRunner extends ScalaCliCrossSbtModule
trait TestRunner extends SbtModule
with ScalaCliPublishModule
with ScalaCliScalafixLegacyModule {
override def crossScalaVersion: String = crossValue
with ScalaCliScalafixModule {
override def scalaVersion: T[String] = Scala.scala3Lts
override def scalacOptions: T[Seq[String]] = Task {
super.scalacOptions() ++ Seq("-release", "8")
super.scalacOptions() ++ Seq("-release", "8", "-deprecation")
}
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(
Deps.asm,
Expand All @@ -1315,7 +1317,7 @@ trait TestRunner extends ScalaCliCrossSbtModule

trait TastyLib extends ScalaCliCrossSbtModule
with ScalaCliPublishModule
with ScalaCliScalafixLegacyModule {
with ScalaCliScalafixModule {
override def crossScalaVersion: String = crossValue
def constantsFile: T[PathRef] = Task(persistent = true) {
val dir = Task.dest / "constants"
Expand Down Expand Up @@ -1345,12 +1347,9 @@ object `local-repo` extends LocalRepo {
*/
def developingOnStubModules = false

override def stubsModules: Seq[PublishLocalNoFluff] =
for {
sv <- Scala.runnerScalaVersions
proj <- Seq(runner, `test-runner`)
} yield proj(sv)
override def version: T[String] = runner(Scala.runnerScala3).publishVersion()
override def stubsModules: Seq[PublishLocalNoFluff] = Seq(runner, `test-runner`)

override def version: T[String] = runner.publishVersion()
}

// Helper CI commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,23 @@ class CompileTests213 extends CompileTestDefinitions with Test213 {
| }
|}""".stripMargin
).fromRoot { root =>
val result = os.proc(TestUtil.cli, "test", ".").call(
val result = os.proc(TestUtil.cli, "test", ".", extraOptions).call(
cwd = root,
check = false,
mergeErrIntoOut = true
)
val separator = if (Properties.isWin) "\\" else "/"
val separator = if (Properties.isWin) "\\" else "/"
val graalVmVersion = Constants.defaultGraalVMJavaVersion
val legacyRunnerVersion = Constants.runnerScala2LegacyVersion
val ltsPrefix = Constants.scala3LtsPrefix

val expectedOutput =
s"""|Compiling project (Scala ${Constants.scala213}, JVM (${Constants
.defaultGraalVMJavaVersion}))
|Compiled project (Scala ${Constants.scala213}, JVM (${Constants
.defaultGraalVMJavaVersion}))
|Compiling project (test, Scala ${Constants.scala213}, JVM (${Constants
.defaultGraalVMJavaVersion}))
s"""|Compiling project (Scala $actualScalaVersion, JVM ($graalVmVersion))
|Compiled project (Scala $actualScalaVersion, JVM ($graalVmVersion))
|[warn] Scala $actualScalaVersion is no longer supported by the test-runner module.
|[warn] Defaulting to a legacy test-runner module version: $legacyRunnerVersion.
|[warn] To use the latest test-runner, upgrade Scala to at least $ltsPrefix.
|Compiling project (test, Scala $actualScalaVersion, JVM ($graalVmVersion))
|[info] .${separator}Test.test.scala:6:5
|[info] scala.Predef.ArrowAssoc[Int](1).->[String]("test")
|[info] scala.Predef.ArrowAssoc[Int](1).->[String]("test")
Expand All @@ -71,8 +74,7 @@ class CompileTests213 extends CompileTestDefinitions with Test213 {
|[error] example error message
|[error] Scala2Example.macroMethod(1 -> "test")
|[error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|Error compiling project (test, Scala ${Constants.scala213}, JVM (${Constants
.defaultGraalVMJavaVersion}))
|Error compiling project (test, Scala $actualScalaVersion, JVM ($graalVmVersion))
|Compilation failed
|""".stripMargin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,11 @@ abstract class RunTestDefinitions
val res = os.proc(TestUtil.cli, "run", ".", "--runner", extraOptions)
.call(cwd = root, stderr = os.Pipe)
expect(res.out.trim() == expectedMessage)
expect(!res.err.trim().contains(legacyRunnerWarning))
val legacyWarningCheck = {
val check = res.err.trim().contains(legacyRunnerWarning)
if (actualScalaVersion.startsWith("2")) check else !check
}
expect(legacyWarningCheck)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class RunTestsDefault extends RunTestDefinitions
scalaVersion <- TestUtil.legacyScalaVersionsOnePerMinor
expectedMessage = "Hello, world!"
expectedWarning =
s"Defaulting to a legacy runner module version: ${Constants.runnerLegacyVersion}"
s"Defaulting to a legacy runner module version: ${Constants.runnerScala30LegacyVersion}"
}
test(
s"run a simple hello world with the runner module on the classpath and Scala $scalaVersion (legacy)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
package scala.cli.integration

class TestTests212 extends TestTestDefinitions with Test212
import com.eed3si9n.expecty.Expecty.expect

import scala.cli.integration.TestUtil.StringOps

class TestTests212 extends TestTestDefinitions with Test212 {
test(s"run a simple test with Scala $actualScalaVersion (legacy)") {
val expectedMessage = "Hello, world!"
TestInputs(os.rel / "example.test.scala" ->
s"""//> using dep com.novocode:junit-interface:0.11
|import org.junit.Test
|
|class MyTests {
| @Test
| def foo(): Unit = {
| assert(2 + 2 == 4)
| println("$expectedMessage")
| }
|}
|""".stripMargin).fromRoot { root =>
val expectedWarning =
s"Defaulting to a legacy test-runner module version: ${Constants.runnerScala2LegacyVersion}"
val res =
os.proc(TestUtil.cli, "test", ".", extraOptions)
.call(cwd = root, stderr = os.Pipe)
val out = res.out.trim()
expect(out.contains(expectedMessage))
val err = res.err.trim()
expect(err.contains(expectedWarning))
expect(err.countOccurrences(expectedWarning) == 1)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
package scala.cli.integration

class TestTests213 extends TestTestDefinitions with Test213
import com.eed3si9n.expecty.Expecty.expect

import scala.cli.integration.TestUtil.StringOps

class TestTests213 extends TestTestDefinitions with Test213 {
test(s"run a simple test with Scala $actualScalaVersion (legacy)") {
val expectedMessage = "Hello, world!"
TestInputs(os.rel / "example.test.scala" ->
s"""//> using dep com.novocode:junit-interface:0.11
|import org.junit.Test
|
|class MyTests {
| @Test
| def foo(): Unit = {
| assert(2 + 2 == 4)
| println("$expectedMessage")
| }
|}
|""".stripMargin).fromRoot { root =>
val expectedWarning =
s"Defaulting to a legacy test-runner module version: ${Constants.runnerScala2LegacyVersion}"
val res =
os.proc(TestUtil.cli, "test", ".", extraOptions)
.call(cwd = root, stderr = os.Pipe)
val out = res.out.trim()
expect(out.contains(expectedMessage))
val err = res.err.trim()
expect(err.contains(expectedWarning))
expect(err.countOccurrences(expectedWarning) == 1)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TestTestsDefault extends TestTestDefinitions with TestDefault {
scalaVersion <- TestUtil.legacyScalaVersionsOnePerMinor
expectedMessage = "Hello, world!"
expectedWarning =
s"Defaulting to a legacy test-runner module version: ${Constants.runnerLegacyVersion}"
s"Defaulting to a legacy test-runner module version: ${Constants.runnerScala30LegacyVersion}"
}
test(s"run a simple test with Scala $scalaVersion (legacy)") {
TestInputs(os.rel / "example.test.scala" ->
Expand Down
12 changes: 11 additions & 1 deletion modules/options/src/main/scala/scala/build/Artifacts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,18 @@ object Artifacts {
scalaVersion = scalaParams.scalaVersion
} yield scalaVersion).getOrElse(defaultScalaVersion)

val shouldUseLegacyRunners =
val shouldUseLegacyScala3Runners =
scalaVersion.startsWith("3") &&
scalaVersion.coursierVersion < s"$scala3LtsPrefix.0".coursierVersion
val shouldUseLegacyScala2Runners = scalaVersion.startsWith("2")
val shouldUseLegacyRunners = shouldUseLegacyScala2Runners || shouldUseLegacyScala3Runners

val jvmTestRunnerDependencies =
if addJvmTestRunner then {
val runnerLegacyVersion =
if scalaVersion.startsWith("3")
then runnerScala30LegacyVersion
else runnerScala2LegacyVersion
val testRunnerVersion0 =
if shouldUseLegacyRunners then {
logger.message(
Expand Down Expand Up @@ -471,6 +477,10 @@ object Artifacts {
else Nil
val runnerVersion0 =
if shouldUseLegacyRunners then {
val runnerLegacyVersion =
if shouldUseLegacyScala3Runners
then runnerScala30LegacyVersion
else runnerScala2LegacyVersion
logger.message(
s"""$warnPrefix Scala $scalaVersion is no longer supported by the runner module.
|$warnPrefix Defaulting to a legacy runner module version: $runnerLegacyVersion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ final case class StackTracePrinter(
}

object StackTracePrinter {

lazy val coloredStackTraces: Boolean =
sys.props.get("scala.colored-stack-traces")
.map(_.toLowerCase(Locale.ROOT))
.forall(_ == "true")

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TastyBuffer(initialSize: Int) {
/** Like writeNat, but for longs. Note that the binary representation of LongNat is identical to
* Nat if the long value is in the range Int.MIN_VALUE to Int.MAX_VALUE.
*/
def writeLongNat(x: Long): Unit = {
private def writeLongNat(x: Long): Unit = {
def writePrefix(x: Long): Unit = {
val y = x >>> 7
if (y != 0L) writePrefix(y)
Expand All @@ -79,7 +79,7 @@ class TastyBuffer(initialSize: Int) {
def getNat(at: Addr): Int = getLongNat(at).toInt

/** The long natural number at address `at` */
def getLongNat(at: Addr): Long = {
private def getLongNat(at: Addr): Long = {
var b = 0L
var x = 0L
var idx = at.index
Expand Down
Loading