[gjs] test: Fix debugger test script to print diff properly



commit e76f9ae52ce940e83e47ce70aeda64069f8d572a
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Nov 24 21:57:14 2020 -0800

    test: Fix debugger test script to print diff properly
    
    We added this test for the exit code because the tests weren't failing if
    one of the commands earlier in the pipeline failed, but mistakenly
    suppressed printing a diff of the output (because diff always "fails" if
    there is a difference.)
    
    If there is a diff, print it; only if there is no diff, look at the exit
    code.
    
    Unreviewed, pushing to make developing the debugger easier.

 installed-tests/debugger-test.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/installed-tests/debugger-test.sh b/installed-tests/debugger-test.sh
index 08b3661f..29f0930f 100755
--- a/installed-tests/debugger-test.sh
+++ b/installed-tests/debugger-test.sh
@@ -17,14 +17,15 @@ THE_DIFF=$("$gjs" -d "$JS_SCRIPT" < "$DEBUGGER_SCRIPT" | sed \
     -e "s#$1#$(basename $1)#g" \
     -e "s/0x[0-9a-f]\{4,16\}/0xADDR/g" \
     | diff -u "$EXPECTED_OUTPUT" -)
-if test $? -ne 0; then
-    echo "not ok 1 - $1  # command failed"
-    exit 1
-fi
+EXITCODE=$?
 
 if test -n "$THE_DIFF"; then
     echo "not ok 1 - $1"
     echo "$THE_DIFF" | while read line; do echo "#$line"; done
 else
+    if test $EXITCODE -ne 0; then
+        echo "not ok 1 - $1  # command failed"
+        exit 1
+    fi
     echo "ok 1 - $1"
 fi


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