Redo test suite to be able to test more than one command at a time. Eliminate
$COMMAND environment variable, instead put full command line (including command to run) in second argument. Modify $PATH to have test versions of commands at start of path. (Also more infrastructure for testing as root, work in progress...)
This commit is contained in:
		@@ -6,7 +6,6 @@
 | 
			
		||||
 | 
			
		||||
# AUDIT: Full SUSv3 coverage (except internationalization).
 | 
			
		||||
 | 
			
		||||
if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi
 | 
			
		||||
. testing.sh
 | 
			
		||||
 | 
			
		||||
# testing "test name" "options" "expected result" "file input" "stdin"
 | 
			
		||||
@@ -15,25 +14,25 @@ if [ ${#COMMAND} -eq 0 ]; then COMMAND=uniq; fi
 | 
			
		||||
 | 
			
		||||
# Test exit status
 | 
			
		||||
 | 
			
		||||
testing "uniq (exit with error)" "nonexistent 2> /dev/null || echo yes" \
 | 
			
		||||
testing "uniq (exit with error)" "uniq nonexistent 2> /dev/null || echo yes" \
 | 
			
		||||
	"yes\n" "" ""
 | 
			
		||||
testing "uniq (exit success)" "/dev/null && echo yes" "yes\n" "" ""
 | 
			
		||||
testing "uniq (exit success)" "uniq /dev/null && echo yes" "yes\n" "" ""
 | 
			
		||||
 | 
			
		||||
# Test various data sources and destinations
 | 
			
		||||
 | 
			
		||||
testing "uniq (default to stdin)" "" "one\ntwo\nthree\n" "" \
 | 
			
		||||
testing "uniq (default to stdin)" "uniq" "one\ntwo\nthree\n" "" \
 | 
			
		||||
	"one\ntwo\ntwo\nthree\nthree\nthree\n"
 | 
			
		||||
testing "uniq - (specify stdin)" "-" "one\ntwo\nthree\n" "" \
 | 
			
		||||
testing "uniq - (specify stdin)" "uniq -" "one\ntwo\nthree\n" "" \
 | 
			
		||||
	"one\ntwo\ntwo\nthree\nthree\nthree\n"
 | 
			
		||||
testing "uniq input (specify file)" "input" "one\ntwo\nthree\n" \
 | 
			
		||||
testing "uniq input (specify file)" "uniq input" "one\ntwo\nthree\n" \
 | 
			
		||||
	"one\ntwo\ntwo\nthree\nthree\nthree\n" ""
 | 
			
		||||
 | 
			
		||||
testing "uniq input outfile (two files)" "input actual > /dev/null" \
 | 
			
		||||
testing "uniq input outfile (two files)" "uniq input actual > /dev/null" \
 | 
			
		||||
	"one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
 | 
			
		||||
testing "uniq (stdin) outfile" "- actual" \
 | 
			
		||||
testing "uniq (stdin) outfile" "uniq - actual" \
 | 
			
		||||
	"one\ntwo\nthree\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n"
 | 
			
		||||
# Note: SUSv3 doesn't seem to require support for "-" output, but we do anyway.
 | 
			
		||||
testing "uniq input - (specify stdout)" "input -" \
 | 
			
		||||
testing "uniq input - (specify stdout)" "uniq input -" \
 | 
			
		||||
	"one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" ""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -47,13 +46,13 @@ testing "uniq input - (specify stdout)" "input -" \
 | 
			
		||||
 | 
			
		||||
# Leading whitespace is a minor technical violation of the spec,
 | 
			
		||||
# but since gnu does it...
 | 
			
		||||
testing "uniq -c (occurrence count)" "-c | sed 's/^[ \t]*//'" \
 | 
			
		||||
testing "uniq -c (occurrence count)" "uniq -c | sed 's/^[ \t]*//'" \
 | 
			
		||||
	"1 one\n2 two\n3 three\n" "" \
 | 
			
		||||
	"one\ntwo\ntwo\nthree\nthree\nthree\n"
 | 
			
		||||
testing "uniq -d (dups only) " "-d" "two\nthree\n" "" \
 | 
			
		||||
testing "uniq -d (dups only) " "uniq -d" "two\nthree\n" "" \
 | 
			
		||||
	"one\ntwo\ntwo\nthree\nthree\nthree\n"
 | 
			
		||||
 | 
			
		||||
testing "uniq -f -s (skip fields and chars)" "-f2 -s 3" \
 | 
			
		||||
testing "uniq -f -s (skip fields and chars)" "uniq -f2 -s 3" \
 | 
			
		||||
"cc	dd	ee8
 | 
			
		||||
aa	bb	cc9
 | 
			
		||||
" "" \
 | 
			
		||||
@@ -65,7 +64,7 @@ aa	bb	cc9
 | 
			
		||||
# -d is "Suppress the writing fo lines that are not repeated in the input."
 | 
			
		||||
# -u is "Suppress the writing of lines that are repeated in the input."
 | 
			
		||||
# Therefore, together this means they should produce no output.
 | 
			
		||||
testing "uniq -u and -d produce no output" "-d -u" "" "" \
 | 
			
		||||
testing "uniq -u and -d produce no output" "uniq -d -u" "" "" \
 | 
			
		||||
	"one\ntwo\ntwo\nthree\nthree\nthree\n"
 | 
			
		||||
 | 
			
		||||
exit $FAILCOUNT
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user