revng.cli: ensure proper exit code propagation

This commit is contained in:
Alessandro Di Federico
2023-06-23 17:55:38 +02:00
parent 942cc1323a
commit 42abf64c62
3 changed files with 21 additions and 4 deletions
+18 -4
View File
@@ -48,7 +48,11 @@ class IRPipelineCommand(Command):
saved_input_file.flush()
# Extract model
run_revng_command(["model", "dump", saved_input_file.name, "-o", model.name], options)
result = run_revng_command(
["model", "dump", saved_input_file.name, "-o", model.name], options
)
if result != 0:
return result
# Run revng-pipeline
target = f"--produce={args.to}/module.ll/{args.target}"
@@ -58,9 +62,14 @@ class IRPipelineCommand(Command):
load_binary = []
if args.binary != "":
from_step = args.__dict__["from"]
load_binary = ["-i", f"{args.binary}:{from_step}/input"]
load_binary = [
"-i",
f"{args.binary}:{from_step}/input",
"-i",
f"{args.binary}:begin/input",
]
run_revng_command(
result = run_revng_command(
[
"pipeline",
"-m",
@@ -76,11 +85,16 @@ class IRPipelineCommand(Command):
],
options,
)
if result != 0:
return result
# Re-inject the model
run_revng_command(
result = run_revng_command(
["model", "inject", model.name, module.name, "-o", args.output], options
)
if result != 0:
return result
return 0
@@ -19,6 +19,7 @@ class PipelineToolCommand(Command):
command = build_command_with_loads(
f"revng-{self.name}", pipelines_args + options.remaining_args, options
)
return run(command, options)
+2
View File
@@ -105,6 +105,8 @@ def run(command, options: Options, environment: OptionalEnv = None):
if result != 0:
sys.exit(result)
return result
def exec_run(command, options: Options, environment: OptionalEnv) -> Union[int, NoReturn]:
command, environment = _run_common(command, options, environment)