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

Exit with Bloop command return code if it's non-zero #1837

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 @@ -87,7 +87,7 @@ object Bloop extends ScalaCommand[BloopOptions] {
case Seq(cmd, args @ _*) =>
val assumeTty = System.console() != null
val workingDir = options.workDirOpt.getOrElse(os.pwd).toNIO
Operations.run(
val retCode = Operations.run(
command = cmd,
args = args.toArray,
workingDir = workingDir,
Expand All @@ -100,6 +100,12 @@ object Bloop extends ScalaCommand[BloopOptions] {
assumeOutTty = assumeTty,
assumeErrTty = assumeTty
)
if (retCode == 0)
logger.debug(s"Bloop command $cmd ran successfully (return code 0)")
else {
logger.debug(s"Got return code $retCode from Bloop server when running $cmd, exiting with it")
sys.exit(retCode)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ class BloopTests extends ScalaCliSuite {

os.proc(TestUtil.cli, "--power", "bloop", "compile", proj)
.call(cwd = root / Constants.workspaceDirName)

val failRes = os.proc(TestUtil.cli, "--power", "bloop", "foo")
.call(cwd = root / Constants.workspaceDirName, check = false, mergeErrIntoOut = true)
val failOutput = failRes.out.text()
expect(failRes.exitCode == 4)
expect(failOutput.contains("Command not found: foo"))
}
}

Expand Down