[mutter/gbsneto/burn-autotools-with-fire: 8/15] cogl/tests: Use temp log file when .log isn't writable



commit 9ce7ce00de7ba3c217e744708fa0844d111a0779
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Dec 17 13:12:29 2018 -0200

    cogl/tests: Use temp log file when .log isn't writable
    
    When running installed tests, the working directory for Cogl
    tests is /usr/libexec/installed-tests/mutter-cogl-4/conform,
    which isn't writable by normal users.
    
    To avoid the need of running those tests as root, adapt the
    runner script to fallback to $(mktemp) - which is available
    on all platform we care about - and avoid trying to write to
    unwritable files.

 cogl/tests/run-tests.sh | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/cogl/tests/run-tests.sh b/cogl/tests/run-tests.sh
index 6934bccd6..6af358f55 100755
--- a/cogl/tests/run-tests.sh
+++ b/cogl/tests/run-tests.sh
@@ -21,6 +21,15 @@ shift
 
 set +m
 
+LOG=".log"
+if test ! -w "$LOG"; then
+    LOG=$(mktemp)
+fi
+
+echo ""
+echo "Writing logs to $LOG"
+echo ""
+
 trap "" ERR
 trap "" SIGABRT
 trap "" SIGFPE
@@ -65,17 +74,17 @@ get_status()
 
 run_test()
 {
-  $("$TEST_BINARY" "$1" &>.log)
+  $("$TEST_BINARY" "$1" &> "$LOG")
   TMP=$?
   var_name=$2_result
   eval "$var_name=$TMP"
-  if grep -q "$MISSING_FEATURE" .log; then
+  if grep -q "$MISSING_FEATURE" "$LOG"; then
     if test "$TMP" -ne 0; then
       eval "$var_name=500"
     else
       eval "$var_name=400"
     fi
-  elif grep -q "$KNOWN_FAILURE" .log; then
+  elif grep -q "$KNOWN_FAILURE" "$LOG"; then
     if test $TMP -ne 0; then
       eval "$var_name=300"
     else


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