[ostree] tests: Strengthen test tmpdir sanity check, be compat with ginsttest saving



commit a02b425fc241556d6e4aed1ed69e00b77e3cc758
Author: Colin Walters <walters verbum org>
Date:   Fri Mar 18 08:43:53 2016 -0400

    tests: Strengthen test tmpdir sanity check, be compat with ginsttest saving
    
    GNOME Continuous uses ginstest-runner --report-directory, which causes
    the tests to save their tmpdirs persistently.  This also means the
    result directories didn't match the `/(var/)?tmp` regexp, which broke
    the ostree tests in GContinuous.
    
    Fix this by simply asserting that the tmpdir either has `.tmpdir` or
    nothing.

 tests/libtest.sh |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/tests/libtest.sh b/tests/libtest.sh
index 0db3382..06982d2 100755
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -25,13 +25,14 @@ assert_not_reached () {
 
 test_tmpdir=$(pwd)
 
-# Extra sanity checks
-if test -d .git; then
-    assert_not_reached "Found .git, not in a tempdir?"
-fi
-echo "in ${test_tmpdir}"
-if ! echo ${test_tmpdir} | grep -E -q '^/(var/)?tmp'; then
-    assert_not_reached "Not in /tmp or /var/tmp"
+# Sanity check that we're in a tmpdir that has
+# just .testtmp (created by tap-driver for `make check`,
+# or nothing at all (as ginstest-runner does)
+if ! test -f .testtmp; then
+    files=$(ls)
+    if test -n "${files}"; then
+       assert_not_reached "test tmpdir=${test_tmpdir} is not empty; run this test via \`make check TESTS=\`, 
not directly"
+    fi
 fi
 
 export G_DEBUG=fatal-warnings


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