Fix command error being ignored and not reported as error code

This commit is contained in:
Sleepy Monax 2024-01-20 18:02:02 +01:00
parent 16225f50d4
commit aa6a55f717

View file

@ -3,6 +3,7 @@ import logging
import dataclasses as dt import dataclasses as dt
from pathlib import Path from pathlib import Path
import sys
from typing import Callable, Literal, TextIO, Union from typing import Callable, Literal, TextIO, Union
from . import shell, rules, model, ninja, const, cli from . import shell, rules, model, ninja, const, cli
@ -355,7 +356,7 @@ def runCmd(args: cli.Args):
debug = args.consumeOpt("debug", False) is True debug = args.consumeOpt("debug", False) is True
profile = args.consumeOpt("profile", False) is True profile = args.consumeOpt("profile", False) is True
wait = args.consumeOpt("wait", False) is True wait = args.consumeOpt("wait", False) is True
debugger = args.consumeOpt("debugger", "lldb") debugger = str(args.consumeOpt("debugger", "lldb"))
componentSpec = args.consumeArg() or "__main__" componentSpec = args.consumeArg() or "__main__"
scope = TargetScope.use(args, {"debug": debug}) scope = TargetScope.use(args, {"debug": debug})
@ -371,17 +372,14 @@ def runCmd(args: cli.Args):
os.environ["CK_BUILDDIR"] = product.target.builddir os.environ["CK_BUILDDIR"] = product.target.builddir
os.environ["CK_COMPONENT"] = product.component.id os.environ["CK_COMPONENT"] = product.component.id
try: command = [str(product.path), *args.extra]
command = [str(product.path), *args.extra]
if debug: if debug:
shell.debug(command, debugger=debugger, wait=wait) shell.debug(command, debugger=debugger, wait=wait)
elif profile: elif profile:
shell.profile(command) shell.profile(command)
else: else:
shell.exec(*command) shell.exec(*command)
except Exception as e:
cli.error(e)
@cli.command("t", "builder/test", "Run all test targets") @cli.command("t", "builder/test", "Run all test targets")