[gegl] tests: buffer tests - migrate to new python buffer test runner - migrate to common test setup
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] tests: buffer tests - migrate to new python buffer test runner - migrate to common test setup
- Date: Sat, 20 Feb 2021 22:28:48 +0000 (UTC)
commit 0af9ba7d63121df757b5c5929a42b74812a2e097
Author: John Marshall <jtm home gmail com>
Date: Sun Jun 14 08:23:44 2020 +0100
tests: buffer tests
- migrate to new python buffer test runner
- migrate to common test setup
tests/buffer/buffer-test.py | 78 ++++++++++++++++++++++++++++++++++++
tests/buffer/buffer-tests-results.sh | 17 --------
tests/buffer/buffer-tests-run.sh | 11 -----
tests/buffer/meson.build | 46 ++++++++-------------
tests/meson.build | 1 +
5 files changed, 96 insertions(+), 57 deletions(-)
---
diff --git a/tests/buffer/buffer-test.py b/tests/buffer/buffer-test.py
new file mode 100644
index 000000000..5c806401d
--- /dev/null
+++ b/tests/buffer/buffer-test.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python3
+
+from __future__ import print_function
+
+import os
+import sys
+import argparse
+import errno
+import filecmp
+import subprocess
+
+class Args():
+ def __init__(self):
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '--reference-dir',
+ metavar='REF_DIR',
+ help='directory holding reference images'
+ )
+ parser.add_argument(
+ 'TEST',
+ metavar='TEST_NAME',
+ help='buffer test file to run'
+ )
+
+ self.test_exe = os.path.realpath(parser.parse_args().TEST)
+ self.test_name = os.path.splitext(
+ os.path.basename(self.test_exe)
+ )[0]
+ self.test_file = self.test_name + '.buf'
+
+ if parser.parse_args().reference_dir:
+ self.reference_dir = os.path.realpath(
+ parser.parse_args().reference_dir
+ )
+ else:
+ self.reference_dir = os.path.realpath('reference')
+ print(self.reference_dir)
+
+
+def main():
+ args = Args()
+
+ if not os.path.exists(args.test_exe):
+ print('Skipping - cannot find test exe: %s' % args.test_exe)
+ sys.exit(77)
+
+ ref_file = os.path.join(args.reference_dir, args.test_file)
+ if not os.path.exists(ref_file):
+ print('Skipping - cannot find buffer reference file')
+ sys.exit(77)
+
+ output_dir = os.path.realpath('output')
+ if not os.path.exists(output_dir):
+ try:
+ os.makedirs(output_dir, 0o700)
+ except OSError as err:
+ if err.errno != errno.EEXIST:
+ raise
+
+ try:
+ subprocess.call(args.test_exe)
+ except subprocess.CalledProcessError as err:
+ print(err.returncode)
+
+ if filecmp.cmp(
+ ref_file,
+ os.path.join(output_dir, args.test_file),
+ shallow=False
+ ):
+ sys.exit(0)
+ else:
+ print(': buffer output does not match reference')
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/tests/buffer/meson.build b/tests/buffer/meson.build
index a803d379c..0f244efe5 100644
--- a/tests/buffer/meson.build
+++ b/tests/buffer/meson.build
@@ -1,5 +1,5 @@
-buffer_tests_list = [
+buffer_tests = [
'blank',
'buffer_copy',
'buffer_copy_abyss',
@@ -66,41 +66,29 @@ buffer_tests_list = [
'vertical_gradient',
]
-
-buffer_test_run_script = find_program('buffer-tests-run.sh')
-
-foreach test_name : buffer_tests_list
-
- test_exe = executable(test_name,
+buffer_test = find_program('buffer-test.py')
+foreach _test : buffer_tests
+ _test_exe = executable(_test,
'buffer-test-wrapper.c',
- include_directories: [ rootInclude, geglInclude, ],
- link_with: [
- gegl_lib,
- ],
- dependencies: [
- babl,
- glib,
- gobject,
- math,
- ],
+ include_directories: gegl_test_includes,
+ link_with: gegl_lib,
+ dependencies: gegl_test_deps,
c_args: [
'-Wno-unused-function',
- '-DTEST_NAME="@0@"'.format(test_name),
- '-DTEST_INCLUDE="@0@"'.format('tests' / test_name + '.c'),
+ '-DTEST_NAME="@0@"'.format(_test),
+ '-DTEST_INCLUDE="@0@"'.format('tests' / _test + '.c'),
],
)
- test(test_name,
- buffer_test_run_script,
- args: [ test_name, test_exe.full_path(), ],
- env: [
- 'GEGL_PATH=' + meson.build_root() / 'operations',
- 'GEGL_SWAP=RAM',
- 'REFERENCE_DIR=' + meson.source_root() / 'tests' / 'buffer' / 'reference',
+ test(_test,
+ buffer_test,
+ args: [
+ '--reference-dir', meson.current_source_dir() / 'reference',
+ _test_exe,
],
+ env: gegl_test_env,
workdir: meson.current_build_dir(),
- suite: 'buffers',
- is_parallel: false,
+ suite: 'buffer',
+ is_parallel: gegl_test_parallel,
)
-
endforeach
diff --git a/tests/meson.build b/tests/meson.build
index 4c809b501..d110416fb 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -27,6 +27,7 @@ gegl_test_deps = [
babl,
glib,
gobject,
+ math,
]
# common test paralllel flag
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]