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

Ensure --version passed to the default command works with --offline #3207

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 @@ -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
Loading