Files
postgresql/src/tools/testwrap
Peter Eisentraut bc15a126bb Explicitly skip TAP tests under Meson if disabled
If the tap_tests option is disabled under Meson, the TAP tests are
currently not registered at all.  But this makes it harder to see what
is going on, why suddently there are fewer tests than before.

Instead, run testwrap with an option that marks the test as skipped.
That way, the total list and count of tests is constant whether the
option is enabled or not.

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/ad5ec96d-69ec-317b-a137-367ea5019b61@eisentraut.org
2023-11-16 08:14:33 +01:00

53 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import shutil
import subprocess
import os
import sys
parser = argparse.ArgumentParser()
parser.add_argument('--srcdir', help='source directory of test', type=str)
parser.add_argument('--basedir', help='base directory of test', type=str)
parser.add_argument('--testgroup', help='test group', type=str)
parser.add_argument('--testname', help='test name', type=str)
parser.add_argument('--skip', help='skip test (with reason)', type=str)
parser.add_argument('test_command', nargs='*')
args = parser.parse_args()
testdir = '{}/testrun/{}/{}'.format(
args.basedir, args.testgroup, args.testname)
print('# executing test in {} group {} test {}'.format(
testdir, args.testgroup, args.testname))
sys.stdout.flush()
if args.skip is not None:
print('1..0 # Skipped: ' + args.skip)
sys.exit(0)
if os.path.exists(testdir) and os.path.isdir(testdir):
shutil.rmtree(testdir)
os.makedirs(testdir)
os.chdir(args.srcdir)
# mark test as having started
open(os.path.join(testdir, 'test.start'), 'x')
env_dict = {**os.environ,
'TESTDATADIR': os.path.join(testdir, 'data'),
'TESTLOGDIR': os.path.join(testdir, 'log')}
sp = subprocess.run(args.test_command, env=env_dict)
if sp.returncode == 0:
print('# test succeeded')
open(os.path.join(testdir, 'test.success'), 'x')
else:
print('# test failed')
open(os.path.join(testdir, 'test.fail'), 'x')
sys.exit(sp.returncode)