[PATCH 03 of 11 cubicweb/debian] [pkg] Run test suite as part of autopkgtest

Jérémy Bobbio jeremy.bobbio at irq7.fr
Thu Jun 13 17:18:57 CEST 2019


# HG changeset patch
# User Jérémy Bobbio <jeremy.bobbio at irq7.fr>
# Date 1559752551 -7200
#      Wed Jun 05 18:35:51 2019 +0200
# Node ID 0212118394c1beb5c44b45fe8728f0175406d3a3
# Parent  ea87b07e728f8c420082ec25192c47f639874411
[pkg] Run test suite as part of autopkgtest

Add support for autopkgtest. The test “unittest” will run the test
suite using pytest. As we need PostgreSQL in the test environment
and open network connection, the test is marked with
`isolation-container` and requires at least LXC to be run, e.g:

    autopkgtest -s -- lxc -s autopkgtest-sid

diff -r ea87b07e728f -r 0212118394c1 debian/changelog
--- a/debian/changelog	Wed Jun 05 16:29:04 2019 +0200
+++ b/debian/changelog	Wed Jun 05 18:35:51 2019 +0200
@@ -2,6 +2,7 @@
 
   * Switch all Debian packages to Python 3.
   * Switch to Debian source format 3.0 (quilt).
+  * Run test suite as part of autopkgtest.
 
  -- Jérémy Bobbio <jeremy.bobbio at irq7.fr>  Wed, 29 May 2019 16:06:20 +0200
 
diff -r ea87b07e728f -r 0212118394c1 debian/tests/control
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/tests/control	Wed Jun 05 18:35:51 2019 +0200
@@ -0,0 +1,9 @@
+Tests: unittest
+Depends:
+ python3-cubicweb,
+ @builddeps@,
+ python3-pytest,
+ python3-crypto, python3-psycopg2,
+ postgresql, postgresql-plpython,
+ firefox
+Restrictions: allow-stderr, isolation-container
diff -r ea87b07e728f -r 0212118394c1 debian/tests/unittest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/tests/unittest	Wed Jun 05 18:35:51 2019 +0200
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+set -x
+
+### Setup tests
+
+find cubicweb -type d -name 'test' | while read dir; do
+	mkdir -p "$AUTOPKGTEST_TMP"/$(dirname "$dir")
+	cp -r "$dir" "$AUTOPKGTEST_TMP/$dir"
+done
+chown -R nobody:nogroup "$AUTOPKGTEST_TMP"
+
+### Find PostgreSQL binaries
+
+POSTGRESQL_BINDIR=$(find /usr/lib/postgresql -type f -name 'initdb' -printf "%h\n" | head -n 1)
+test "$POSTGRESQL_BINDIR" || { echo "Unable to find 'initdb'" >&2; exit 1; }
+
+### Run tests
+
+for py in $(py3versions -r 2>/dev/null); do
+	cd "$AUTOPKGTEST_TMP"
+	echo "Testing with $py:"
+	su nobody --shell /bin/sh \
+		-c "env PATH='$PATH:$POSTGRESQL_BINDIR' $py -m pytest -v"
+done


More information about the cubicweb-devel mailing list