Make inittestdb take a -k argument to restrict which tests it uses
This is useful because it is faster to only initialize the databases
you care about in testing and because edgedb starts up faster when
there are fewer databases.
@@ -46,11 +46,12 @@ class TestRunner:
return TestResult()
-def execute(tests_dir, conn, num_workers):
+def execute(tests_dir, conn, num_workers, include):
runner = TestRunner()
+ include = [x for pat in include for x in ['-k', pat]]
unittest.main(
module=None,
- argv=['unittest', 'discover', '-s', tests_dir],
+ argv=['unittest', 'discover', '-s', tests_dir, *include],
testRunner=runner, exit=False)
tb.setup_test_cases(runner.cases, conn, num_workers)
@@ -74,7 +75,9 @@ def die(msg):
@click.option('-j', '--jobs', type=int,
default=lambda: round((os.cpu_count() or 1) * 0.75),
help='number of parallel processes to use')
-def inittestdb(*, data_dir, jobs, tests_dir):
+@click.option('-k', '--include', type=str, multiple=True, metavar='REGEXP',
+ help='only use tests which match the given regular expression')
+def inittestdb(*, data_dir, jobs, tests_dir, include):
if os.path.exists(data_dir):
if not os.path.isdir(data_dir):
die(f'{data_dir!r} exists and is not a directory')
@@ -100,7 +103,7 @@ def inittestdb(*, data_dir, jobs, tests_dir):
destroy_cluster = False
try:
- execute(tests_dir, conn, num_workers=jobs)
+ execute(tests_dir, conn, num_workers=jobs, include=include)
print(f'Initialized and populated test EdgeDB instance in {data_dir}')
except BaseException:
destroy_cluster = True
