Skip to content

Commit 6c1fb73

Browse files
committed
Improve logging in bctest.py if there is a formatting mismatch
1 parent 47510ad commit 6c1fb73

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/test/bctest.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import binascii
1111
import difflib
1212
import logging
13+
import pprint
1314

1415
def parse_output(a, fmt):
1516
"""Parse the output according to specified format.
@@ -65,6 +66,7 @@ def bctest(testDir, testObj, exeext):
6566
raise
6667

6768
if outputData:
69+
data_mismatch, formatting_mismatch = False, False
6870
# Parse command output and expected output
6971
try:
7072
a_parsed = parse_output(outs[0], outputType)
@@ -79,7 +81,7 @@ def bctest(testDir, testObj, exeext):
7981
# Compare data
8082
if a_parsed != b_parsed:
8183
logging.error("Output data mismatch for " + outputFn + " (format " + outputType + ")")
82-
raise Exception
84+
data_mismatch = True
8385
# Compare formatting
8486
if outs[0] != outputData:
8587
error_message = "Output formatting mismatch for " + outputFn + ":\n"
@@ -88,7 +90,9 @@ def bctest(testDir, testObj, exeext):
8890
fromfile=outputFn,
8991
tofile="returned"))
9092
logging.error(error_message)
91-
raise Exception
93+
formatting_mismatch = True
94+
95+
assert not data_mismatch and not formatting_mismatch
9296

9397
# Compare the return code to the expected return code
9498
wantRC = 0
@@ -115,7 +119,9 @@ def bctester(testDir, input_basename, buildenv):
115119
failed_testcases.append(testObj["description"])
116120

117121
if failed_testcases:
118-
logging.error("FAILED TESTCASES: [" + ", ".join(failed_testcases) + "]")
122+
error_message = "FAILED_TESTCASES:\n"
123+
error_message += pprint.pformat(failed_testcases, width=400)
124+
logging.error(error_message)
119125
sys.exit(1)
120126
else:
121127
sys.exit(0)

0 commit comments

Comments
 (0)