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.)
This commit is contained in:
2
Makefile
2
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*-*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user