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
diff options
context:
space:
mode:
authorJason Karns <jason@karns.name>2019-01-29 21:42:21 +0300
committerJason Karns <jason@karns.name>2019-01-29 21:42:22 +0300
commit55547e5713ed9a76881ac247184cdaf85ad5e93c (patch)
tree0884778ec55365a1fe21d50b25075b235a4e441f
parent60ca563b1af96253cc850141581fc8f967cf34a4 (diff)
Shellcheck lint fixes
- Adds checks to verify bats-provided vars are set (errors otherwise) - Disables dynamic source lint rule - Removes no-op check of `$?=0` - Fixes declare+assign same line lint warning
-rw-r--r--load.bash1
-rw-r--r--src/assert_failure.bash3
-rw-r--r--src/assert_line.bash1
-rw-r--r--src/assert_output.bash1
-rw-r--r--src/assert_success.bash3
-rw-r--r--src/refute_line.bash3
-rw-r--r--src/refute_output.bash3
-rw-r--r--test/test_helper.bash3
8 files changed, 15 insertions, 3 deletions
diff --git a/load.bash b/load.bash
index 14695c3..38bffe0 100644
--- a/load.bash
+++ b/load.bash
@@ -18,6 +18,7 @@
# All output is formatted for readability using the functions of
# `output.bash' and sent to the standard error.
+# shellcheck disable=1090
source "$(dirname "${BASH_SOURCE[0]}")/src/assert.bash"
source "$(dirname "${BASH_SOURCE[0]}")/src/refute.bash"
source "$(dirname "${BASH_SOURCE[0]}")/src/assert_equal.bash"
diff --git a/src/assert_failure.bash b/src/assert_failure.bash
index 1a797f4..9d5cf57 100644
--- a/src/assert_failure.bash
+++ b/src/assert_failure.bash
@@ -16,6 +16,9 @@
# Outputs:
# STDERR - details, on failure
assert_failure() {
+ : "${output?}"
+ : "${status?}"
+
(( $# > 0 )) && local -r expected="$1"
if (( status == 0 )); then
batslib_print_kv_single_or_multi 6 'output' "$output" \
diff --git a/src/assert_line.bash b/src/assert_line.bash
index 2ab427a..011f08e 100644
--- a/src/assert_line.bash
+++ b/src/assert_line.bash
@@ -47,6 +47,7 @@ assert_line() {
local -i is_match_line=0
local -i is_mode_partial=0
local -i is_mode_regexp=0
+ : "${lines?}"
# Handle options.
while (( $# > 0 )); do
diff --git a/src/assert_output.bash b/src/assert_output.bash
index ec10547..bead6c5 100644
--- a/src/assert_output.bash
+++ b/src/assert_output.bash
@@ -36,6 +36,7 @@ assert_output() {
local -i is_mode_regexp=0
local -i is_mode_nonempty=0
local -i use_stdin=0
+ : "${output?}"
# Handle options.
if (( $# == 0 )); then
diff --git a/src/assert_success.bash b/src/assert_success.bash
index e7d285b..0f36272 100644
--- a/src/assert_success.bash
+++ b/src/assert_success.bash
@@ -12,6 +12,9 @@
# Outputs:
# STDERR - details, on failure
assert_success() {
+ : "${output?}"
+ : "${status?}"
+
if (( status != 0 )); then
{ local -ir width=6
batslib_print_kv_single "$width" 'status' "$status"
diff --git a/src/refute_line.bash b/src/refute_line.bash
index 332c384..8413b34 100644
--- a/src/refute_line.bash
+++ b/src/refute_line.bash
@@ -51,6 +51,7 @@ refute_line() {
local -i is_match_line=0
local -i is_mode_partial=0
local -i is_mode_regexp=0
+ : "${lines?}"
# Handle options.
while (( $# > 0 )); do
@@ -94,7 +95,7 @@ refute_line() {
if (( is_match_line )); then
# Specific line.
if (( is_mode_regexp )); then
- if [[ ${lines[$idx]} =~ $unexpected ]] || (( $? == 0 )); then
+ if [[ ${lines[$idx]} =~ $unexpected ]]; then
batslib_print_kv_single 6 \
'index' "$idx" \
'regexp' "$unexpected" \
diff --git a/src/refute_output.bash b/src/refute_output.bash
index 93298f6..82b9677 100644
--- a/src/refute_output.bash
+++ b/src/refute_output.bash
@@ -38,6 +38,7 @@ refute_output() {
local -i is_mode_regexp=0
local -i is_mode_empty=0
local -i use_stdin=0
+ : "${output?}"
# Handle options.
if (( $# == 0 )); then
@@ -85,7 +86,7 @@ refute_output() {
| fail
fi
elif (( is_mode_regexp )); then
- if [[ $output =~ $unexpected ]] || (( $? == 0 )); then
+ if [[ $output =~ $unexpected ]]; then
batslib_print_kv_single_or_multi 6 \
'regexp' "$unexpected" \
'output' "$output" \
diff --git a/test/test_helper.bash b/test/test_helper.bash
index 4ca71e8..77120f1 100644
--- a/test/test_helper.bash
+++ b/test/test_helper.bash
@@ -18,7 +18,8 @@ assert_test_pass() {
assert_test_fail() {
local err_msg="${1-$(cat -)}"
- local num_lines="$(printf '%s' "$err_msg" | wc -l)"
+ local num_lines
+ num_lines="$(printf '%s' "$err_msg" | wc -l)"
test "$status" -eq 1
test "${#lines[@]}" -eq "$num_lines"