ci: Make sure we save gtdr test results on failures
authorJonathan Lebon <jlebon@redhat.com>
Mon, 27 Nov 2017 17:18:56 +0000 (17:18 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 27 Nov 2017 17:46:07 +0000 (17:46 +0000)
If a test fails, we immediately exit and thus never get a chance to
actually upload the test results. Add a trap so that they always
uploaded, even on failure.

Closes: #1350
Approved by: cgwalters

ci/build-check.sh

index 2f4ddabae3ee7bc8c75f3e0520e81e00ade9959c..6e8b3930db2219fbfb88e87fb46801ecdf219076 100755 (executable)
@@ -16,6 +16,17 @@ for x in test-suite.log config.log; do
 done
 # And now run the installed tests
 make install
+
+copy_out_gdtr_artifacts() {
+    # Keep this in sync with papr.yml
+    # TODO; Split the main/clang builds into separate build dirs
+    for x in test-suite.log config.log gdtr-results; do
+        if test -e ${resultsdir}/${x}; then
+            mv ${resultsdir}/${x} ${topdir}
+        fi
+    done
+}
+
 if test -x /usr/bin/gnome-desktop-testing-runner; then
     mkdir ${resultsdir}/gdtr-results
     # Temporary hack
@@ -24,6 +35,8 @@ if test -x /usr/bin/gnome-desktop-testing-runner; then
      env NOCONFIGURE=1 ./autogen.sh
      ./configure --prefix=/usr --libdir=/usr/lib64
      make && rm -f /usr/bin/ginsttest-runner && make install)
+    # set a trap in case a test fails
+    trap copy_out_gdtr_artifacts EXIT
     # Use the new -L option
     gnome-desktop-testing-runner -L ${resultsdir}/gdtr-results -p 0 ${INSTALLED_TESTS_PATTERN:-libostree/}
 fi
@@ -38,11 +51,3 @@ if test -x /usr/bin/clang; then
     export CC=clang
     build
 fi
-
-# Keep this in sync with papr.yml
-# TODO; Split the main/clang builds into separate build dirs
-for x in test-suite.log config.log gdtr-results; do
-    if test -e ${resultsdir}/${x}; then
-        mv ${resultsdir}/${x} ${topdir}
-    fi
-done