Skip to content

Commit

Permalink
Ensure --version passed to the default command together with `--off…
Browse files Browse the repository at this point in the history
…line` doesn't look for the latest version online (#3207)
  • Loading branch information
Gedochao authored Sep 25, 2024
1 parent 68b3ce8 commit 646e2be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ class Default(actualHelp: => RuntimeCommandsHelp)

override def runCommand(options: DefaultOptions, args: RemainingArgs, logger: Logger): Unit =
// can't fully re-parse and redirect to Version because of --cli-version and --scala-version clashing
if options.version then Version.runCommand(VersionOptions(options.shared.global), args, logger)
if options.version then
Version.runCommand(
options = VersionOptions(
global = options.shared.global,
offline = options.shared.coursier.getOffline().getOrElse(false)
),
args = args,
logger = logger
)
else
{
val shouldDefaultToRun =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@ import com.eed3si9n.expecty.Expecty.expect
import scala.cli.integration.VersionTests.variants

class VersionTests extends ScalaCliSuite {
test("version command") {
// tests if the format is correct instead of comparing to a version passed via Constants
// in order to catch errors in Mill configuration, too
val versionRegex = ".*\\d+[.]\\d+[.]\\d+.*".r
for (versionOption <- variants) {
val version = os.proc(TestUtil.cli, versionOption).call(check = false)

for (versionOption <- variants) {
test(versionOption) {
// tests if the format is correct instead of comparing to a version passed via Constants
// in order to catch errors in Mill configuration, too
val versionRegex = ".*\\d+[.]\\d+[.]\\d+.*".r
val version = os.proc(TestUtil.cli, versionOption).call(check = false)
assert(
versionRegex.findFirstMatchIn(version.out.text()).isDefined,
clues(version.exitCode, version.out.text(), version.err.text())
)
expect(version.exitCode == 0)
}

test(s"$versionOption --offline") {
TestInputs.empty.fromRoot { root =>
// TODO: --power should not be necessary here
os.proc(TestUtil.cli, versionOption, "--offline", "--power").call(cwd = root)
}
}
}

}
Expand Down

0 comments on commit 646e2be

Please sign in to comment.