Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bats-core/bats-assert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Karns <jason@karns.name>2018-11-27 19:07:59 +0300
committerJason Karns <jason@karns.name>2018-11-27 19:09:38 +0300
commit6d21994a341d7d69dca1158212baf881f73a44ba (patch)
tree439007ddb7ffdaa0f2c2158244682ad9eb396ca4 /test
parentd9a59d1e96da2573710cfa4d62377a5b1a1e792f (diff)
Use quiet_exit helper in other tests
Diffstat (limited to 'test')
-rwxr-xr-xtest/50-assert-11-assert.bats3
-rwxr-xr-xtest/50-assert-12-assert_equal.bats3
-rwxr-xr-xtest/50-assert-13-assert_success.bats3
-rwxr-xr-xtest/50-assert-14-assert_failure.bats6
-rwxr-xr-xtest/50-assert-16-refute_output.bats26
-rwxr-xr-xtest/50-assert-17-assert_line.bats36
-rwxr-xr-xtest/50-assert-18-refute_line.bats36
-rwxr-xr-xtest/50-assert-19-refute.bats3
8 files changed, 40 insertions, 76 deletions
diff --git a/test/50-assert-11-assert.bats b/test/50-assert-11-assert.bats
index 6b7606b..cea76c5 100755
--- a/test/50-assert-11-assert.bats
+++ b/test/50-assert-11-assert.bats
@@ -4,8 +4,7 @@ load test_helper
@test 'assert() <expression>: returns 0 if <expression> evaluates to TRUE' {
run assert true
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'assert() <expression>: returns 1 and displays <expression> if it evaluates to FALSE' {
diff --git a/test/50-assert-12-assert_equal.bats b/test/50-assert-12-assert_equal.bats
index b21725a..0c865f0 100755
--- a/test/50-assert-12-assert_equal.bats
+++ b/test/50-assert-12-assert_equal.bats
@@ -4,8 +4,7 @@ load test_helper
@test 'assert_equal() <actual> <expected>: returns 0 if <actual> equals <expected>' {
run assert_equal 'a' 'a'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'assert_equal() <actual> <expected>: returns 1 and displays details if <actual> does not equal <expected>' {
diff --git a/test/50-assert-13-assert_success.bats b/test/50-assert-13-assert_success.bats
index 6e80caa..bf6c053 100755
--- a/test/50-assert-13-assert_success.bats
+++ b/test/50-assert-13-assert_success.bats
@@ -5,8 +5,7 @@ load test_helper
@test "assert_success(): returns 0 if \`\$status' is 0" {
run true
run assert_success
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_success(): returns 1 and displays details if \`\$status' is not 0" {
diff --git a/test/50-assert-14-assert_failure.bats b/test/50-assert-14-assert_failure.bats
index fee9685..14f4d1e 100755
--- a/test/50-assert-14-assert_failure.bats
+++ b/test/50-assert-14-assert_failure.bats
@@ -5,8 +5,7 @@ load test_helper
@test "assert_failure(): returns 0 if \`\$status' is not 0" {
run false
run assert_failure
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_failure(): returns 1 and displays details if \`\$status' is 0" {
@@ -36,8 +35,7 @@ load test_helper
@test "assert_failure() <status>: returns 0 if \`\$status' equals <status>" {
run bash -c 'exit 1'
run assert_failure 1
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_failure() <status>: returns 1 and displays details if \`\$status' does not equal <status>" {
diff --git a/test/50-assert-16-refute_output.bats b/test/50-assert-16-refute_output.bats
index 05f2995..9f145ee 100755
--- a/test/50-assert-16-refute_output.bats
+++ b/test/50-assert-16-refute_output.bats
@@ -11,8 +11,7 @@ load test_helper
@test "refute_output() <unexpected>: returns 0 if <unexpected> does not equal \`\$output'" {
run echo 'b'
run refute_output 'a'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_output() <unexpected>: returns 1 and displays details if <unexpected> equals \`\$output'" {
@@ -30,8 +29,8 @@ load test_helper
run refute_output - <<INPUT
b
INPUT
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+
+ assert_quiet_exit
}
@test 'refute_output() --stdin : reads <unexpected> from STDIN' {
@@ -39,8 +38,8 @@ INPUT
run refute_output --stdin <<INPUT
b
INPUT
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+
+ assert_quiet_exit
}
# Output formatting
@@ -72,8 +71,7 @@ INPUT
test_p_partial () {
run echo 'abc'
run refute_output "$1" 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute_output() -p <partial>: enables partial matching' {
@@ -88,8 +86,7 @@ test_p_partial () {
@test "refute_output() --partial <partial>: returns 0 if <partial> is not a substring in \`\$output'" {
run printf 'a\nb\nc'
run refute_output --partial 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_output() --partial <partial>: returns 1 and displays details if <partial> is a substring in \`\$output'" {
@@ -127,8 +124,7 @@ test_p_partial () {
test_r_regexp () {
run echo 'abc'
run refute_output "$1" '^d'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute_output() -e <regexp>: enables regular expression matching' {
@@ -143,8 +139,7 @@ test_r_regexp () {
@test "refute_output() --regexp <regexp>: returns 0 if <regexp> does not match \`\$output'" {
run printf 'a\nb\nc'
run refute_output --regexp '.*d.*'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_output() --regexp <regexp>: returns 1 and displays details if <regexp> matches \`\$output'" {
@@ -200,6 +195,5 @@ test_r_regexp () {
@test "refute_output(): \`--' stops parsing options" {
run echo '--'
run refute_output -- '-p'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
diff --git a/test/50-assert-17-assert_line.bats b/test/50-assert-17-assert_line.bats
index bee3850..a57cb7b 100755
--- a/test/50-assert-17-assert_line.bats
+++ b/test/50-assert-17-assert_line.bats
@@ -15,8 +15,7 @@ load test_helper
@test "assert_line() <expected>: returns 0 if <expected> is a line in \`\${lines[@]}'" {
run printf 'a\nb\nc'
run assert_line 'b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_line() <expected>: returns 1 and displays details if <expected> is not a line in \`\${lines[@]}'" {
@@ -60,8 +59,7 @@ load test_helper
test_p_partial () {
run printf 'a\n_b_\nc'
run assert_line "$1" 'b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'assert_line() -p <partial>: enables partial matching' {
@@ -76,8 +74,7 @@ test_p_partial () {
@test "assert_line() --partial <partial>: returns 0 if <partial> is a substring in any line in \`\${lines[@]}'" {
run printf 'a\n_b_\nc'
run assert_line --partial 'b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_line() --partial <partial>: returns 1 and displays details if <partial> is not a substring in any lines in \`\${lines[@]}'" {
@@ -114,8 +111,7 @@ test_p_partial () {
test_r_regexp () {
run printf 'a\n_b_\nc'
run assert_line "$1" '^.b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'assert_line() -e <regexp>: enables regular expression matching' {
@@ -130,8 +126,7 @@ test_r_regexp () {
@test "assert_line() --regexp <regexp>: returns 0 if <regexp> matches any line in \`\${lines[@]}'" {
run printf 'a\n_b_\nc'
run assert_line --regexp '^.b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_line() --regexp <regexp>: returns 1 and displays details if <regexp> does not match any lines in \`\${lines[@]}'" {
@@ -168,8 +163,7 @@ test_r_regexp () {
test_n_index () {
run printf 'a\nb\nc'
run assert_line "$1" 1 'b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'assert_line() -n <idx> <expected>: matches against the <idx>-th line only' {
@@ -198,8 +192,7 @@ test_n_index () {
@test "assert_line() --index <idx> <expected>: returns 0 if <expected> equals \`\${lines[<idx>]}'" {
run printf 'a\nb\nc'
run assert_line --index 1 'b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_line() --index <idx> <expected>: returns 1 and displays details if <expected> does not equal \`\${lines[<idx>]}'" {
@@ -230,8 +223,7 @@ test_n_index () {
test_index_p_partial () {
run printf 'a\n_b_\nc'
run assert_line --index 1 "$1" 'b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'assert_line() --index <idx> -p <partial>: enables partial matching' {
@@ -246,8 +238,7 @@ test_index_p_partial () {
@test "assert_line() --index <idx> --partial <partial>: returns 0 if <partial> is a substring in \`\${lines[<idx>]}'" {
run printf 'a\n_b_\nc'
run assert_line --index 1 --partial 'b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_line() --index <idx> --partial <partial>: returns 1 and displays details if <partial> is not a substring in \`\${lines[<idx>]}'" {
@@ -271,8 +262,7 @@ test_index_p_partial () {
test_index_r_regexp () {
run printf 'a\n_b_\nc'
run assert_line --index 1 "$1" '^.b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'assert_line() --index <idx> -e <regexp>: enables regular expression matching' {
@@ -287,8 +277,7 @@ test_index_r_regexp () {
@test "assert_line() --index <idx> --regexp <regexp>: returns 0 if <regexp> matches \`\${lines[<idx>]}'" {
run printf 'a\n_b_\nc'
run assert_line --index 1 --regexp '^.b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "assert_line() --index <idx> --regexp <regexp>: returns 1 and displays details if <regexp> does not match \`\${lines[<idx>]}'" {
@@ -329,6 +318,5 @@ test_index_r_regexp () {
@test "assert_line(): \`--' stops parsing options" {
run printf 'a\n-p\nc'
run assert_line -- '-p'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
diff --git a/test/50-assert-18-refute_line.bats b/test/50-assert-18-refute_line.bats
index 9cc8185..781db33 100755
--- a/test/50-assert-18-refute_line.bats
+++ b/test/50-assert-18-refute_line.bats
@@ -15,8 +15,7 @@ load test_helper
@test "refute_line() <unexpected>: returns 0 if <unexpected> is not a line in \`\${lines[@]}'" {
run printf 'a\nb\nc'
run refute_line 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_line() <unexpected>: returns 1 and displays details if <unexpected> is not a line in \`\${lines[@]}'" {
@@ -63,8 +62,7 @@ load test_helper
test_p_partial () {
run printf 'a\nb\nc'
run refute_line "$1" 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute_line() -p <partial>: enables partial matching' {
@@ -79,8 +77,7 @@ test_p_partial () {
@test "refute_line() --partial <partial>: returns 0 if <partial> is not a substring in any line in \`\${lines[@]}'" {
run printf 'a\nb\nc'
run refute_line --partial 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_line() --partial <partial>: returns 1 and displays details if <partial> is a substring in any line in \`\${lines[@]}'" {
@@ -120,8 +117,7 @@ test_p_partial () {
test_r_regexp () {
run printf 'a\nb\nc'
run refute_line "$1" '^.d'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute_line() -e <regexp>: enables regular expression matching' {
@@ -136,8 +132,7 @@ test_r_regexp () {
@test "refute_line() --regexp <regexp>: returns 0 if <regexp> does not match any line in \`\${lines[@]}'" {
run printf 'a\nb\nc'
run refute_line --regexp '.*d.*'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_line() --regexp <regexp>: returns 1 and displays details if <regexp> matches any lines in \`\${lines[@]}'" {
@@ -177,8 +172,7 @@ test_r_regexp () {
test_n_index () {
run printf 'a\nb\nc'
run refute_line "$1" 1 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute_line() -n <idx> <expected>: matches against the <idx>-th line only' {
@@ -207,8 +201,7 @@ test_n_index () {
@test "refute_line() --index <idx> <unexpected>: returns 0 if <unexpected> does not equal \`\${lines[<idx>]}'" {
run printf 'a\nb\nc'
run refute_line --index 1 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_line() --index <idx> <unexpected>: returns 1 and displays details if <unexpected> equals \`\${lines[<idx>]}'" {
@@ -238,8 +231,7 @@ test_n_index () {
test_index_p_partial () {
run printf 'a\nb\nc'
run refute_line --index 1 "$1" 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute_line() --index <idx> -p <partial>: enables partial matching' {
@@ -254,8 +246,7 @@ test_index_p_partial () {
@test "refute_line() --index <idx> --partial <partial>: returns 0 if <partial> is not a substring in \`\${lines[<idx>]}'" {
run printf 'a\nabc\nc'
run refute_line --index 1 --partial 'd'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_line() --index <idx> --partial <partial>: returns 1 and displays details if <partial> is a substring in \`\${lines[<idx>]}'" {
@@ -279,8 +270,7 @@ test_index_p_partial () {
test_index_r_regexp () {
run printf 'a\nb\nc'
run refute_line --index 1 "$1" '^.b'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute_line() --index <idx> -e <regexp>: enables regular expression matching' {
@@ -295,8 +285,7 @@ test_index_r_regexp () {
@test "refute_line() --index <idx> --regexp <regexp>: returns 0 if <regexp> does not match \`\${lines[<idx>]}'" {
run printf 'a\nabc\nc'
run refute_line --index 1 --regexp '.*d.*'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test "refute_line() --index <idx> --regexp <regexp>: returns 1 and displays details if <regexp> matches \`\${lines[<idx>]}'" {
@@ -337,6 +326,5 @@ test_index_r_regexp () {
@test "refute_line(): \`--' stops parsing options" {
run printf 'a\n--\nc'
run refute_line -- '-p'
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
diff --git a/test/50-assert-19-refute.bats b/test/50-assert-19-refute.bats
index 191dc73..c58d888 100755
--- a/test/50-assert-19-refute.bats
+++ b/test/50-assert-19-refute.bats
@@ -4,8 +4,7 @@ load test_helper
@test 'refute() <expression>: returns 0 if <expression> evaluates to FALSE' {
run refute false
- [ "$status" -eq 0 ]
- [ "${#lines[@]}" -eq 0 ]
+ assert_quiet_exit
}
@test 'refute() <expression>: returns 1 and displays <expression> if it evaluates to TRUE' {