vici: Run Python tests via tox if available
authorTobias Brunner <tobias@strongswan.org>
Tue, 14 Jan 2020 10:00:56 +0000 (11:00 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 14 Jan 2020 14:26:52 +0000 (15:26 +0100)
Since we use the serial test harness we can't use AM_TESTS_ENVIRONMENT.
The script is necessary for out-of-tree builds.

configure.ac
src/libcharon/plugins/vici/python/Makefile.am
src/libcharon/plugins/vici/python/tox.sh [new file with mode: 0755]

index d7e7a11..ae950a4 100644 (file)
@@ -1345,6 +1345,7 @@ if test x$python_eggs = xtrue; then
        else
                AC_SUBST(PYTHONEGGINSTALLDIR, "--install-dir $pythoneggdir")
        fi
+       AC_PATH_PROG([TOX], [tox], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
        AC_PATH_PROG([PY_TEST], [py.test], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
 fi
 AM_CONDITIONAL(PYTHON_EGGS_INSTALL, [test "x$python_eggs_install" = xtrue])
@@ -1764,7 +1765,8 @@ AM_CONDITIONAL(USE_LEGACY_SYSTEMD, test -n "$systemdsystemunitdir" -a "x$systemd
 AM_CONDITIONAL(USE_RUBY_GEMS, test x$ruby_gems = xtrue)
 AM_CONDITIONAL(USE_PYTHON_EGGS, test x$python_eggs = xtrue)
 AM_CONDITIONAL(USE_PERL_CPAN, test x$perl_cpan = xtrue)
-AM_CONDITIONAL(USE_PY_TEST, test "x$PY_TEST" != x)
+AM_CONDITIONAL(USE_TOX, test "x$TOX" != x)
+AM_CONDITIONAL(USE_PY_TEST, test "x$PY_TEST" != x -a "x$TOX" = x)
 
 # ========================
 #  set global definitions
index 68166f4..8a9e6fc 100644 (file)
@@ -1,6 +1,7 @@
 EXTRA_DIST = LICENSE README.rst MANIFEST.in \
        setup.py.in \
        tox.ini \
+       tox.sh \
        vici/test/__init__.py \
        vici/test/test_protocol.py \
        vici/__init__.py \
@@ -38,6 +39,12 @@ install-exec-local: dist/vici-$(PYTHON_PACKAGE_VERSION)-py$(PYTHON_VERSION).egg
                dist/vici-$(PYTHON_PACKAGE_VERSION)-py$(PYTHON_VERSION).egg
 endif
 
+if USE_TOX
+  TESTS_ENVIRONMENT = export TOX=$(TOX);
+  AM_TESTS_FD_REDIRECT = 1>&2
+  TESTS = tox.sh
+endif
+
 if USE_PY_TEST
   TESTS = $(PY_TEST)
 endif
diff --git a/src/libcharon/plugins/vici/python/tox.sh b/src/libcharon/plugins/vici/python/tox.sh
new file mode 100755 (executable)
index 0000000..1a4f786
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+${TOX} -c ${srcdir} --skip-missing-interpreters