mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 15:48:05 +00:00
[tests] Check tests conform to naming convention
Extra-Author: John Newbery <john@johnnewbery.com>
This commit is contained in:
parent
7250b4e563
commit
9b20bb40fb
@ -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.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user