From: Victor Julien Date: Sat, 13 Jan 2018 17:41:52 +0000 (+0100) Subject: runner: allow tests to be loaded from external dir X-Git-Tag: suricata-6.0.4~537 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb7ee8d26b3b29ee984b48589718728735be3deb;p=thirdparty%2Fsuricata-verify.git runner: allow tests to be loaded from external dir Add --dir option to specify a external directory for loading and running tests. This allows external test repositories for tests that are private or too large to be part of the repo. --- diff --git a/run.py b/run.py index b46a415bc..7dc796f2c 100755 --- a/run.py +++ b/run.py @@ -441,6 +441,8 @@ def main(): help="Force running of skipped tests") parser.add_argument("--fail", action="store_true", help="Exit on test failure") + parser.add_argument("--dir", action="store", + help="Runs tests from custom directory") parser.add_argument("patterns", nargs="*", default=[]) args = parser.parse_args() @@ -462,11 +464,17 @@ def main(): # Create a SuricataConfig object that is passed to all tests. suricata_config = SuricataConfig(get_suricata_version()) - for dirpath, dirnames, filenames in os.walk(os.path.join(topdir, "tests")): + tdir = os.path.join(topdir, "tests") + if args.dir: + tdir = os.path.abspath(args.dir) + + for dirpath, dirnames, filenames in os.walk(tdir): # The top directory is not a test... if dirpath == os.path.join(topdir, "tests"): continue + if dirpath == tdir: + continue # We only want to go one level deep. dirnames[0:] = []