aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2017-11-30 20:11:18 +1000
committerAnthony Towns <aj@erisian.com.au>2017-12-08 01:50:02 +1000
commit9b20bb40fbd59c8fd24a7c82e87600ea3c5c7039 (patch)
tree7918ce6e1c0779becbef31d1df9975b99022f5e4 /test/functional
parent7250b4e5630ec6e440652855876ba83b0365a15a (diff)
[tests] Check tests conform to naming convention
Extra-Author: John Newbery <john@johnnewbery.com>
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/test_runner.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index 5c8740d7cd..e85d672096 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -260,6 +260,7 @@ def main():
sys.exit(0)
check_script_list(config["environment"]["SRCDIR"])
+ check_script_prefixes()
if not args.keepcache:
shutil.rmtree("%s/test/cache" % config["environment"]["BUILDDIR"], ignore_errors=True)
@@ -444,6 +445,28 @@ class TestResult():
return self.status != "Failed"
+def check_script_prefixes():
+ """Check that no more than `EXPECTED_VIOLATION_COUNT` of the
+ test scripts don't start with one of the allowed name prefixes."""
+ EXPECTED_VIOLATION_COUNT = 77
+
+ # LEEWAY is provided as a transition measure, so that pull-requests
+ # that introduce new tests that don't conform with the naming
+ # convention don't immediately cause the tests to fail.
+ LEEWAY = 10
+
+ good_prefixes_re = re.compile("(example|feature|interface|mempool|mining|p2p|rpc|wallet)_")
+ bad_script_names = [script for script in ALL_SCRIPTS if good_prefixes_re.match(script) is None]
+
+ if len(bad_script_names) < EXPECTED_VIOLATION_COUNT:
+ print("{}HURRAY!{} Number of functional tests violating naming convention reduced!".format(BOLD[1], BOLD[0]))
+ print("Consider reducing EXPECTED_VIOLATION_COUNT from %d to %d" % (EXPECTED_VIOLATION_COUNT, len(bad_script_names)))
+ elif len(bad_script_names) > EXPECTED_VIOLATION_COUNT:
+ print("INFO: %d tests not meeting naming conventions (expected %d):" % (len(bad_script_names), EXPECTED_VIOLATION_COUNT))
+ print(" %s" % ("\n ".join(sorted(bad_script_names))))
+ assert len(bad_script_names) <= EXPECTED_VIOLATION_COUNT + LEEWAY, "Too many tests not following naming convention! (%d found, expected: <= %d)" % (len(bad_script_names), EXPECTED_VIOLATION_COUNT)
+
+
def check_script_list(src_dir):
"""Check scripts directory.