Skip to content

Commit cd3b343

Browse files
committed
prepare_report.py: --exit-on-error option
1 parent dd88f7e commit cd3b343

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

scripts/bytecodecompare/prepare_report.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def run_compiler( # pylint: disable=too-many-arguments
237237
smt_use: SMTUse,
238238
metadata_option_supported: bool,
239239
tmp_dir: Path,
240+
exit_on_error: bool,
240241
) -> FileReport:
241242

242243
if interface == CompilerInterface.STANDARD_JSON:
@@ -255,7 +256,7 @@ def run_compiler( # pylint: disable=too-many-arguments
255256
input=compiler_input,
256257
encoding='utf8',
257258
capture_output=True,
258-
check=False,
259+
check=exit_on_error,
259260
)
260261

261262
return parse_standard_json_output(Path(source_file_name), process.stdout)
@@ -285,20 +286,21 @@ def run_compiler( # pylint: disable=too-many-arguments
285286
cwd=tmp_dir,
286287
encoding='utf8',
287288
capture_output=True,
288-
check=False,
289+
check=exit_on_error,
289290
)
290291

291292
return parse_cli_output(Path(source_file_name), process.stdout)
292293

293294

294-
def generate_report(
295+
def generate_report( # pylint: disable=too-many-arguments
295296
source_file_names: List[str],
296297
compiler_path: Path,
297298
interface: CompilerInterface,
298299
smt_use: SMTUse,
299300
force_no_optimize_yul: bool,
300301
report_file_path: Path,
301302
verbose: bool,
303+
exit_on_error: bool,
302304
):
303305
metadata_option_supported = detect_metadata_cli_option_support(compiler_path)
304306

@@ -316,6 +318,7 @@ def generate_report(
316318
smt_use,
317319
metadata_option_supported,
318320
Path(tmp_dir),
321+
exit_on_error,
319322
)
320323
print(report.format_summary(verbose), end=('\n' if verbose else ''), flush=True)
321324
report_file.write(report.format_report())
@@ -368,6 +371,13 @@ def commandline_parser() -> ArgumentParser:
368371
)
369372
parser.add_argument('--report-file', dest='report_file', default='report.txt', help="The file to write the report to.")
370373
parser.add_argument('--verbose', dest='verbose', default=False, action='store_true', help="More verbose output.")
374+
parser.add_argument(
375+
'--exit-on-error',
376+
dest='exit_on_error',
377+
default=False,
378+
action='store_true',
379+
help="Immediately exit and print compiler output if the compiler exits with an error.",
380+
)
371381
return parser;
372382

373383

@@ -381,4 +391,5 @@ def commandline_parser() -> ArgumentParser:
381391
options.force_no_optimize_yul,
382392
Path(options.report_file),
383393
options.verbose,
394+
options.exit_on_error,
384395
)

0 commit comments

Comments
 (0)