Loads and parses the input file, runs all tests and reports results
(testDir, input_basename, buildenv)
| 41 | bctester(os.path.join(env_conf["SRCDIR"], "test", "util", "data"), "bitcoin-util-test.json", env_conf) |
| 42 | |
| 43 | def bctester(testDir, input_basename, buildenv): |
| 44 | """ Loads and parses the input file, runs all tests and reports results""" |
| 45 | input_filename = os.path.join(testDir, input_basename) |
| 46 | raw_data = open(input_filename, encoding="utf8").read() |
| 47 | input_data = json.loads(raw_data) |
| 48 | |
| 49 | failed_testcases = [] |
| 50 | |
| 51 | for testObj in input_data: |
| 52 | try: |
| 53 | bctest(testDir, testObj, buildenv) |
| 54 | logging.info("PASSED: " + testObj["description"]) |
| 55 | except: |
| 56 | logging.info("FAILED: " + testObj["description"]) |
| 57 | failed_testcases.append(testObj["description"]) |
| 58 | |
| 59 | if failed_testcases: |
| 60 | error_message = "FAILED_TESTCASES:\n" |
| 61 | error_message += pprint.pformat(failed_testcases, width=400) |
| 62 | logging.error(error_message) |
| 63 | sys.exit(1) |
| 64 | else: |
| 65 | sys.exit(0) |
| 66 | |
| 67 | def bctest(testDir, testObj, buildenv): |
| 68 | """Runs a single test, comparing output and RC to expected output and RC. |