Merge 2.1.9 fixes.

This commit is contained in:
Daniel Nichter
2013-02-05 09:47:17 -07:00
33 changed files with 1130 additions and 130 deletions

View File

@@ -100,6 +100,7 @@ run_test() {
result() {
local result=$1
local test_name=${2:-""}
testno=$((testno + 1))
if [ $result -eq 0 ]; then
echo "ok $testno - $TEST_FILE $test_name"
else
@@ -110,7 +111,6 @@ result() {
cat $TEST_PT_TMPDIR/failed_result | sed -e 's/^/# /' -e '30q' >&2
fi
fi
testno=$((testno + 1))
return $result
}
@@ -121,19 +121,21 @@ plan() {
fi
}
done_testing() {
echo "1..$testno"
}
#
# The following subs are for the test files to call.
#
pass() {
local reason="${1:-""}"
result 0 "$reason"
}
fail() {
local reason="${1:-""}"
result 1 "$reason"
}
@@ -177,6 +179,42 @@ is() {
result $? "$test_name"
}
file_is_empty() {
local file=$1
local test_name=${2:-""}
test_command="-s $file"
if [ ! -f "$file" ]; then
echo "$file does not exist" > $TEST_PT_TMPDIR/failed_result
result 1 "$test_name"
fi
if [ -s "$file" ]; then
echo "$file is not empty:" > $TEST_PT_TMPDIR/failed_result
cat "$file" >> $TEST_PT_TMPDIR/failed_result
result 1 "$test_name"
else
result 0 "$test_name"
fi
}
file_contains() {
local file="$1"
local pat="$2"
local test_name=${3:-""}
test_command="grep -q '$pat' '$file'"
if [ ! -f "$file" ]; then
echo "$file does not exist" > $TEST_PT_TMPDIR/failed_result
result 1 "$test_name"
fi
grep -q "$pat" $file
if [ $? -ne 0 ]; then
echo "$file does not contain '$pat':" > $TEST_PT_TMPDIR/failed_result
cat "$file" >> $TEST_PT_TMPDIR/failed_result
result 1 "$test_name"
else
result 0 "$test_name"
fi
}
cmd_ok() {
local test_command=$1
local test_name=${2:-""}
@@ -226,7 +264,7 @@ diag() {
# Script starts here
# ############################################################################
testno=1
testno=0
failed_tests=0
if [ $# -eq 0 ]; then