@@ -260,6 +260,7 @@ def main():
260
260
sys .exit (0 )
261
261
262
262
check_script_list (config ["environment" ]["SRCDIR" ])
263
+ check_script_prefixes ()
263
264
264
265
if not args .keepcache :
265
266
shutil .rmtree ("%s/test/cache" % config ["environment" ]["BUILDDIR" ], ignore_errors = True )
@@ -444,6 +445,28 @@ def was_successful(self):
444
445
return self .status != "Failed"
445
446
446
447
448
+ def check_script_prefixes ():
449
+ """Check that no more than `EXPECTED_VIOLATION_COUNT` of the
450
+ test scripts don't start with one of the allowed name prefixes."""
451
+ EXPECTED_VIOLATION_COUNT = 77
452
+
453
+ # LEEWAY is provided as a transition measure, so that pull-requests
454
+ # that introduce new tests that don't conform with the naming
455
+ # convention don't immediately cause the tests to fail.
456
+ LEEWAY = 10
457
+
458
+ good_prefixes_re = re .compile ("(example|feature|interface|mempool|mining|p2p|rpc|wallet)_" )
459
+ bad_script_names = [script for script in ALL_SCRIPTS if good_prefixes_re .match (script ) is None ]
460
+
461
+ if len (bad_script_names ) < EXPECTED_VIOLATION_COUNT :
462
+ print ("{}HURRAY!{} Number of functional tests violating naming convention reduced!" .format (BOLD [1 ], BOLD [0 ]))
463
+ print ("Consider reducing EXPECTED_VIOLATION_COUNT from %d to %d" % (EXPECTED_VIOLATION_COUNT , len (bad_script_names )))
464
+ elif len (bad_script_names ) > EXPECTED_VIOLATION_COUNT :
465
+ print ("INFO: %d tests not meeting naming conventions (expected %d):" % (len (bad_script_names ), EXPECTED_VIOLATION_COUNT ))
466
+ print (" %s" % ("\n " .join (sorted (bad_script_names ))))
467
+ 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 )
468
+
469
+
447
470
def check_script_list (src_dir ):
448
471
"""Check scripts directory.
449
472
0 commit comments