view scripts/test/tac.test @ 1393:3e8ab37a4b60 draft

Find bugfixes. The check for -print vs -print0 was tested before I optimized out the "-" in the strcmps, and I didn't adjust the offset or retest it. (Ooops.) Also, I wasn't clearing the ! value when descending into parentheticals, so "find . -name blah -o \! \( -stuff -o -thing \)" acted like it had a spurious second ! before -stuff inside the parentheses.
author Rob Landley <rob@landley.net>
date Fri, 18 Jul 2014 18:31:41 -0500
parents 54d248b907ed
children
line wrap: on
line source

#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"


echo -e "one-A\none-B" > file1 
echo -e "two-A\ntwo-B" > file2
testing "tac" "tac && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
testing "tac -" "tac - && echo yes" "one-B\none-A\nyes\n" "" "one-A\none-B\n"
testing "tac file1 file2" "tac file1 file2" "one-B\none-A\ntwo-B\ntwo-A\n"  "" ""
testing "tac - file"      "tac - file1"     "zero-B\nzero-A\none-B\none-A\n" "" "zero-A\nzero-B\n"
testing "tac file -"      "tac file1 -"     "one-B\none-A\nzero-B\nzero-A\n" "" "zero-A\nzero-B\n"

testing "tac file1 notfound file2" \
        "tac file1 notfound file2 2>stderr && echo ok ; tac stderr; rm stderr" \
        "one-B\none-A\ntwo-B\ntwo-A\ntac: notfound: No such file or directory\n" "" ""

testing "tac no trailing newline" "tac -" "defabc\n" "" "abc\ndef"

# xputs used by tac does not propagate this error condition properly. 
#testing "tac > /dev/full" \
#        "tac - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \
#        "tac: write: No space left on device\n" "" "zero\n"

# 

rm file1 file2