testsuite: allow tests to work in paths containing spaces
authorRon Yorston <rmy@pobox.com>
Fri, 9 Feb 2018 09:52:52 +0000 (09:52 +0000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 9 Apr 2018 18:35:48 +0000 (20:35 +0200)
Tweak some tests so they work when the path to the test directory or
$HOME contains spaces.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
testsuite/grep.tests
testsuite/printf.tests
testsuite/pwd/pwd-prints-working-directory
testsuite/sum.tests
testsuite/xargs/xargs-works

index d0b0d2767cb26a4818b2979e9282a1f06c413a69..e578897905e3a0f48b1c3f78937af3bb670f5d35 100755 (executable)
@@ -15,7 +15,7 @@
 
 testing "grep (exit with error)" "grep nonexistent 2> /dev/null ; echo \$?" \
        "1\n" "" ""
-testing "grep (exit success)" "grep grep $0 > /dev/null 2>&1 ; echo \$?" "0\n" \
+testing "grep (exit success)" "grep grep '$0' > /dev/null 2>&1 ; echo \$?" "0\n" \
        "" ""
 # Test various data sources and destinations
 
index 9a3c8747361b139a6e7e6fec228bbab83ed5dd7d..963ded94b4a398cb815f20889ef2852838d32503 100755 (executable)
@@ -20,7 +20,7 @@ testing "printf produces no further output 2" \
        "" ""
 
 testing "printf repeatedly uses pattern for each argv" \
-       "${bb}printf '%s\n' foo \$HOME" \
+       "${bb}printf '%s\n' foo '$HOME'" \
        "foo\n$HOME\n" \
        "" ""
 
index 971adb5a629ee0ece3bcd47fc2944766933c8d3b..fc7fea7c9e4b87a3ee8eeed686df624e24f2e33c 100644 (file)
@@ -1,4 +1,4 @@
 # shell's $PWD may leave symlinks unresolved.
 # "pwd" may be a built-in and have the same problem.
 # External pwd _can't_ have that problem (current dir on Unix is physical).
-test $(`which pwd`) = $(busybox pwd)
+test "$(`which pwd`)" = "$(busybox pwd)"
index b9f4cbfa839ddc7f2f3ca986236b272795558528..e6379349f20581612ce1038a977d68f76f75ef94 100755 (executable)
 #   test can create a file "actual" instead of writing to stdout
 
 testing "sum -r file doesn't print file's name" \
-        "sum -r $0 | grep -c $0 && echo wrongly_printed_filename || echo yes" \
+        "sum -r '$0' | grep -c '$0' && echo wrongly_printed_filename || echo yes" \
        "0\nyes\n" "" ""
 testing "sum -r file file does print both names" \
-        "sum -r $0 $0 | grep -c $0 && echo yes || echo wrongly_omitted_filename" \
+        "sum -r '$0' '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \
        "2\nyes\n" "" ""
 testing "sum -s file does print file's name" \
-        "sum -s $0 | grep -c $0 && echo yes || echo wrongly_omitted_filename" \
+        "sum -s '$0' | grep -c '$0' && echo yes || echo wrongly_omitted_filename" \
        "1\nyes\n" "" ""
 exit $FAILCOUNT
index c95869e89d52102c21d703afbf4bc237d1000c13..a4bba763007c26177c18259c389a4b5ce7bdb9b9 100644 (file)
@@ -1,4 +1,6 @@
+# FEATURE: CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM
+
 [ -n "$d" ] || d=..
-find "$d" -name \*works -type f | xargs md5sum > logfile.gnu
-find "$d" -name \*works -type f | busybox xargs md5sum > logfile.bb
+find "$d" -name \*works -type f -print0 | xargs -0 md5sum > logfile.gnu
+find "$d" -name \*works -type f -print0 | busybox xargs -0 md5sum > logfile.bb
 diff -u logfile.gnu logfile.bb