Merge #9945: Improve logging in bctest.py if there is a formatting mismatch
6c1fb73
Improve logging in bctest.py if there is a formatting mismatch (John Newbery)
Tree-SHA512: ef33f4766df92a987cd714d73b98277616ff947ad0e43811013dda668e31464062816480bd654865231d56d37fb4d6e4ccdccbcb2f0e2f01f49572b843a232ae
This commit is contained in:
commit
ac23a7c1f1
1 changed files with 9 additions and 3 deletions
|
@ -10,6 +10,7 @@ import sys
|
||||||
import binascii
|
import binascii
|
||||||
import difflib
|
import difflib
|
||||||
import logging
|
import logging
|
||||||
|
import pprint
|
||||||
|
|
||||||
def parse_output(a, fmt):
|
def parse_output(a, fmt):
|
||||||
"""Parse the output according to specified format.
|
"""Parse the output according to specified format.
|
||||||
|
@ -65,6 +66,7 @@ def bctest(testDir, testObj, exeext):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if outputData:
|
if outputData:
|
||||||
|
data_mismatch, formatting_mismatch = False, False
|
||||||
# Parse command output and expected output
|
# Parse command output and expected output
|
||||||
try:
|
try:
|
||||||
a_parsed = parse_output(outs[0], outputType)
|
a_parsed = parse_output(outs[0], outputType)
|
||||||
|
@ -79,7 +81,7 @@ def bctest(testDir, testObj, exeext):
|
||||||
# Compare data
|
# Compare data
|
||||||
if a_parsed != b_parsed:
|
if a_parsed != b_parsed:
|
||||||
logging.error("Output data mismatch for " + outputFn + " (format " + outputType + ")")
|
logging.error("Output data mismatch for " + outputFn + " (format " + outputType + ")")
|
||||||
raise Exception
|
data_mismatch = True
|
||||||
# Compare formatting
|
# Compare formatting
|
||||||
if outs[0] != outputData:
|
if outs[0] != outputData:
|
||||||
error_message = "Output formatting mismatch for " + outputFn + ":\n"
|
error_message = "Output formatting mismatch for " + outputFn + ":\n"
|
||||||
|
@ -88,7 +90,9 @@ def bctest(testDir, testObj, exeext):
|
||||||
fromfile=outputFn,
|
fromfile=outputFn,
|
||||||
tofile="returned"))
|
tofile="returned"))
|
||||||
logging.error(error_message)
|
logging.error(error_message)
|
||||||
raise Exception
|
formatting_mismatch = True
|
||||||
|
|
||||||
|
assert not data_mismatch and not formatting_mismatch
|
||||||
|
|
||||||
# Compare the return code to the expected return code
|
# Compare the return code to the expected return code
|
||||||
wantRC = 0
|
wantRC = 0
|
||||||
|
@ -115,7 +119,9 @@ def bctester(testDir, input_basename, buildenv):
|
||||||
failed_testcases.append(testObj["description"])
|
failed_testcases.append(testObj["description"])
|
||||||
|
|
||||||
if failed_testcases:
|
if failed_testcases:
|
||||||
logging.error("FAILED TESTCASES: [" + ", ".join(failed_testcases) + "]")
|
error_message = "FAILED_TESTCASES:\n"
|
||||||
|
error_message += pprint.pformat(failed_testcases, width=400)
|
||||||
|
logging.error(error_message)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Reference in a new issue