Skip to content

Commit

Permalink
Check that all test scripts in test/functional are being run
Browse files Browse the repository at this point in the history
Summary:
This commit checks that all of the python files in the test/functional
directory are listed in test_runner.py.

This backports core's PR10096 and improves the situation on T163

Test Plan:
Remove one test from the test_runner.py

  ./test/functional/test_runner.py

Check that is gives me the following error:

  The following scripts are not being run:['scriptname.py']
  Chec the test list in test_runner.py

Reviewers: #bitcoin_abc, matiu

Reviewed By: #bitcoin_abc, matiu

Subscribers: teamcity

Differential Revision: https://reviews.bitcoinabc.org/D995
  • Loading branch information
jnewbery authored and deadalnix committed Jan 21, 2018
1 parent 004c416 commit 52dee22
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@
ALL_SCRIPTS = EXTENDED_SCRIPTS + BASE_SCRIPTS


NON_SCRIPTS = [
# These are python files that live in the functional tests directory, but are not test scripts.
"combine_logs.py",
"create_cache.py",
"test_runner.py",
]


def main():
# Parse arguments and pass through unrecognised args
parser = argparse.ArgumentParser(add_help=False,
Expand Down Expand Up @@ -224,10 +232,10 @@ def main():
(config["environment"]["SRCDIR"] + '/test/functional/' + test_list[0]).split() + ['-h'])
sys.exit(0)

run_tests(
test_list, config["environment"][
"SRCDIR"], config["environment"]["BUILDDIR"],
config["environment"]["EXEEXT"], args.jobs, args.coverage, passon_args)
check_script_list(config["environment"]["SRCDIR"])

run_tests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"],
config["environment"]["EXEEXT"], args.jobs, args.coverage, passon_args)


def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=False, args=[]):
Expand Down Expand Up @@ -359,6 +367,21 @@ def get_next(self):
print('.', end='', flush=True)


def check_script_list(src_dir):
"""Check scripts directory.
Check that there are no scripts in the functional tests directory which are
not being run by pull-tester.py."""
script_dir = src_dir + '/test/functional/'
python_files = set([t for t in os.listdir(script_dir) if t[-3:] == ".py"])
missed_tests = list(
python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS)))
if len(missed_tests) != 0:
print("The following scripts are not being run:" + str(missed_tests))
print("Check the test lists in test_runner.py")
sys.exit(1)


class RPCCoverage(object):

"""
Expand Down

0 comments on commit 52dee22

Please sign in to comment.