mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 01:16:14 +00:00
test-bash-functions: test_name is optional, so avoid it stopping us if set -u
This commit is contained in:
@@ -93,7 +93,7 @@ run_test() {
|
|||||||
# Print a TAP-style test result.
|
# Print a TAP-style test result.
|
||||||
result() {
|
result() {
|
||||||
local result=$1
|
local result=$1
|
||||||
local test_name=$2
|
local test_name=${2:-""}
|
||||||
if [ $result -eq 0 ]; then
|
if [ $result -eq 0 ]; then
|
||||||
echo "ok $testno - $TEST_FILE $test_name"
|
echo "ok $testno - $TEST_FILE $test_name"
|
||||||
else
|
else
|
||||||
@@ -115,7 +115,7 @@ result() {
|
|||||||
no_diff() {
|
no_diff() {
|
||||||
local got=$1
|
local got=$1
|
||||||
local expected=$2
|
local expected=$2
|
||||||
local test_name=$3
|
local test_name=${3:-""}
|
||||||
test_command="diff $got $expected"
|
test_command="diff $got $expected"
|
||||||
eval $test_command > $TEST_TMPDIR/failed_result 2>&1
|
eval $test_command > $TEST_TMPDIR/failed_result 2>&1
|
||||||
result $? "$test_name"
|
result $? "$test_name"
|
||||||
@@ -124,7 +124,7 @@ no_diff() {
|
|||||||
is() {
|
is() {
|
||||||
local got=$1
|
local got=$1
|
||||||
local expected=$2
|
local expected=$2
|
||||||
local test_name=$3
|
local test_name=${3:-""}
|
||||||
test_command="\"$got\" == \"$expected\""
|
test_command="\"$got\" == \"$expected\""
|
||||||
test "$got" = "$expected"
|
test "$got" = "$expected"
|
||||||
result $? "$test_name"
|
result $? "$test_name"
|
||||||
@@ -132,7 +132,7 @@ is() {
|
|||||||
|
|
||||||
cmd_ok() {
|
cmd_ok() {
|
||||||
local test_command=$1
|
local test_command=$1
|
||||||
local test_name=$2
|
local test_name=${2:-""}
|
||||||
eval $test_command
|
eval $test_command
|
||||||
result $? "$test_name"
|
result $? "$test_name"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user