[gegl] tests: Convert xml and simple directories to python runner
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] tests: Convert xml and simple directories to python runner
- Date: Tue, 12 Nov 2013 20:21:07 +0000 (UTC)
commit baadf440ea2eb0a0237edc0a721902cde039157b
Author: Daniel Sabo <DanielSabo gmail com>
Date: Sat Nov 2 17:13:51 2013 -0700
tests: Convert xml and simple directories to python runner
tests/buffer/Makefile.am | 8 ++-
tests/python/Makefile.am | 16 +++---
tests/run-tests.py | 130 ++++++++++++++++++++++++++++++++++++++++++++++
tests/simple/Makefile.am | 11 ++--
tests/xml/Makefile.am | 17 ++----
5 files changed, 155 insertions(+), 27 deletions(-)
---
diff --git a/tests/buffer/Makefile.am b/tests/buffer/Makefile.am
index 13bed52..371a190 100644
--- a/tests/buffer/Makefile.am
+++ b/tests/buffer/Makefile.am
@@ -6,8 +6,6 @@ SUBDIRS = \
TESTS = buffer-tests-results.sh
buffer-tests-results.sh: buffer-tests-report
-TESTS_ENVIRONMENT = REFERENCE_DIR=$(top_srcdir)/tests/buffer/reference
-
EXTRA_DIST = buffer-tests-results.sh
# Always build buffer-test to catch compilation problems early
@@ -64,6 +62,12 @@ buffer-tests-report: buffer-test$(EXEEXT) $(top_srcdir)/tests/buffer/reference/*
$(builddir_gegl_env) ./buffer-test$(EXEEXT)
for f in $(top_srcdir)/tests/buffer/reference/*.buf; do LC_ALL=C diff --report-identical-files
--context=50 $$f output/`basename $$f`; done > buffer-tests-report; true
+check-TESTS: $(TESTS)
+ REFERENCE_DIR=$(top_srcdir)/tests/buffer/reference \
+ $(PYTHON) $(srcdir)/../run-tests.py \
+ --build-dir=$(top_builddir) --src-dir=$(top_srcdir) \
+ $(TESTS)
+
clean-local:
rm -rf output
diff --git a/tests/python/Makefile.am b/tests/python/Makefile.am
index 3ffecba..c512e55 100644
--- a/tests/python/Makefile.am
+++ b/tests/python/Makefile.am
@@ -1,10 +1,3 @@
-TESTS_ENVIRONMENT = \
- LD_LIBRARY_PATH=$(top_builddir)/gegl/.libs:$(LD_LIBRARY_PATH) \
- GI_TYPELIB_PATH=$(top_builddir)/gegl:$(GI_TYPELIB_PATH) \
- GEGL_SWAP=RAM \
- GEGL_PATH=$(top_builddir)/operations/
- $(PYTHON)
-
if HAVE_PYTHON
if HAVE_INTROSPECTION
if HAVE_PYGOBJECT
@@ -15,7 +8,16 @@ TESTS = \
test-gegl-color.py \
test-gegl-buffer.py \
test-gegl-format.py
+
EXTRA_DIST = $(TESTS)
+
+check-TESTS: $(TESTS)
+ LD_LIBRARY_PATH=$(top_builddir)/gegl/.libs:$(LD_LIBRARY_PATH) \
+ GI_TYPELIB_PATH=$(top_builddir)/gegl:$(GI_TYPELIB_PATH) \
+ $(PYTHON) $(srcdir)/../run-tests.py \
+ --build-dir=$(top_builddir) --src-dir=$(top_srcdir) \
+ $(TESTS)
+
endif # HAVE_PYGOBJECT
endif # HAVE_INTROSPECTION
endif # HAVE_PYTHON
diff --git a/tests/run-tests.py b/tests/run-tests.py
new file mode 100755
index 0000000..960ad24
--- /dev/null
+++ b/tests/run-tests.py
@@ -0,0 +1,130 @@
+#!/usr/bin/env python
+from __future__ import print_function
+
+import os
+import sys
+import argparse
+import subprocess
+
+from glob import glob
+from pprint import pprint
+
+if "SHELL" in os.environ:
+ SHELL = os.environ["SHELL"]
+else:
+ SHELL = "sh"
+
+if "PYTHON" in os.environ:
+ PYTHON = os.environ["PYTHON"]
+else:
+ PYTHON = "python"
+
+if sys.stdout.isatty() and "TERM" in os.environ:
+ blue = "\033[1;34m"
+ green = "\033[1;32m"
+ red = "\033[1;31m"
+ end = "\033[0m"
+ PASS_STR = green + "PASS" + end
+ FAIL_STR = red + "FAIL" + end
+ SKIP_STR = blue + "SKIP" + end
+else:
+ PASS_STR = "PASS"
+ FAIL_STR = "FAIL"
+ SKIP_STR = "SKIP"
+
+VERBOSE = False
+if ("V" in os.environ and os.environ["V"] != "0") or \
+ ("VERBOSE" in os.environ and os.environ["VERBOSE"] != "0"):
+ VERBOSE = True
+
+class Context():
+ def __init__(self):
+ self.src_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
+ self.build_dir = self.src_dir
+
+ def prep(self):
+ self.fail_count = 0
+ self.pass_count = 0
+ self.skip_count = 0
+
+ def run_exe_test(self, test_name):
+ result_name_str = "%s" % os.path.basename(test_name)
+
+ test_env = os.environ.copy()
+ test_env["ABS_TOP_BUILDDIR"] = self.build_dir
+ test_env["ABS_TOP_SRCDIR"] = self.src_dir
+ test_env["GEGL_SWAP"] = "RAM"
+ test_env["GEGL_PATH"] = os.path.join(self.build_dir, "operations")
+
+ if test_name.endswith(".sh"):
+ test_exe = [SHELL, "./" + test_name]
+ elif test_name.endswith(".py"):
+ test_exe = [PYTHON, "./" + test_name]
+ else:
+ test_exe = ["./" + test_name]
+
+ try:
+ print(" ".join(test_exe))
+ subprocess.check_call(test_exe, env=test_env)
+ except KeyboardInterrupt:
+ raise
+ except subprocess.CalledProcessError as error:
+ if (error.returncode == 77):
+ # 77 is the magic automake skip value
+ print (SKIP_STR, result_name_str)
+ self.skip_count += 1
+ return True
+ print (FAIL_STR, result_name_str)
+ self.fail_count += 1
+ return False
+ print (PASS_STR, result_name_str)
+ self.pass_count += 1
+ return True
+
+def main():
+ parser = argparse.ArgumentParser()
+ # parser.add_argument("--without-opencl",
+ # action="store_true",
+ # help="disable OpenCL when running tests")
+ parser.add_argument("--build-dir",
+ help="path to the top build directory")
+ parser.add_argument("--src-dir",
+ help="path to the top source directory")
+ parser.add_argument("FILES",
+ nargs="*",
+ help="the test programs to run")
+
+ args = parser.parse_args()
+
+ context = Context()
+
+ if args.src_dir:
+ context.src_dir = os.path.realpath(args.src_dir)
+
+ if args.build_dir:
+ context.build_dir = os.path.realpath(args.build_dir)
+
+ tests = args.FILES
+
+ if not tests:
+ sys.exit(0)
+
+ context.prep()
+
+ for testfile in tests:
+ context.run_exe_test(testfile)
+ sys.stdout.flush() # Keep our ouput in sync with subprocess if redirected
+
+ print ("=== Test Results ===")
+ print (" tests passed: %d" % context.pass_count)
+ print (" tests skipped: %d" % context.skip_count)
+ print (" tests failed: %d" % context.fail_count)
+
+ if context.fail_count == 0:
+ print ("====== %s ======" % PASS_STR)
+ sys.exit(0)
+ else:
+ print ("====== %s ======" % FAIL_STR)
+ sys.exit(1)
+
+main()
\ No newline at end of file
diff --git a/tests/simple/Makefile.am b/tests/simple/Makefile.am
index dd1820f..f600690 100644
--- a/tests/simple/Makefile.am
+++ b/tests/simple/Makefile.am
@@ -1,9 +1,3 @@
-# Make the tests run against the build and not the installation
-TESTS_ENVIRONMENT = \
- GEGL_PATH=$(top_builddir)/operations/ \
- ABS_TOP_BUILDDIR=$(top_builddir) \
- ABS_TOP_SRCDIR=$(top_srcdir)
-
# The tests
noinst_PROGRAMS = \
test-buffer-cast \
@@ -48,5 +42,10 @@ AM_CFLAGS = $(DEP_CFLAGS) $(BABL_CFLAGS)
LIBS = $(top_builddir)/gegl/libgegl-$(GEGL_API_VERSION).la \
$(DEP_LIBS) $(BABL_LIBS)
+check-TESTS: $(TESTS)
+ $(PYTHON) $(srcdir)/../run-tests.py \
+ --build-dir=$(top_builddir) --src-dir=$(top_srcdir) \
+ $(TESTS)
+
clean-local:
rm -f test-exp-combine.hdr test-exp-combine-diff.png
diff --git a/tests/xml/Makefile.am b/tests/xml/Makefile.am
index c83654c..5370d69 100644
--- a/tests/xml/Makefile.am
+++ b/tests/xml/Makefile.am
@@ -1,17 +1,5 @@
SUBDIRS = data
-# Make the tests run against the build and not the installation
-TESTS_ENVIRONMENT = \
- export GEGL_PATH=$(top_builddir)/operations/;\
- export ABS_TOP_BUILDDIR=$(top_builddir); \
- export ABS_TOP_SRCDIR=$(top_srcdir) ;
-
-LOG_COMPILER = \
- gtester
-
-AM_LOG_FLAGS = \
- -k --verbose
-
# The tests
noinst_PROGRAMS = \
test-save \
@@ -42,3 +30,8 @@ AM_CFLAGS = $(DEP_CFLAGS) $(BABL_CFLAGS)
# Common libs
LIBS = $(top_builddir)/gegl/libgegl-$(GEGL_API_VERSION).la \
$(DEP_LIBS) $(BABL_LIBS)
+
+check-TESTS: $(TESTS)
+ $(PYTHON) $(srcdir)/../run-tests.py \
+ --build-dir=$(top_builddir) --src-dir=$(top_srcdir) \
+ $(TESTS)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]