Add diag() for Bash tests. Diag 'ollect_mysql_info.t find_my_cnf_file gets the correct file' when it fails.

This commit is contained in:
Daniel Nichter
2012-08-22 14:50:11 -06:00
parent f8a0eaaa7d
commit 9674c6ad88
2 changed files with 12 additions and 0 deletions

View File

@@ -85,6 +85,7 @@ is \
"$cnf_file" \ "$cnf_file" \
"/tmp/12345/my.sandbox.cnf" \ "/tmp/12345/my.sandbox.cnf" \
"find_my_cnf_file gets the correct file" "find_my_cnf_file gets the correct file"
[ $? -ne 0 ] && diag "$p/mysqld-instances"
res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt") res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt")
is "$res" "/tmp/12345/my.sandbox.cnf" "ps-mysqld-001.txt" is "$res" "/tmp/12345/my.sandbox.cnf" "ps-mysqld-001.txt"

View File

@@ -211,6 +211,17 @@ wait_for_files() {
done done
} }
diag() {
if [ $# -eq 1 -a -f "$1" ]; then
echo "# $1:"
awk '{print "# " $0}' "$1"
else
for line in "$@"; do
echo "# $line"
done
fi
}
# ############################################################################ # ############################################################################
# Script starts here # Script starts here
# ############################################################################ # ############################################################################