From 2df5f9fee95800686223ee9f5078c132947637d2 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Thu, 20 Jan 2011 13:23:06 +0100 Subject: [PATCH] Fixed test environment for escaped test output. - test-lib uses 'read -r' to parse the test session input literally, without interpretation of backslashes. - FIX: Use quoting to maintain original whitespace (tabs and multiple spaces) from the test session input (instead of condensing into a single space). - Using Bash instead of POSIX shell for t1340-listescapes.sh, so that the interpretation of escape sequences is not dependent on the POSIX shell being used. - Changed Makefile so that the shell selected by the shebang line is actually used when invoking tests, not the POSIX shell. - Above changes obsolete the multiple escaping of the test session data; now, the test session can actually be pasted as-is into a test script, even when it contains backslashes. (I.e. works as expected now.) --- Makefile | 2 +- tests/t1340-listescapes.sh | 16 ++++++---------- tests/test-lib.sh | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 5ef5431..3219f85 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ test-pre-clean: aggregate-results: $(TESTS) $(TESTS): test-pre-clean - -cd tests && sh $(notdir $@) $(TEST_OPTIONS) + -cd tests && ./$(notdir $@) $(TEST_OPTIONS) test: aggregate-results tests/aggregate-results.sh tests/test-results/t*-* diff --git a/tests/t1340-listescapes.sh b/tests/t1340-listescapes.sh index e0682c3..075b9ec 100755 --- a/tests/t1340-listescapes.sh +++ b/tests/t1340-listescapes.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # test_description='list with escape sequences @@ -7,10 +7,6 @@ This test checks listing of tasks that have embedded escape sequences in them. ' . ./test-lib.sh -# Note: The quadrupled escaped backslashes (even 8-fold for the escape color -# code) in the expected output are necessary due to (superfluous?!) -# interpretation of the expected output in the test library itself. - # # check aborted list output on \c escape sequence # @@ -23,13 +19,13 @@ EOF test_todo_session 'aborted list output on backslash-c' <<'EOF' >>> todo.sh ls 1 first todo -2 second todo run C:\\\\WINDOWS\\\\sysnative\\\\cscript.exe +2 second todo run C:\WINDOWS\sysnative\cscript.exe 3 third todo -- TODO: 3 of 3 tasks shown >>> todo.sh ls 2 -2 second todo run C:\\\\WINDOWS\\\\sysnative\\\\cscript.exe +2 second todo run C:\WINDOWS\sysnative\cscript.exe -- TODO: 1 of 3 tasks shown EOF @@ -45,9 +41,9 @@ EOF test_todo_session 'various escape sequences' <<'EOF' >>> todo.sh ls -1 first todo with \\\\\\\\, \\\\a and \\\\t -2 second todo with \\\\r\\\\n line break -3 third todo with \\\\x42\\\\x55\\\\x47 and \\\\\\\\033[0;31m color codes \\\\\\\\033[0;30m +1 first todo with \\, \a and \t +2 second todo with \r\n line break +3 third todo with \x42\x55\x47 and \033[0;31m color codes \033[0;30m -- TODO: 3 of 3 tasks shown EOF diff --git a/tests/test-lib.sh b/tests/test-lib.sh index efe8960..c4f3ff5 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -527,7 +527,7 @@ test_todo_session () { cmd="" status=0 > expect - while read line + while read -r line do case $line in ">>> "*) @@ -552,7 +552,7 @@ test_todo_session () { fi ;; *) - echo $line >> expect + echo "$line" >> expect ;; esac done