Add build-time check and autopkgtest support
authorRafael Laboissière <rafael@debian.org>
Sun, 7 Jan 2024 19:38:03 +0000 (16:38 -0300)
committerRafael Laboissière <rafael@debian.org>
Mon, 8 Jan 2024 19:54:36 +0000 (16:54 -0300)
Closes: #1035174
debian/clean [new file with mode: 0644]
debian/control
debian/rules
debian/tests/control [new file with mode: 0644]
debian/tests/run-tests [new file with mode: 0755]

diff --git a/debian/clean b/debian/clean
new file mode 100644 (file)
index 0000000..0d9670e
--- /dev/null
@@ -0,0 +1,3 @@
+examples/mgl_example
+examples/*.png
+sample.png
index aeb7f7b1855d8f504bfcb88dabbf31adbbb5cd71..0aaf86092326c58fdd178b2e3a436df309eecf8c 100644 (file)
@@ -11,6 +11,7 @@ Build-Depends:
  debhelper-compat (= 13),
  desktop-file-utils,
  dh-sequence-python3,
+ file,
  fluid,
  freeglut3-dev,
  libfltk1.3-dev,
index fb3d742d6a1ad4484f4c8812d14dc77cefabbd21..c4c7c7161b0897dc830b532f3aeea220a10d582e 100755 (executable)
@@ -53,3 +53,8 @@ ifneq (,$(filter $(DEB_BUILD_ARCH),mips mipsel alpha))
 override_dh_dwz:
        @echo bypass dwz that causes build failures
 endif
+
+override_dh_auto_test:
+ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
+       LOCAL=true debian/tests/run-tests
+endif
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644 (file)
index 0000000..6be16ad
--- /dev/null
@@ -0,0 +1,2 @@
+Test-Command: debian/tests/run-tests
+Depends: @, @builddeps@
diff --git a/debian/tests/run-tests b/debian/tests/run-tests
new file mode 100755 (executable)
index 0000000..d03e004
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+set -e
+
+LOCAL=${LOCAL:-false}
+CWD=$(pwd)
+BUILDDIR=obj-$(dpkg-architecture -qDEB_BUILD_MULTIARCH)
+
+if [ $LOCAL = true ] ; then
+    cd $BUILDDIR/examples
+    make
+    export PYTHONPATH=$CWD/$BUILDDIR/lang/
+    export LD_LIBRARY_PATH=$CWD/$BUILDDIR/src/
+else
+    cd examples
+    g++ wnd_samples.cpp full_test.cpp samples.cpp -o mgl_example -lmgl
+fi
+
+check_png() {
+    FILE=$1.png
+    echo -n "$FILE: "
+    file --brief $FILE | grep -q "^PNG image data,"
+    echo ok
+    rm -f $FILE
+}
+
+NAMES="$(./mgl_example)"
+rm -f mgl_example
+
+for i in $NAMES ; do
+    check_png $i
+done
+
+cd $CWD
+python3 examples/test.py
+check_png sample