[osinfo-db-tools PATCH 1/2] tests: Only run the tests if deps are installed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Let's check whether we have all the deps installed in the system and
only run the tests if that's the case.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 configure.ac      | 23 +++++++++++++++++++++++
 tests/Makefile.am |  6 +++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d87f86c..1f29468 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,29 @@ AC_PROG_LN_S
 # Perl is needed for syntax-check
 AC_PATH_PROG([PERL], [perl])
 
+# python3, python3-pytest and python3-requests are needed for our tests
+AC_CHECK_PROG(HAVE_PYTHON3, python3, yes, no)
+if test "x$HAVE_PYTHON3" == "xyes";
+then
+    PYTHON="python3"
+
+    $PYTHON -c "import pytest"
+    if test $? -eq 0;
+    then
+        HAVE_PYTEST="yes"
+    fi
+
+    $PYTHON -c "import requests"
+    if test $? -eq 0;
+    then
+        HAVE_REQUESTS="yes"
+    fi
+else
+    HAVE_PYTEST="no"
+    HAVE_REQUESTS="no"
+fi
+AM_CONDITIONAL([EXECUTE_TESTS], [test "x$HAVE_PYTEST" == "xyes" -a "x$HAVE_REQUESTS" = "xyes"])
+
 LT_INIT([shared disable-static win32-dll])
 
 LIBOSINFO_COMPILE_WARNINGS
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f9755a0..efa31df 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,7 +15,10 @@ EXTRA_DIST += \
 	$(test_programs) \
 	$(NULL)
 
-TESTS = \
+TESTS =
+
+if EXECUTE_TESTS
+TESTS += \
 	$(test_programs) \
 	$(NULL)
 
@@ -24,3 +27,4 @@ TESTS_ENVIRONMENT = \
 	abs_top_srcdir="$(abs_top_srcdir)" \
 	datadir="$(datadir)" \
 	sysconfdir="$(sysconfdir)"
+endif
-- 
2.20.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux