Skip to content

Commit d428c8c

Browse files
committed
scripts: compliance: support not writing output to files
Support running the compliance check script without writing the output to any file. This adds a check for the --output flag to not write to the output file if the value is empty, and add a second flag for inhibiting the individual case files. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent 8f01e4c commit d428c8c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

scripts/ci/check_compliance.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,8 @@ def parse_args():
10841084
parser.add_argument('-o', '--output', default="compliance.xml",
10851085
help='''Name of outfile in JUnit format,
10861086
default is ./compliance.xml''')
1087+
parser.add_argument('-n', '--no-case-output', action="store_true",
1088+
help="Do not store the individual test case output.")
10871089
parser.add_argument('-l', '--list', action="store_true",
10881090
help="List all checks and exit")
10891091
parser.add_argument("-v", "--loglevel", choices=['DEBUG', 'INFO', 'WARNING',
@@ -1184,10 +1186,11 @@ def _main(args):
11841186

11851187
suite.add_testcase(test.case)
11861188

1187-
xml = JUnitXml()
1188-
xml.add_testsuite(suite)
1189-
xml.update_statistics()
1190-
xml.write(args.output, pretty=True)
1189+
if args.output:
1190+
xml = JUnitXml()
1191+
xml.add_testsuite(suite)
1192+
xml.update_statistics()
1193+
xml.write(args.output, pretty=True)
11911194

11921195
failed_cases = []
11931196
name2doc = {testcase.name: testcase.doc
@@ -1208,16 +1211,20 @@ def _main(args):
12081211
if n_fails:
12091212
print(f"{n_fails} checks failed")
12101213
for case in failed_cases:
1211-
errmsg = ""
1214+
for res in case.result:
1215+
errmsg = res.text.strip()
1216+
logging.error(f"Test {case.name} failed: \n{errmsg}")
1217+
if args.no_case_output:
1218+
continue
12121219
with open(f"{case.name}.txt", "w") as f:
12131220
docs = name2doc.get(case.name)
12141221
f.write(f"{docs}\n")
12151222
for res in case.result:
12161223
errmsg = res.text.strip()
1217-
logging.error(f"Test {case.name} failed: \n{errmsg}")
12181224
f.write(f'\n {errmsg}')
12191225

1220-
print(f"\nComplete results in {args.output}")
1226+
if args.output:
1227+
print(f"\nComplete results in {args.output}")
12211228
return n_fails
12221229

12231230

0 commit comments

Comments
 (0)