Skip to content

Commit

Permalink
Ensure --cli-default-scala-version is respected by --scalac-help
Browse files Browse the repository at this point in the history
  • Loading branch information
Gedochao committed Jul 24, 2024
1 parent daa8b27 commit 7aa91a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T],
updatedScalacOptions = scalacOptions.withScalacExtraOptions(shared.scalacExtra)
if updatedScalacOptions.exists(ScalacOptions.ScalacPrintOptions)
logger = shared.logger
artifacts <- buildOptions.artifacts(logger, Scope.Main).toOption
fixedBuildOptions = buildOptions.copy(scalaOptions =
buildOptions.scalaOptions.copy(defaultScalaVersion = Some(ScalaCli.getDefaultScalaVersion))
)
artifacts <- fixedBuildOptions.artifacts(logger, Scope.Main).toOption
scalaArtifacts <- artifacts.scalaOpt
compilerClassPath = scalaArtifacts.compilerClassPath
scalaVersion = scalaArtifacts.params.scalaVersion
compileClassPath = artifacts.compileClassPath
simpleScalaCompiler = SimpleScalaCompiler("java", Nil, scaladoc = false)
javacOptions = buildOptions.javaOptions.javacOptions.map(_.value)
javaHome = buildOptions.javaHomeLocation().value
javacOptions = fixedBuildOptions.javaOptions.javacOptions.map(_.value)
javaHome = fixedBuildOptions.javaHomeLocation().value
} {
val exitCode = simpleScalaCompiler.runSimpleScalacLike(
scalaVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,4 +904,19 @@ class SipScalaTests extends ScalaCliSuite with SbtTestHelper with MillTestHelper
expect(r.out.trim() == sv)
}
}

test("scalac help respects --cli-default-scala-version") {
TestInputs.empty.fromRoot { root =>
val sv = Constants.scala3NextRc
val launcherVersionOverrideHelp =
os.proc(TestUtil.cli, "--cli-default-scala-version", sv, "--scalac-help")
.call(cwd = root).out.trim()
val standardVersionOverrideHelp =
os.proc(TestUtil.cli, "--scalac-help", "-S", sv)
.call(cwd = root).out.trim()
val migrationPrefix = sv.take(2) + (sv.charAt(2).asDigit + 1).toString
expect(launcherVersionOverrideHelp.contains(s"$migrationPrefix-migration"))
expect(launcherVersionOverrideHelp == standardVersionOverrideHelp)
}
}
}

0 comments on commit 7aa91a8

Please sign in to comment.