@bats-hardened/bats 1.14.1-alpha02

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,425 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # shellcheck source=lib/bats-core/common.bash
4
+ source "$BATS_ROOT/$BATS_LIBDIR/bats-core/common.bash"
5
+
6
+ # set limit such that traces are only captured for calls at the same depth as this function in the calltree
7
+ bats_set_stacktrace_limit() {
8
+ BATS_STACK_TRACE_LIMIT=$(( ${#FUNCNAME[@]} - 1 )) # adjust by -1 to account for call to this functions
9
+ }
10
+
11
+ bats_capture_stack_trace() {
12
+ local test_file
13
+ local funcname
14
+ local i
15
+
16
+ BATS_DEBUG_LAST_STACK_TRACE=()
17
+ local limit=$(( ${#FUNCNAME[@]} - ${BATS_STACK_TRACE_LIMIT-0} ))
18
+ # TODO: why is the line number off by one in @test "--trace recurses into functions but not into run"
19
+ for ((i = 2; i < limit ; ++i)); do
20
+ # Use BATS_TEST_SOURCE if necessary to work around Bash < 4.4 bug whereby
21
+ # calling an exported function erases the test file's BASH_SOURCE entry.
22
+ test_file="${BASH_SOURCE[$i]:-$BATS_TEST_SOURCE}"
23
+ funcname="${FUNCNAME[$i]}"
24
+ BATS_DEBUG_LAST_STACK_TRACE+=("${BASH_LINENO[$((i - 1))]} $funcname $test_file")
25
+ done
26
+ }
27
+
28
+ bats_get_failure_stack_trace() {
29
+ local stack_trace_var
30
+ # See bats_debug_trap for details.
31
+ if [[ -n "${BATS_DEBUG_LAST_STACK_TRACE_IS_VALID:-}" ]]; then
32
+ stack_trace_var=BATS_DEBUG_LAST_STACK_TRACE
33
+ else
34
+ stack_trace_var=BATS_DEBUG_LASTLAST_STACK_TRACE
35
+ fi
36
+ # shellcheck disable=SC2016
37
+ eval "$(printf \
38
+ '%s=(${%s[@]+"${%s[@]}"})' \
39
+ "${1}" \
40
+ "${stack_trace_var}" \
41
+ "${stack_trace_var}")"
42
+ }
43
+
44
+ bats_print_stack_trace() {
45
+ local frame
46
+ local index=1
47
+ local count="${#@}"
48
+ local filename
49
+ local lineno
50
+
51
+ for frame in "$@"; do
52
+ bats_frame_filename "$frame" 'filename'
53
+ bats_trim_filename "$filename" 'filename'
54
+ bats_frame_lineno "$frame" 'lineno'
55
+
56
+ printf '%s' "${BATS_STACK_TRACE_PREFIX-# }"
57
+ if [[ $index -eq 1 ]]; then
58
+ printf '('
59
+ else
60
+ printf ' '
61
+ fi
62
+
63
+ local fn
64
+ bats_frame_function "$frame" 'fn'
65
+ if [[ "$fn" != "${BATS_TEST_NAME-}" ]] &&
66
+ # don't print "from function `source'"",
67
+ # when failing in free code during `source $test_file` from bats-exec-file
68
+ ! [[ "$fn" == 'source' && $index -eq $count ]]; then
69
+ local quoted_fn
70
+ bats_quote_code quoted_fn "$fn"
71
+ printf "from function %s " "$quoted_fn"
72
+ fi
73
+
74
+ local reference
75
+ bats_format_file_line_reference reference "$filename" "$lineno"
76
+ if [[ $index -eq $count ]]; then
77
+ printf 'in test file %s)\n' "$reference"
78
+ else
79
+ printf 'in file %s,\n' "$reference"
80
+ fi
81
+
82
+ ((++index))
83
+ done
84
+ }
85
+
86
+ bats_print_failed_command() {
87
+ local stack_trace=("${@}")
88
+ if [[ ${#stack_trace[@]} -eq 0 ]]; then
89
+ return 0
90
+ fi
91
+ local frame="${stack_trace[${#stack_trace[@]} - 1]}"
92
+ local filename
93
+ local lineno
94
+ local failed_line
95
+ local failed_command
96
+
97
+ bats_frame_filename "$frame" 'filename'
98
+ bats_frame_lineno "$frame" 'lineno'
99
+ bats_extract_line "$filename" "$lineno" 'failed_line'
100
+ bats_strip_string "$failed_line" 'failed_command'
101
+ local quoted_failed_command
102
+ bats_quote_code quoted_failed_command "$failed_command"
103
+ printf '# %s ' "${quoted_failed_command}"
104
+
105
+ if [[ "${BATS_TIMED_OUT-NOTSET}" != NOTSET ]]; then
106
+ # the other values can be safely overwritten here,
107
+ # as the timeout is the primary reason for failure
108
+ BATS_ERROR_SUFFIX=" due to timeout"
109
+ fi
110
+
111
+ if [[ "$BATS_ERROR_STATUS" -eq 1 ]]; then
112
+ printf 'failed%s\n' "$BATS_ERROR_SUFFIX"
113
+ else
114
+ printf 'failed with status %d%s\n' "$BATS_ERROR_STATUS" "$BATS_ERROR_SUFFIX"
115
+ fi
116
+ }
117
+
118
+ bats_frame_lineno() {
119
+ printf -v "$2" '%s' "${1%% *}"
120
+ }
121
+
122
+ bats_frame_function() {
123
+ local __bff_function="${1#* }"
124
+ printf -v "$2" '%s' "${__bff_function%% *}"
125
+ }
126
+
127
+ bats_frame_filename() {
128
+ local __bff_filename="${1#* }"
129
+ __bff_filename="${__bff_filename#* }"
130
+
131
+ if [[ "$__bff_filename" == "${BATS_TEST_SOURCE-}" ]]; then
132
+ __bff_filename="$BATS_TEST_FILENAME"
133
+ fi
134
+ printf -v "$2" '%s' "$__bff_filename"
135
+ }
136
+
137
+ bats_extract_line() {
138
+ local __bats_extract_line_line
139
+ local __bats_extract_line_index=0
140
+
141
+ while IFS= read -r __bats_extract_line_line; do
142
+ if [[ "$((++__bats_extract_line_index))" -eq "$2" ]]; then
143
+ printf -v "$3" '%s' "${__bats_extract_line_line%$'\r'}"
144
+ break
145
+ fi
146
+ done <"$1"
147
+ }
148
+
149
+ bats_strip_string() {
150
+ [[ "$1" =~ ^[[:space:]]*(.*)[[:space:]]*$ ]]
151
+ printf -v "$2" '%s' "${BASH_REMATCH[1]}"
152
+ }
153
+
154
+ bats_trim_filename() {
155
+ printf -v "$2" '%s' "${1#"$BATS_CWD"/}"
156
+ }
157
+
158
+ # normalize a windows path from e.g. C:/directory to /c/directory
159
+ # The path must point to an existing/accessible directory, not a file!
160
+ bats_normalize_windows_dir_path() { # <output-var> <path>
161
+ local output_var="$1" path="$2"
162
+ if [[ "$output_var" != NORMALIZED_INPUT ]]; then
163
+ local NORMALIZED_INPUT
164
+ fi
165
+ if [[ $path == ?:* ]]; then
166
+ NORMALIZED_INPUT="$(
167
+ cd "$path" || exit 1
168
+ pwd
169
+ )"
170
+ else
171
+ NORMALIZED_INPUT="$path"
172
+ fi
173
+ printf -v "$output_var" "%s" "$NORMALIZED_INPUT"
174
+ }
175
+
176
+ bats_emit_trace_context() {
177
+ local padding='$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
178
+ local reference
179
+ bats_format_file_line_reference reference "${file##*/}" "$line"
180
+ printf '%s [%s]\n' "${padding::${#BASH_LINENO[@]}-limit-3}" "$reference" >&4
181
+ }
182
+
183
+ bats_emit_trace_command() {
184
+ local padding='$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
185
+ printf '%s %s\n' "${padding::${#BASH_LINENO[@]}-limit-3}" "$BASH_COMMAND" >&4
186
+
187
+ # keep track of printed commands
188
+ BATS_LAST_BASH_COMMAND="$BASH_COMMAND"
189
+ BATS_LAST_BASH_LINENO="$line"
190
+ }
191
+
192
+ BATS_EMIT_TRACE_LAST_STACK_DIFF=0
193
+
194
+ bats_emit_trace() {
195
+ if [[ ${BATS_TRACE_LEVEL:-0} -gt 0 ]]; then
196
+ local line=${BASH_LINENO[1]} limit=${BATS_STACK_TRACE_LIMIT-0}
197
+ # shellcheck disable=SC2016
198
+ if (( ${#FUNCNAME[@]} > limit + 2 )) # only emit below BATS_STRACK_TRACE_LIMIT (adjust by 2 for trap+this function call)
199
+ # avoid printing the same line twice on errexit
200
+ [[ $BASH_COMMAND != "$BATS_LAST_BASH_COMMAND" || $line != "$BATS_LAST_BASH_LINENO" ]]; then
201
+ local file="${BASH_SOURCE[2]}" # index 2: skip over bats_emit_trace and bats_debug_trap
202
+ if [[ $file == "${BATS_TEST_SOURCE:-}" ]]; then
203
+ file="$BATS_TEST_FILENAME"
204
+ fi
205
+ # stack size difference since last call of this function
206
+ # <0: means new function call
207
+ # >0: means return
208
+ # =0: in same function as before (assuming we did not skip return/call)
209
+ local stack_diff=$(( BATS_LAST_STACK_DEPTH - ${#BASH_LINENO[@]} ))
210
+ # show context immediately when returning or on second command in new function
211
+ # as the first "command" is the function itself
212
+ if (( stack_diff > 0 )) || (( BATS_EMIT_TRACE_LAST_STACK_DIFF < 0 )); then
213
+ bats_emit_trace_context
214
+ fi
215
+ # only print command when moving up or staying in same function
216
+ # again, avoids printing the first command (the function itself) in new function
217
+ if (( stack_diff >= 0 )); then
218
+ bats_emit_trace_command
219
+ fi
220
+
221
+ BATS_EMIT_TRACE_LAST_STACK_DIFF=$stack_diff
222
+ fi
223
+ # always update to detect stack depth changes regardless of printing
224
+ BATS_LAST_STACK_DEPTH="${#BASH_LINENO[@]}"
225
+ fi
226
+ }
227
+
228
+ # bats_debug_trap tracks the last line of code executed within a test. This is
229
+ # necessary because $BASH_LINENO is often incorrect inside of ERR and EXIT
230
+ # trap handlers.
231
+ #
232
+ # Below are tables describing different command failure scenarios and the
233
+ # reliability of $BASH_LINENO within different the executed DEBUG, ERR, and EXIT
234
+ # trap handlers. Naturally, the behaviors change between versions of Bash.
235
+ #
236
+ # Table rows should be read left to right. For example, on bash version
237
+ # 4.0.44(2)-release, if a test executes `false` (or any other failing external
238
+ # command), bash will do the following in order:
239
+ # 1. Call the DEBUG trap handler (bats_debug_trap) with $BASH_LINENO referring
240
+ # to the source line containing the `false` command, then
241
+ # 2. Call the DEBUG trap handler again, but with an incorrect $BASH_LINENO, then
242
+ # 3. Call the ERR trap handler, but with a (possibly-different) incorrect
243
+ # $BASH_LINENO, then
244
+ # 4. Call the DEBUG trap handler again, but with $BASH_LINENO set to 1, then
245
+ # 5. Call the EXIT trap handler, with $BASH_LINENO set to 1.
246
+ #
247
+ # bash version 4.4.20(1)-release
248
+ # command | first DEBUG | second DEBUG | ERR | third DEBUG | EXIT
249
+ # -------------+-------------+--------------+---------+-------------+--------
250
+ # false | OK | OK | OK | BAD[1] | BAD[1]
251
+ # [[ 1 = 2 ]] | OK | BAD[2] | BAD[2] | BAD[1] | BAD[1]
252
+ # (( 1 = 2 )) | OK | BAD[2] | BAD[2] | BAD[1] | BAD[1]
253
+ # ! true | OK | --- | BAD[4] | --- | BAD[1]
254
+ # $var_dne | OK | --- | --- | BAD[1] | BAD[1]
255
+ # source /dne | OK | --- | --- | BAD[1] | BAD[1]
256
+ #
257
+ # bash version 4.0.44(2)-release
258
+ # command | first DEBUG | second DEBUG | ERR | third DEBUG | EXIT
259
+ # -------------+-------------+--------------+---------+-------------+--------
260
+ # false | OK | BAD[3] | BAD[3] | BAD[1] | BAD[1]
261
+ # [[ 1 = 2 ]] | OK | --- | BAD[3] | --- | BAD[1]
262
+ # (( 1 = 2 )) | OK | --- | BAD[3] | --- | BAD[1]
263
+ # ! true | OK | --- | BAD[3] | --- | BAD[1]
264
+ # $var_dne | OK | --- | --- | BAD[1] | BAD[1]
265
+ # source /dne | OK | --- | --- | BAD[1] | BAD[1]
266
+ #
267
+ # [1] The reported line number is always 1.
268
+ # [2] The reported source location is that of the beginning of the function
269
+ # calling the command.
270
+ # [3] The reported line is that of the last command executed in the DEBUG trap
271
+ # handler.
272
+ # [4] The reported source location is that of the call to the function calling
273
+ # the command.
274
+ bats_debug_trap() {
275
+ # on windows we sometimes get a mix of paths (when install via nmp install -g)
276
+ # which have C:/... or /c/... comparing them is going to be problematic.
277
+ # We need to normalize them to a common format!
278
+ local NORMALIZED_INPUT
279
+ bats_normalize_windows_dir_path NORMALIZED_INPUT "${1%/*}"
280
+ local path
281
+ for path in "${BATS_DEBUG_EXCLUDE_PATHS[@]}"; do
282
+ if [[ "$NORMALIZED_INPUT" == "$path"* ]]; then
283
+ return # skip this call
284
+ fi
285
+ done
286
+
287
+ # don't update the trace within library functions or we get backtraces from inside traps
288
+ # also don't record new stack traces while handling interruptions, to avoid overriding the interrupted command
289
+ if [[ "${BATS_INTERRUPTED-NOTSET}" == NOTSET &&
290
+ "${BATS_TIMED_OUT-NOTSET}" == NOTSET ]]; then
291
+ BATS_DEBUG_LASTLAST_STACK_TRACE=(
292
+ ${BATS_DEBUG_LAST_STACK_TRACE[@]+"${BATS_DEBUG_LAST_STACK_TRACE[@]}"}
293
+ )
294
+
295
+ BATS_DEBUG_LAST_LINENO=(${BASH_LINENO[@]+"${BASH_LINENO[@]}"})
296
+ BATS_DEBUG_LAST_SOURCE=(${BASH_SOURCE[@]+"${BASH_SOURCE[@]}"})
297
+ bats_capture_stack_trace
298
+ bats_emit_trace
299
+ fi
300
+ }
301
+
302
+ # For some versions of Bash, the `ERR` trap may not always fire for every
303
+ # command failure, but the `EXIT` trap will. Also, some command failures may not
304
+ # set `$?` properly. See #72 and #81 for details.
305
+ #
306
+ # For this reason, we call `bats_check_status_from_trap` at the very beginning
307
+ # of `bats_teardown_trap` and check the value of `$BATS_TEST_COMPLETED` before
308
+ # taking other actions. We also adjust the exit status value if needed.
309
+ #
310
+ # See `bats_exit_trap` for an additional EXIT error handling case when `$?`
311
+ # isn't set properly during `teardown()` errors.
312
+ bats_check_status_from_trap() {
313
+ local status="$?"
314
+ if [[ -z "${BATS_TEST_COMPLETED:-}" ]]; then
315
+ BATS_ERROR_STATUS="${BATS_ERROR_STATUS:-$status}"
316
+ if [[ "$BATS_ERROR_STATUS" -eq 0 ]]; then
317
+ BATS_ERROR_STATUS=1
318
+ fi
319
+ trap - DEBUG
320
+ fi
321
+ }
322
+
323
+ bats_add_debug_exclude_path() { # <path>
324
+ if [[ -z "$1" ]]; then # don't exclude everything
325
+ printf "bats_add_debug_exclude_path: Exclude path must not be empty!\n" >&2
326
+ return 1
327
+ fi
328
+ if [[ "$OSTYPE" == cygwin || "$OSTYPE" == msys ]]; then
329
+ local normalized_dir
330
+ bats_normalize_windows_dir_path normalized_dir "$1"
331
+ BATS_DEBUG_EXCLUDE_PATHS+=("$normalized_dir")
332
+ else
333
+ BATS_DEBUG_EXCLUDE_PATHS+=("$1")
334
+ fi
335
+ }
336
+
337
+ bats_setup_tracing() {
338
+ # Variables for capturing accurate stack traces. See bats_debug_trap for
339
+ # details.
340
+ #
341
+ # BATS_DEBUG_LAST_LINENO, BATS_DEBUG_LAST_SOURCE, and
342
+ # BATS_DEBUG_LAST_STACK_TRACE hold data from the most recent call to
343
+ # bats_debug_trap.
344
+ #
345
+ # BATS_DEBUG_LASTLAST_STACK_TRACE holds data from two bats_debug_trap calls
346
+ # ago.
347
+ #
348
+ # BATS_DEBUG_LAST_STACK_TRACE_IS_VALID indicates that
349
+ # BATS_DEBUG_LAST_STACK_TRACE contains the stack trace of the test's error. If
350
+ # unset, BATS_DEBUG_LAST_STACK_TRACE is unreliable and
351
+ # BATS_DEBUG_LASTLAST_STACK_TRACE should be used instead.
352
+ BATS_DEBUG_LASTLAST_STACK_TRACE=()
353
+ BATS_DEBUG_LAST_LINENO=()
354
+ BATS_DEBUG_LAST_SOURCE=()
355
+ BATS_DEBUG_LAST_STACK_TRACE=()
356
+ BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=
357
+ BATS_ERROR_SUFFIX=
358
+ BATS_DEBUG_EXCLUDE_PATHS=()
359
+ # exclude some paths by default
360
+ bats_add_debug_exclude_path "$BATS_ROOT/$BATS_LIBDIR/"
361
+ bats_add_debug_exclude_path "$BATS_ROOT/libexec/"
362
+
363
+ exec 4<&1 # used for tracing
364
+ if [[ "${BATS_TRACE_LEVEL:-0}" -gt 0 ]]; then
365
+ # avoid undefined variable errors
366
+ BATS_LAST_BASH_COMMAND=
367
+ BATS_LAST_BASH_LINENO=
368
+ BATS_LAST_STACK_DEPTH=
369
+ # try to exclude helper libraries if found, this is only relevant for tracing
370
+ while read -r path; do
371
+ bats_add_debug_exclude_path "$path"
372
+ done < <(find "$PWD" -type d -name bats-assert -o -name bats-support)
373
+ fi
374
+
375
+ local exclude_paths path
376
+ # exclude user defined libraries
377
+ IFS=':' read -r exclude_paths <<<"${BATS_DEBUG_EXCLUDE_PATHS:-}"
378
+ for path in "${exclude_paths[@]}"; do
379
+ if [[ -n "$path" ]]; then
380
+ bats_add_debug_exclude_path "$path"
381
+ fi
382
+ done
383
+
384
+ # turn on traps after setting excludes to avoid tracing the exclude setup
385
+ trap 'bats_debug_trap "$BASH_SOURCE" "$_"' DEBUG
386
+ trap 'bats_error_trap "$_"' ERR
387
+ }
388
+
389
+ # predefine to avoid problems when the user does not declare one
390
+ bats::on_failure() {
391
+ :
392
+ }
393
+
394
+ bats_error_trap() {
395
+ bats_check_status_from_trap
396
+ bats::on_failure "$BATS_ERROR_STATUS"
397
+
398
+ # If necessary, undo the most recent stack trace captured by bats_debug_trap.
399
+ # See bats_debug_trap for details.
400
+ if [[ "${BASH_LINENO[*]}" = "${BATS_DEBUG_LAST_LINENO[*]:-}" &&
401
+ "${BASH_SOURCE[*]}" = "${BATS_DEBUG_LAST_SOURCE[*]:-}" &&
402
+ -z "$BATS_DEBUG_LAST_STACK_TRACE_IS_VALID" ]]; then
403
+ BATS_DEBUG_LAST_STACK_TRACE=(
404
+ ${BATS_DEBUG_LASTLAST_STACK_TRACE[@]+"${BATS_DEBUG_LASTLAST_STACK_TRACE[@]}"}
405
+ )
406
+ fi
407
+ BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=1
408
+ }
409
+
410
+ bats_interrupt_trap() {
411
+ # mark the interruption, to handle during exit
412
+ BATS_INTERRUPTED=true
413
+ BATS_ERROR_STATUS=130
414
+ # debug trap fires before interrupt trap but gets wrong linenumber (line 1)
415
+ # -> use last stack trace instead of BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=true
416
+ }
417
+
418
+ # this is used inside run()
419
+ bats_interrupt_trap_in_run() {
420
+ # mark the interruption, to handle during exit
421
+ BATS_INTERRUPTED=true
422
+ BATS_ERROR_STATUS=130
423
+ BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=true
424
+ exit 130
425
+ }
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+
3
+ bats_test_count_validator() {
4
+ trap '' INT # continue forwarding
5
+ header_pattern='[0-9]+\.\.[0-9]+'
6
+ IFS= read -r header
7
+ # repeat the header
8
+ printf "%s\n" "$header"
9
+
10
+ # if we detect a TAP plan
11
+ if [[ "$header" =~ $header_pattern ]]; then
12
+ # extract the number of tests ...
13
+ local expected_number_of_tests="${header:3}"
14
+ # ... count the actual number of [not ] oks...
15
+ local actual_number_of_tests=0
16
+ while IFS= read -r line; do
17
+ # forward line
18
+ printf "%s\n" "$line"
19
+ case "$line" in
20
+ 'ok '*)
21
+ ((++actual_number_of_tests))
22
+ ;;
23
+ 'not ok'*)
24
+ ((++actual_number_of_tests))
25
+ ;;
26
+ esac
27
+ done
28
+ # ... and error if they are not the same
29
+ if [[ "${actual_number_of_tests}" != "${expected_number_of_tests}" ]]; then
30
+ printf '# bats warning: Executed %s instead of expected %s tests\n' "$actual_number_of_tests" "$expected_number_of_tests"
31
+ return 1
32
+ fi
33
+ else
34
+ # forward output unchanged
35
+ cat
36
+ fi
37
+ }
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # shellcheck source=lib/bats-core/tracing.bash
4
+ source "$BATS_ROOT/$BATS_LIBDIR/bats-core/tracing.bash"
5
+
6
+ # generate a warning report for the parent call's call site
7
+ bats_generate_warning() { # <warning number> [--no-stacktrace] [<printf args for warning string>...]
8
+ local warning_number="${1-}" padding="00"
9
+ shift
10
+ local no_stacktrace=
11
+ if [[ ${1-} == --no-stacktrace ]]; then
12
+ no_stacktrace=1
13
+ shift
14
+ fi
15
+ if [[ $warning_number =~ [0-9]+ ]] && ((warning_number < ${#BATS_WARNING_SHORT_DESCS[@]})); then
16
+ {
17
+ printf "BW%s: ${BATS_WARNING_SHORT_DESCS[$warning_number]}\n" "${padding:${#warning_number}}${warning_number}" "$@"
18
+ if [[ -z "$no_stacktrace" ]]; then
19
+ bats_capture_stack_trace
20
+ BATS_STACK_TRACE_PREFIX=' ' bats_print_stack_trace "${BATS_DEBUG_LAST_STACK_TRACE[@]}"
21
+ fi
22
+ } >>"$BATS_WARNING_FILE" 2>&3
23
+ else
24
+ printf "Invalid Bats warning number '%s'. It must be an integer between 1 and %d." "$warning_number" "$((${#BATS_WARNING_SHORT_DESCS[@]} - 1))" >&2
25
+ exit 1
26
+ fi
27
+ }
28
+
29
+ # generate a warning if the BATS_GUARANTEED_MINIMUM_VERSION is not high enough
30
+ bats_warn_minimum_guaranteed_version() { # <feature> <minimum required version>
31
+ if bats_version_lt "$BATS_GUARANTEED_MINIMUM_VERSION" "$2"; then
32
+ bats_generate_warning 2 "$1" "$2" "$2"
33
+ fi
34
+ }
35
+
36
+ # put after functions to avoid line changes in tests when new ones get added
37
+ BATS_WARNING_SHORT_DESCS=(
38
+ # to start with 1
39
+ 'PADDING'
40
+ # see issue #578 for context
41
+ "\`run\`'s command \`%s\` exited with code 127, indicating 'Command not found'. Use run's return code checks, e.g. \`run -127\`, to fix this message."
42
+ "%s requires at least BATS_VERSION=%s. Use \`bats_require_minimum_version %s\` to fix this message."
43
+ "\`setup_suite\` is visible to test file '%s', but was not executed. It belongs into 'setup_suite.bash' to be picked up automatically."
44
+ )