Fix default log level in log_warn_die.sh.

This commit is contained in:
Daniel Nichter
2013-01-24 11:39:23 -07:00
parent 738359dd10
commit 26cc08d3d9
8 changed files with 31 additions and 28 deletions

View File

@@ -26,15 +26,15 @@ ts() {
}
info() {
[ ${OPT_VERBOSE:-0} -ge 3 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 3 ] && ts "$*"
}
log() {
[ ${OPT_VERBOSE:-0} -ge 2 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 2 ] && ts "$*"
}
warn() {
[ ${OPT_VERBOSE:-0} -ge 1 ] && ts "$*" >&2
[ ${OPT_VERBOSE:-3} -ge 1 ] && ts "$*" >&2
EXIT_STATUS=1
}

View File

@@ -28,15 +28,15 @@ ts() {
}
info() {
[ ${OPT_VERBOSE:-0} -ge 3 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 3 ] && ts "$*"
}
log() {
[ ${OPT_VERBOSE:-0} -ge 2 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 2 ] && ts "$*"
}
warn() {
[ ${OPT_VERBOSE:-0} -ge 1 ] && ts "$*" >&2
[ ${OPT_VERBOSE:-3} -ge 1 ] && ts "$*" >&2
EXIT_STATUS=1
}

View File

@@ -28,15 +28,15 @@ ts() {
}
info() {
[ ${OPT_VERBOSE:-0} -ge 3 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 3 ] && ts "$*"
}
log() {
[ ${OPT_VERBOSE:-0} -ge 2 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 2 ] && ts "$*"
}
warn() {
[ ${OPT_VERBOSE:-0} -ge 1 ] && ts "$*" >&2
[ ${OPT_VERBOSE:-3} -ge 1 ] && ts "$*" >&2
EXIT_STATUS=1
}

View File

@@ -35,15 +35,15 @@ ts() {
}
info() {
[ ${OPT_VERBOSE:-0} -ge 3 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 3 ] && ts "$*"
}
log() {
[ ${OPT_VERBOSE:-0} -ge 2 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 2 ] && ts "$*"
}
warn() {
[ ${OPT_VERBOSE:-0} -ge 1 ] && ts "$*" >&2
[ ${OPT_VERBOSE:-3} -ge 1 ] && ts "$*" >&2
EXIT_STATUS=1
}

View File

@@ -34,15 +34,15 @@ ts() {
}
info() {
[ ${OPT_VERBOSE:-0} -ge 3 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 3 ] && ts "$*"
}
log() {
[ ${OPT_VERBOSE:-0} -ge 2 ] && ts "$*"
[ ${OPT_VERBOSE:-3} -ge 2 ] && ts "$*"
}
warn() {
[ ${OPT_VERBOSE:-0} -ge 1 ] && ts "$*" >&2
[ ${OPT_VERBOSE:-3} -ge 1 ] && ts "$*" >&2
EXIT_STATUS=1
}

View File

@@ -1,17 +1,15 @@
#!/usr/bin/env bash
plan 6
source "$LIB_DIR/log_warn_die.sh"
log "Hello world!" > $TEST_PT_TMPDIR/log
log "Hello world A!" > $TEST_PT_TMPDIR/log
cmd_ok \
"grep -q 'Hello world!' $TEST_PT_TMPDIR/log" \
"grep -q 'Hello world A!' $TEST_PT_TMPDIR/log" \
"log msg"
log "Hello" "world!" > $TEST_PT_TMPDIR/log
log "Hello" "world B!" > $TEST_PT_TMPDIR/log
cmd_ok \
"grep -q 'Hello world!' $TEST_PT_TMPDIR/log" \
"grep -q 'Hello world B!' $TEST_PT_TMPDIR/log" \
"log msg msg"
is \
@@ -19,14 +17,14 @@ is \
"0" \
"Exit status 0"
warn "Hello world!" 2> $TEST_PT_TMPDIR/log
warn "Hello world C!" 2> $TEST_PT_TMPDIR/log
cmd_ok \
"grep -q 'Hello world!' $TEST_PT_TMPDIR/log" \
"grep -q 'Hello world C!' $TEST_PT_TMPDIR/log" \
"warn msg"
warn "Hello" "world!" 2> $TEST_PT_TMPDIR/log
warn "Hello" "world D!" 2> $TEST_PT_TMPDIR/log
cmd_ok \
"grep -q 'Hello world!' $TEST_PT_TMPDIR/log" \
"grep -q 'Hello world D!' $TEST_PT_TMPDIR/log" \
"warn msg msg"
is \
@@ -111,3 +109,4 @@ file_is_empty \
# ###########################################################################
# Done
# ###########################################################################
done_testing

View File

@@ -17,7 +17,7 @@ my $output = `$trunk/bin/pt-stalk --help`;
like(
$output,
qr/^\s+--verbose\s+2/m,
qr/^\s+--vebose\s+2/m,
"Default --verbose=2"
);

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,6 +121,10 @@ plan() {
fi
}
done_testing() {
echo "1..$testno"
}
#
# The following subs are for the test files to call.
#
@@ -260,7 +264,7 @@ diag() {
# Script starts here
# ############################################################################
testno=1
testno=0
failed_tests=0
if [ $# -eq 0 ]; then