Add support for non-Python unittests
authorMichael Hanselmann <hansmi@google.com>
Thu, 11 Mar 2010 17:28:54 +0000 (18:28 +0100)
committerMichael Hanselmann <hansmi@google.com>
Fri, 12 Mar 2010 15:44:50 +0000 (16:44 +0100)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

Makefile.am
autotools/testrunner [new file with mode: 0755]

index 64b15e6..bf97265 100644 (file)
@@ -247,6 +247,7 @@ EXTRA_DIST = \
        autotools/check-man \
        autotools/docbook-wrapper \
        autotools/gen-coverage \
+       autotools/testrunner \
        $(RUN_IN_TEMPDIR) \
        daemons/daemon-util.in \
        daemons/ganeti-cleaner.in \
@@ -318,7 +319,7 @@ TEST_FILES = \
        test/data/proc_drbd80-emptyline.txt \
        test/data/proc_drbd83.txt
 
-dist_TESTS = \
+python_tests = \
        test/ganeti.bdev_unittest.py \
        test/ganeti.cli_unittest.py \
        test/ganeti.cmdlib_unittest.py \
@@ -340,6 +341,9 @@ dist_TESTS = \
        test/docs_unittest.py \
        test/tempfile_fork_unittest.py
 
+dist_TESTS = \
+       $(python_tests)
+
 nodist_TESTS =
 
 TESTS = $(dist_TESTS) $(nodist_TESTS)
@@ -349,12 +353,13 @@ PLAIN_TESTS_ENVIRONMENT = \
        PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) $(RUN_IN_TEMPDIR)
 
 # Environment for tests run by automake
-TESTS_ENVIRONMENT = $(PLAIN_TESTS_ENVIRONMENT) $(PYTHON)
+TESTS_ENVIRONMENT = \
+       $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/testrunner
 
 all_python_code = \
        $(dist_sbin_SCRIPTS) \
        $(dist_tools_SCRIPTS) \
-       $(dist_TESTS) \
+       $(python_tests) \
        $(pkgpython_PYTHON) \
        $(hypervisor_PYTHON) \
        $(rapi_PYTHON) \
@@ -545,12 +550,13 @@ TAGS: $(BUILT_SOURCES)
          etags -
 
 .PHONY: coverage
-coverage: $(BUILT_SOURCES) $(TESTS)
+coverage: $(BUILT_SOURCES) $(python_tests)
        set -e; \
        mkdir -p doc/coverage; \
        COVERAGE_FILE=$(CURDIR)/doc/coverage/data \
        TEXT_COVERAGE=$(CURDIR)/doc/coverage/report.txt \
        HTML_COVERAGE=$(CURDIR)/doc/coverage \
-       $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage $(TESTS)
+       $(PLAIN_TESTS_ENVIRONMENT) $(abs_top_srcdir)/autotools/gen-coverage \
+       $(python_tests)
 
 # vim: set noet :
diff --git a/autotools/testrunner b/autotools/testrunner
new file mode 100755 (executable)
index 0000000..d933613
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+
+# Copyright (C) 2010 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+set -e
+
+filename=$1
+
+case "$filename" in
+  *.py) exec $PYTHON "$@" ;;
+  *) exec "$@" ;;
+esac