Skip to content

Commit dd88f7e

Browse files
committed
prepare_report.py: More information on stdout, with verbosity control
1 parent 0e9e497 commit dd88f7e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

scripts/bytecodecompare/prepare_report.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ def format_report(self) -> str:
6262

6363
return report
6464

65+
def format_summary(self, verbose: bool) -> str:
66+
error = (self.contract_reports is None)
67+
contract_reports = self.contract_reports if self.contract_reports is not None else []
68+
no_bytecode = any(bytecode is None for bytecode in contract_reports)
69+
no_metadata = any(metadata is None for metadata in contract_reports)
70+
71+
if verbose:
72+
flags = ('E' if error else ' ') + ('B' if no_bytecode else ' ') + ('M' if no_metadata else ' ')
73+
contract_count = '?' if self.contract_reports is None else str(len(self.contract_reports))
74+
return f"{contract_count} {flags} {self.file_name}"
75+
else:
76+
if error:
77+
return 'E'
78+
if no_bytecode:
79+
return 'B'
80+
if no_metadata:
81+
return 'M'
82+
83+
return '.'
84+
6585

6686
def load_source(path: Union[Path, str], smt_use: SMTUse) -> str:
6787
# NOTE: newline='' disables newline conversion.
@@ -278,6 +298,7 @@ def generate_report(
278298
smt_use: SMTUse,
279299
force_no_optimize_yul: bool,
280300
report_file_path: Path,
301+
verbose: bool,
281302
):
282303
metadata_option_supported = detect_metadata_cli_option_support(compiler_path)
283304

@@ -296,6 +317,7 @@ def generate_report(
296317
metadata_option_supported,
297318
Path(tmp_dir),
298319
)
320+
print(report.format_summary(verbose), end=('\n' if verbose else ''), flush=True)
299321
report_file.write(report.format_report())
300322
except subprocess.CalledProcessError as exception:
301323
print(
@@ -345,6 +367,7 @@ def commandline_parser() -> ArgumentParser:
345367
help="Explicitly disable Yul optimizer in CLI runs without optimization to work around a bug in solc 0.6.0 and 0.6.1."
346368
)
347369
parser.add_argument('--report-file', dest='report_file', default='report.txt', help="The file to write the report to.")
370+
parser.add_argument('--verbose', dest='verbose', default=False, action='store_true', help="More verbose output.")
348371
return parser;
349372

350373

@@ -357,4 +380,5 @@ def commandline_parser() -> ArgumentParser:
357380
SMTUse(options.smt_use),
358381
options.force_no_optimize_yul,
359382
Path(options.report_file),
383+
options.verbose,
360384
)

0 commit comments

Comments
 (0)