summaryrefslogtreecommitdiffstats
path: root/src/tools/testwrap
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
commit293913568e6a7a86fd1479e1cff8e2ecb58d6568 (patch)
treefc3b469a3ec5ab71b36ea97cc7aaddb838423a0c /src/tools/testwrap
parentInitial commit. (diff)
downloadpostgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.tar.xz
postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.zip
Adding upstream version 16.2.upstream/16.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/testwrap')
-rwxr-xr-xsrc/tools/testwrap47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/tools/testwrap b/src/tools/testwrap
new file mode 100755
index 0000000..7a64fe7
--- /dev/null
+++ b/src/tools/testwrap
@@ -0,0 +1,47 @@
+#!/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('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 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)