File manager - Edit - /home/u774251322/domains/quickyums.com/public_html/static/img/logo/bats-core.zip
Back
PK K9[��}��4 �4 tracing.bashnu ȯ�� #!/usr/bin/bash # shellcheck source=lib/bats-core/common.bash source "$BATS_ROOT/lib/bats-core/common.bash" bats_capture_stack_trace() { local test_file local funcname local i BATS_DEBUG_LAST_STACK_TRACE=() for ((i = 2; i != ${#FUNCNAME[@]}; ++i)); do # Use BATS_TEST_SOURCE if necessary to work around Bash < 4.4 bug whereby # calling an exported function erases the test file's BASH_SOURCE entry. test_file="${BASH_SOURCE[$i]:-$BATS_TEST_SOURCE}" funcname="${FUNCNAME[$i]}" BATS_DEBUG_LAST_STACK_TRACE+=("${BASH_LINENO[$((i-1))]} $funcname $test_file") case "$funcname" in "${BATS_TEST_NAME-}" | setup | teardown | setup_file | teardown_file | setup_suite | teardown_suite) break ;; esac if [[ "${BASH_SOURCE[$i + 1]:-}" == *"bats-exec-file" ]] && [[ "$funcname" == 'source' ]]; then break fi done } bats_get_failure_stack_trace() { local stack_trace_var # See bats_debug_trap for details. if [[ -n "${BATS_DEBUG_LAST_STACK_TRACE_IS_VALID:-}" ]]; then stack_trace_var=BATS_DEBUG_LAST_STACK_TRACE else stack_trace_var=BATS_DEBUG_LASTLAST_STACK_TRACE fi # shellcheck disable=SC2016 eval "$(printf \ '%s=(${%s[@]+"${%s[@]}"})' \ "${1}" \ "${stack_trace_var}" \ "${stack_trace_var}")" } bats_print_stack_trace() { local frame local index=1 local count="${#@}" local filename local lineno for frame in "$@"; do bats_frame_filename "$frame" 'filename' bats_trim_filename "$filename" 'filename' bats_frame_lineno "$frame" 'lineno' printf '%s' "${BATS_STACK_TRACE_PREFIX-# }" if [[ $index -eq 1 ]]; then printf '(' else printf ' ' fi local fn bats_frame_function "$frame" 'fn' if [[ "$fn" != "${BATS_TEST_NAME-}" ]] && # don't print "from function `source'"", # when failing in free code during `source $test_file` from bats-exec-file ! [[ "$fn" == 'source' && $index -eq $count ]]; then local quoted_fn bats_quote_code quoted_fn "$fn" printf "from function %s " "$quoted_fn" fi if [[ $index -eq $count ]]; then printf 'in test file %s, line %d)\n' "$filename" "$lineno" else printf 'in file %s, line %d,\n' "$filename" "$lineno" fi ((++index)) done } bats_print_failed_command() { local stack_trace=("${@}") if [[ ${#stack_trace[@]} -eq 0 ]]; then return 0 fi local frame="${stack_trace[${#stack_trace[@]} - 1]}" local filename local lineno local failed_line local failed_command bats_frame_filename "$frame" 'filename' bats_frame_lineno "$frame" 'lineno' bats_extract_line "$filename" "$lineno" 'failed_line' bats_strip_string "$failed_line" 'failed_command' local quoted_failed_command bats_quote_code quoted_failed_command "$failed_command" printf '# %s ' "${quoted_failed_command}" if [[ "${BATS_TIMED_OUT-NOTSET}" != NOTSET ]]; then # the other values can be safely overwritten here, # as the timeout is the primary reason for failure BATS_ERROR_SUFFIX=" due to timeout" fi if [[ "$BATS_ERROR_STATUS" -eq 1 ]]; then printf 'failed%s\n' "$BATS_ERROR_SUFFIX" else printf 'failed with status %d%s\n' "$BATS_ERROR_STATUS" "$BATS_ERROR_SUFFIX" fi } bats_frame_lineno() { printf -v "$2" '%s' "${1%% *}" } bats_frame_function() { local __bff_function="${1#* }" printf -v "$2" '%s' "${__bff_function%% *}" } bats_frame_filename() { local __bff_filename="${1#* }" __bff_filename="${__bff_filename#* }" if [[ "$__bff_filename" == "${BATS_TEST_SOURCE-}" ]]; then __bff_filename="$BATS_TEST_FILENAME" fi printf -v "$2" '%s' "$__bff_filename" } bats_extract_line() { local __bats_extract_line_line local __bats_extract_line_index=0 while IFS= read -r __bats_extract_line_line; do if [[ "$((++__bats_extract_line_index))" -eq "$2" ]]; then printf -v "$3" '%s' "${__bats_extract_line_line%$'\r'}" break fi done <"$1" } bats_strip_string() { [[ "$1" =~ ^[[:space:]]*(.*)[[:space:]]*$ ]] printf -v "$2" '%s' "${BASH_REMATCH[1]}" } bats_trim_filename() { printf -v "$2" '%s' "${1#"$BATS_CWD"/}" } # normalize a windows path from e.g. C:/directory to /c/directory # The path must point to an existing/accessable directory, not a file! bats_normalize_windows_dir_path() { # <output-var> <path> local output_var="$1" path="$2" if [[ "$output_var" != NORMALIZED_INPUT ]]; then local NORMALIZED_INPUT fi if [[ $path == ?:* ]]; then NORMALIZED_INPUT="$(cd "$path" || exit 1; pwd)" else NORMALIZED_INPUT="$path" fi printf -v "$output_var" "%s" "$NORMALIZED_INPUT" } bats_emit_trace() { if [[ $BATS_TRACE_LEVEL -gt 0 ]]; then local line=${BASH_LINENO[1]} # shellcheck disable=SC2016 if [[ $BASH_COMMAND != '"$BATS_TEST_NAME" >> "$BATS_OUT" 2>&1 4>&1' && $BASH_COMMAND != "bats_test_begin "* ]] && # don't emit these internal calls [[ $BASH_COMMAND != "$BATS_LAST_BASH_COMMAND" || $line != "$BATS_LAST_BASH_LINENO" ]] && # avoid printing a function twice (at call site and at definition site) [[ $BASH_COMMAND != "$BATS_LAST_BASH_COMMAND" || ${BASH_LINENO[2]} != "$BATS_LAST_BASH_LINENO" || ${BASH_SOURCE[3]} != "$BATS_LAST_BASH_SOURCE" ]]; then local file="${BASH_SOURCE[2]}" # index 2: skip over bats_emit_trace and bats_debug_trap if [[ $file == "${BATS_TEST_SOURCE}" ]]; then file="$BATS_TEST_FILENAME" fi local padding='$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$' if (( BATS_LAST_STACK_DEPTH != ${#BASH_LINENO[@]} )); then printf '%s [%s:%d]\n' "${padding::${#BASH_LINENO[@]}-4}" "${file##*/}" "$line" >&4 fi printf '%s %s\n' "${padding::${#BASH_LINENO[@]}-4}" "$BASH_COMMAND" >&4 BATS_LAST_BASH_COMMAND="$BASH_COMMAND" BATS_LAST_BASH_LINENO="$line" BATS_LAST_BASH_SOURCE="${BASH_SOURCE[2]}" BATS_LAST_STACK_DEPTH="${#BASH_LINENO[@]}" fi fi } # bats_debug_trap tracks the last line of code executed within a test. This is # necessary because $BASH_LINENO is often incorrect inside of ERR and EXIT # trap handlers. # # Below are tables describing different command failure scenarios and the # reliability of $BASH_LINENO within different the executed DEBUG, ERR, and EXIT # trap handlers. Naturally, the behaviors change between versions of Bash. # # Table rows should be read left to right. For example, on bash version # 4.0.44(2)-release, if a test executes `false` (or any other failing external # command), bash will do the following in order: # 1. Call the DEBUG trap handler (bats_debug_trap) with $BASH_LINENO referring # to the source line containing the `false` command, then # 2. Call the DEBUG trap handler again, but with an incorrect $BASH_LINENO, then # 3. Call the ERR trap handler, but with a (possibly-different) incorrect # $BASH_LINENO, then # 4. Call the DEBUG trap handler again, but with $BASH_LINENO set to 1, then # 5. Call the EXIT trap handler, with $BASH_LINENO set to 1. # # bash version 4.4.20(1)-release # command | first DEBUG | second DEBUG | ERR | third DEBUG | EXIT # -------------+-------------+--------------+---------+-------------+-------- # false | OK | OK | OK | BAD[1] | BAD[1] # [[ 1 = 2 ]] | OK | BAD[2] | BAD[2] | BAD[1] | BAD[1] # (( 1 = 2 )) | OK | BAD[2] | BAD[2] | BAD[1] | BAD[1] # ! true | OK | --- | BAD[4] | --- | BAD[1] # $var_dne | OK | --- | --- | BAD[1] | BAD[1] # source /dne | OK | --- | --- | BAD[1] | BAD[1] # # bash version 4.0.44(2)-release # command | first DEBUG | second DEBUG | ERR | third DEBUG | EXIT # -------------+-------------+--------------+---------+-------------+-------- # false | OK | BAD[3] | BAD[3] | BAD[1] | BAD[1] # [[ 1 = 2 ]] | OK | --- | BAD[3] | --- | BAD[1] # (( 1 = 2 )) | OK | --- | BAD[3] | --- | BAD[1] # ! true | OK | --- | BAD[3] | --- | BAD[1] # $var_dne | OK | --- | --- | BAD[1] | BAD[1] # source /dne | OK | --- | --- | BAD[1] | BAD[1] # # [1] The reported line number is always 1. # [2] The reported source location is that of the beginning of the function # calling the command. # [3] The reported line is that of the last command executed in the DEBUG trap # handler. # [4] The reported source location is that of the call to the function calling # the command. bats_debug_trap() { # on windows we sometimes get a mix of paths (when install via nmp install -g) # which have C:/... or /c/... comparing them is going to be problematic. # We need to normalize them to a common format! local NORMALIZED_INPUT bats_normalize_windows_dir_path NORMALIZED_INPUT "${1%/*}" local file_excluded='' path for path in "${BATS_DEBUG_EXCLUDE_PATHS[@]}"; do if [[ "$NORMALIZED_INPUT" == "$path"* ]]; then file_excluded=1 break fi done # don't update the trace within library functions or we get backtraces from inside traps # also don't record new stack traces while handling interruptions, to avoid overriding the interrupted command if [[ -z "$file_excluded" && "${BATS_INTERRUPTED-NOTSET}" == NOTSET && "${BATS_TIMED_OUT-NOTSET}" == NOTSET ]]; then BATS_DEBUG_LASTLAST_STACK_TRACE=( ${BATS_DEBUG_LAST_STACK_TRACE[@]+"${BATS_DEBUG_LAST_STACK_TRACE[@]}"} ) BATS_DEBUG_LAST_LINENO=(${BASH_LINENO[@]+"${BASH_LINENO[@]}"}) BATS_DEBUG_LAST_SOURCE=(${BASH_SOURCE[@]+"${BASH_SOURCE[@]}"}) bats_capture_stack_trace bats_emit_trace fi } # For some versions of Bash, the `ERR` trap may not always fire for every # command failure, but the `EXIT` trap will. Also, some command failures may not # set `$?` properly. See #72 and #81 for details. # # For this reason, we call `bats_check_status_from_trap` at the very beginning # of `bats_teardown_trap` and check the value of `$BATS_TEST_COMPLETED` before # taking other actions. We also adjust the exit status value if needed. # # See `bats_exit_trap` for an additional EXIT error handling case when `$?` # isn't set properly during `teardown()` errors. bats_check_status_from_trap() { local status="$?" if [[ -z "${BATS_TEST_COMPLETED:-}" ]]; then BATS_ERROR_STATUS="${BATS_ERROR_STATUS:-$status}" if [[ "$BATS_ERROR_STATUS" -eq 0 ]]; then BATS_ERROR_STATUS=1 fi trap - DEBUG fi } bats_add_debug_exclude_path() { # <path> if [[ -z "$1" ]]; then # don't exclude everything printf "bats_add_debug_exclude_path: Exclude path must not be empty!\n" >&2 return 1 fi if [[ "$OSTYPE" == cygwin || "$OSTYPE" == msys ]]; then local normalized_dir bats_normalize_windows_dir_path normalized_dir "$1" BATS_DEBUG_EXCLUDE_PATHS+=("$normalized_dir") else BATS_DEBUG_EXCLUDE_PATHS+=("$1") fi } bats_setup_tracing() { # Variables for capturing accurate stack traces. See bats_debug_trap for # details. # # BATS_DEBUG_LAST_LINENO, BATS_DEBUG_LAST_SOURCE, and # BATS_DEBUG_LAST_STACK_TRACE hold data from the most recent call to # bats_debug_trap. # # BATS_DEBUG_LASTLAST_STACK_TRACE holds data from two bats_debug_trap calls # ago. # # BATS_DEBUG_LAST_STACK_TRACE_IS_VALID indicates that # BATS_DEBUG_LAST_STACK_TRACE contains the stack trace of the test's error. If # unset, BATS_DEBUG_LAST_STACK_TRACE is unreliable and # BATS_DEBUG_LASTLAST_STACK_TRACE should be used instead. BATS_DEBUG_LASTLAST_STACK_TRACE=() BATS_DEBUG_LAST_LINENO=() BATS_DEBUG_LAST_SOURCE=() BATS_DEBUG_LAST_STACK_TRACE=() BATS_DEBUG_LAST_STACK_TRACE_IS_VALID= BATS_ERROR_SUFFIX= BATS_DEBUG_EXCLUDE_PATHS=() # exclude some paths by default bats_add_debug_exclude_path "$BATS_ROOT/lib/" bats_add_debug_exclude_path "$BATS_ROOT/libexec/" exec 4<&1 # used for tracing if [[ "${BATS_TRACE_LEVEL:-0}" -gt 0 ]]; then # avoid undefined variable errors BATS_LAST_BASH_COMMAND= BATS_LAST_BASH_LINENO= BATS_LAST_BASH_SOURCE= BATS_LAST_STACK_DEPTH= # try to exclude helper libraries if found, this is only relevant for tracing while read -r path; do bats_add_debug_exclude_path "$path" done < <(find "$PWD" -type d -name bats-assert -o -name bats-support) fi local exclude_paths path # exclude user defined libraries IFS=':' read -r exclude_paths <<< "${BATS_DEBUG_EXCLUDE_PATHS:-}" for path in "${exclude_paths[@]}"; do if [[ -n "$path" ]]; then bats_add_debug_exclude_path "$path" fi done # turn on traps after setting excludes to avoid tracing the exclude setup trap 'bats_debug_trap "$BASH_SOURCE"' DEBUG trap 'bats_error_trap' ERR } bats_error_trap() { bats_check_status_from_trap # If necessary, undo the most recent stack trace captured by bats_debug_trap. # See bats_debug_trap for details. if [[ "${BASH_LINENO[*]}" = "${BATS_DEBUG_LAST_LINENO[*]:-}" && "${BASH_SOURCE[*]}" = "${BATS_DEBUG_LAST_SOURCE[*]:-}" && -z "$BATS_DEBUG_LAST_STACK_TRACE_IS_VALID" ]]; then BATS_DEBUG_LAST_STACK_TRACE=( ${BATS_DEBUG_LASTLAST_STACK_TRACE[@]+"${BATS_DEBUG_LASTLAST_STACK_TRACE[@]}"} ) fi BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=1 } bats_interrupt_trap() { # mark the interruption, to handle during exit BATS_INTERRUPTED=true BATS_ERROR_STATUS=130 # debug trap fires before interrupt trap but gets wrong linenumber (line 1) # -> use last stack trace exit $BATS_ERROR_STATUS } # this is used inside run() bats_interrupt_trap_in_run() { # mark the interruption, to handle during exit BATS_INTERRUPTED=true BATS_ERROR_STATUS=130 BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=true exit $BATS_ERROR_STATUS } PK K9[� �q common.bashnu ȯ�� #!/usr/bin/bash bats_prefix_lines_for_tap_output() { while IFS= read -r line; do printf '# %s\n' "$line" || break # avoid feedback loop when errors are redirected into BATS_OUT (see #353) done if [[ -n "$line" ]]; then printf '# %s\n' "$line" fi } function bats_replace_filename() { local line while read -r line; do printf "%s\n" "${line//$BATS_TEST_SOURCE/$BATS_TEST_FILENAME}" done if [[ -n "$line" ]]; then printf "%s\n" "${line//$BATS_TEST_SOURCE/$BATS_TEST_FILENAME}" fi } bats_quote_code() { # <var> <code> printf -v "$1" -- "%s%s%s" "$BATS_BEGIN_CODE_QUOTE" "$2" "$BATS_END_CODE_QUOTE" } bats_check_valid_version() { if [[ ! $1 =~ [0-9]+.[0-9]+.[0-9]+ ]]; then printf "ERROR: version '%s' must be of format <major>.<minor>.<patch>!\n" "$1" >&2 exit 1 fi } # compares two versions. Return 0 when version1 < version2 bats_version_lt() { # <version1> <version2> bats_check_valid_version "$1" bats_check_valid_version "$2" local -a version1_parts version2_parts IFS=. read -ra version1_parts <<< "$1" IFS=. read -ra version2_parts <<< "$2" for i in {0..2}; do if (( version1_parts[i] < version2_parts[i] )); then return 0 elif (( version1_parts[i] > version2_parts[i] )); then return 1 fi done # if we made it this far, they are equal -> also not less then return 2 # use other failing return code to distinguish equal from gt } # ensure a minimum version of bats is running or exit with failure bats_require_minimum_version() { # <required version> local required_minimum_version=$1 if bats_version_lt "$BATS_VERSION" "$required_minimum_version"; then printf "BATS_VERSION=%s does not meet required minimum %s\n" "$BATS_VERSION" "$required_minimum_version" exit 1 fi if bats_version_lt "$BATS_GUARANTEED_MINIMUM_VERSION" "$required_minimum_version"; then BATS_GUARANTEED_MINIMUM_VERSION="$required_minimum_version" fi } bats_binary_search() { # <search-value> <array-name> if [[ $# -ne 2 ]]; then printf "ERROR: bats_binary_search requires exactly 2 arguments: <search value> <array name>\n" >&2 return 2 fi local -r search_value=$1 array_name=$2 # we'd like to test if array is set but we cannot distinguish unset from empty arrays, so we need to skip that local start=0 mid end mid_value # start is inclusive, end is exclusive ... eval "end=\${#${array_name}[@]}" # so start == end means empty search space while (( start < end )); do mid=$(( (start + end) / 2 )) eval "mid_value=\${${array_name}[$mid]}" if [[ "$mid_value" == "$search_value" ]]; then return 0 elif [[ "$mid_value" < "$search_value" ]]; then # This branch excludes equality -> +1 to skip the mid element. # This +1 also avoids endless recursion on odd sized search ranges. start=$((mid + 1)) else end=$mid fi done # did not find it -> its not there return 1 } # store the values in ascending order in result array # Intended for short lists! bats_sort() { # <result-array-name> <values to sort...> local -r result_name=$1 shift if (( $# == 0 )); then eval "$result_name=()" return 0 fi local -a sorted_array=() local -i j i=0 for (( j=1; j <= $#; ++j )); do for ((i=${#sorted_array[@]}; i >= 0; --i )); do if [[ $i -eq 0 || ${sorted_array[$((i-1))]} < ${!j} ]]; then sorted_array[$i]=${!j} break else sorted_array[$i]=${sorted_array[$((i-1))]} fi done done eval "$result_name=(\"\${sorted_array[@]}\")" } # check if all search values (must be sorted!) are in the (sorted!) array # Intended for short lists/arrays! bats_all_in() { # <sorted-array> <sorted search values...> local -r haystack_array=$1 shift local -i haystack_length # just to appease shellcheck eval "local -r haystack_length=\${#${haystack_array}[@]}" local -i haystack_index=0 # initialize only here to continue from last search position local search_value haystack_value # just to appease shellcheck for (( i=1; i <= $#; ++i )); do eval "local search_value=${!i}" for ((; haystack_index < haystack_length; ++haystack_index)); do eval "local haystack_value=\${${haystack_array}[$haystack_index]}" if [[ $haystack_value > "$search_value" ]]; then # we passed the location this value would have been at -> not found return 1 elif [[ $haystack_value == "$search_value" ]]; then continue 2 # search value found -> try the next one fi done return 1 # we ran of the end of the haystack without finding the value! done # did not return from loop above -> all search values were found return 0 } # check if any search value (must be sorted!) is in the (sorted!) array # intended for short lists/arrays bats_any_in() { # <sorted-array> <sorted search values> local -r haystack_array=$1 shift local -i haystack_length # just to appease shellcheck eval "local -r haystack_length=\${#${haystack_array}[@]}" local -i haystack_index=0 # initialize only here to continue from last search position local search_value haystack_value # just to appease shellcheck for (( i=1; i <= $#; ++i )); do eval "local search_value=${!i}" for ((; haystack_index < haystack_length; ++haystack_index)); do eval "local haystack_value=\${${haystack_array}[$haystack_index]}" if [[ $haystack_value > "$search_value" ]]; then continue 2 # search value not in array! -> try next elif [[ $haystack_value == "$search_value" ]]; then return 0 # search value found fi done done # did not return from loop above -> no search value was found return 1 } bats_trim () { # <output-variable> <string> local -r bats_trim_ltrimmed=${2#"${2%%[![:space:]]*}"} # cut off leading whitespace # shellcheck disable=SC2034 # used in eval! local -r bats_trim_trimmed=${bats_trim_ltrimmed%"${bats_trim_ltrimmed##*[![:space:]]}"} # cut off trailing whitespace eval "$1=\$bats_trim_trimmed" } # a helper function to work around unbound variable errors with ${arr[@]} on Bash 3 bats_append_arrays_as_args () { # <array...> -- <command ...> local -a trailing_args=() while (( $# > 0)) && [[ $1 != -- ]]; do local array=$1 shift if eval "(( \${#${array}[@]} > 0 ))"; then eval "trailing_args+=(\"\${${array}[@]}\")" fi done shift # remove -- separator if (( $# == 0 )); then printf "Error: append_arrays_as_args is missing a command or -- separator\n" >&2 return 1 fi if (( ${#trailing_args[@]} > 0 )); then "$@" "${trailing_args[@]}" else "$@" fi } PK K9[��QMk k warnings.bashnu ȯ�� #!/usr/bin/bash # shellcheck source=lib/bats-core/tracing.bash source "$BATS_ROOT/lib/bats-core/tracing.bash" # generate a warning report for the parent call's call site bats_generate_warning() { # <warning number> [--no-stacktrace] [<printf args for warning string>...] local warning_number="${1-}" padding="00" shift local no_stacktrace= if [[ ${1-} == --no-stacktrace ]]; then no_stacktrace=1 shift fi if [[ $warning_number =~ [0-9]+ ]] && ((warning_number < ${#BATS_WARNING_SHORT_DESCS[@]} )); then { printf "BW%s: ${BATS_WARNING_SHORT_DESCS[$warning_number]}\n" "${padding:${#warning_number}}${warning_number}" "$@" if [[ -z "$no_stacktrace" ]]; then bats_capture_stack_trace BATS_STACK_TRACE_PREFIX=' ' bats_print_stack_trace "${BATS_DEBUG_LAST_STACK_TRACE[@]}" fi } >> "$BATS_WARNING_FILE" 2>&3 else printf "Invalid Bats warning number '%s'. It must be an integer between 1 and %d." "$warning_number" "$((${#BATS_WARNING_SHORT_DESCS[@]} - 1))" >&2 exit 1 fi } # generate a warning if the BATS_GUARANTEED_MINIMUM_VERSION is not high enough bats_warn_minimum_guaranteed_version() { # <feature> <minimum required version> if bats_version_lt "$BATS_GUARANTEED_MINIMUM_VERSION" "$2"; then bats_generate_warning 2 "$1" "$2" "$2" fi } # put after functions to avoid line changes in tests when new ones get added BATS_WARNING_SHORT_DESCS=( # to start with 1 'PADDING' # see issue #578 for context "\`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." "%s requires at least BATS_VERSION=%s. Use \`bats_require_minimum_version %s\` to fix this message." "\`setup_suite\` is visible to test file '%s', but was not executed. It belongs into 'setup_suite.bash' to be picked up automatically." ) PK K9[V*G G formatter.bashnu ȯ�� #!/usr/bin/bash # reads (extended) bats tap streams from stdin and calls callback functions for each line # # Segmenting functions # ==================== # bats_tap_stream_plan <number of tests> -> when the test plan is encountered # bats_tap_stream_suite <file name> -> when a new file is begun WARNING: extended only # bats_tap_stream_begin <test index> <test name> -> when a new test is begun WARNING: extended only # # Test result functions # ===================== # If timing was enabled, BATS_FORMATTER_TEST_DURATION will be set to their duration in milliseconds # bats_tap_stream_ok <test index> <test name> -> when a test was successful # bats_tap_stream_not_ok <test index> <test name> -> when a test has failed. If the failure was due to a timeout, # BATS_FORMATTER_TEST_TIMEOUT is set to the timeout duration in seconds # bats_tap_stream_skipped <test index> <test name> <skip reason> -> when a test was skipped # # Context functions # ================= # bats_tap_stream_comment <comment text without leading '# '> <scope> -> when a comment line was encountered, # scope tells the last encountered of plan, begin, ok, not_ok, skipped, suite # bats_tap_stream_unknown <full line> <scope> -> when a line is encountered that does not match the previous entries, # scope @see bats_tap_stream_comment # forwards all input as is, when there is no TAP test plan header function bats_parse_internal_extended_tap() { local header_pattern='[0-9]+\.\.[0-9]+' IFS= read -r header if [[ "$header" =~ $header_pattern ]]; then bats_tap_stream_plan "${header:3}" else # If the first line isn't a TAP plan, print it and pass the rest through printf '%s\n' "$header" exec cat fi ok_line_regexpr="ok ([0-9]+) (.*)" skip_line_regexpr="ok ([0-9]+) (.*) # skip( (.*))?$" timeout_line_regexpr="not ok ([0-9]+) (.*) # timeout after ([0-9]+)s$" not_ok_line_regexpr="not ok ([0-9]+) (.*)" timing_expr="in ([0-9]+)ms$" local test_name begin_index ok_index not_ok_index index scope begin_index=0 index=0 scope=plan while IFS= read -r line; do unset BATS_FORMATTER_TEST_DURATION BATS_FORMATTER_TEST_TIMEOUT case "$line" in 'begin '*) # this might only be called in extended tap output ((++begin_index)) scope=begin test_name="${line#* "$begin_index" }" bats_tap_stream_begin "$begin_index" "$test_name" ;; 'ok '*) ((++index)) if [[ "$line" =~ $ok_line_regexpr ]]; then ok_index="${BASH_REMATCH[1]}" test_name="${BASH_REMATCH[2]}" if [[ "$line" =~ $skip_line_regexpr ]]; then scope=skipped test_name="${BASH_REMATCH[2]}" # cut off name before "# skip" local skip_reason="${BASH_REMATCH[4]}" if [[ "$test_name" =~ $timing_expr ]]; then local BATS_FORMATTER_TEST_DURATION="${BASH_REMATCH[1]}" test_name="${test_name% in "${BATS_FORMATTER_TEST_DURATION}"ms}" bats_tap_stream_skipped "$ok_index" "$test_name" "$skip_reason" else bats_tap_stream_skipped "$ok_index" "$test_name" "$skip_reason" fi else scope=ok if [[ "$line" =~ $timing_expr ]]; then local BATS_FORMATTER_TEST_DURATION="${BASH_REMATCH[1]}" bats_tap_stream_ok "$ok_index" "${test_name% in "${BASH_REMATCH[1]}"ms}" else bats_tap_stream_ok "$ok_index" "$test_name" fi fi else printf "ERROR: could not match ok line: %s" "$line" >&2 exit 1 fi ;; 'not ok '*) ((++index)) scope=not_ok if [[ "$line" =~ $not_ok_line_regexpr ]]; then not_ok_index="${BASH_REMATCH[1]}" test_name="${BASH_REMATCH[2]}" if [[ "$line" =~ $timeout_line_regexpr ]]; then not_ok_index="${BASH_REMATCH[1]}" test_name="${BASH_REMATCH[2]}" # shellcheck disable=SC2034 # used in bats_tap_stream_ok local BATS_FORMATTER_TEST_TIMEOUT="${BASH_REMATCH[3]}" fi if [[ "$test_name" =~ $timing_expr ]]; then # shellcheck disable=SC2034 # used in bats_tap_stream_ok local BATS_FORMATTER_TEST_DURATION="${BASH_REMATCH[1]}" test_name="${test_name% in "${BASH_REMATCH[1]}"ms}" fi bats_tap_stream_not_ok "$not_ok_index" "$test_name" else printf "ERROR: could not match not ok line: %s" "$line" >&2 exit 1 fi ;; '# '*) bats_tap_stream_comment "${line:2}" "$scope" ;; '#') bats_tap_stream_comment "" "$scope" ;; 'suite '*) scope=suite # pass on the bats_tap_stream_suite "${line:6}" ;; *) bats_tap_stream_unknown "$line" "$scope" ;; esac done } normalize_base_path() { # <target variable> <base path> # the relative path root to use for reporting filenames # this is mainly intended for suite mode, where this will be the suite root folder local base_path="$2" # use the containing directory when --base-path is a file if [[ ! -d "$base_path" ]]; then base_path="$(dirname "$base_path")" fi # get the absolute path base_path="$(cd "$base_path" && pwd)" # ensure the path ends with / to strip that later on if [[ "${base_path}" != *"/" ]]; then base_path="$base_path/" fi printf -v "$1" "%s" "$base_path" } PK K9[�y��� � semaphore.bashnu ȯ�� #!/usr/bin/bash # setup the semaphore environment for the loading file bats_semaphore_setup() { export -f bats_semaphore_get_free_slot_count export -f bats_semaphore_acquire_while_locked export BATS_SEMAPHORE_DIR="$BATS_RUN_TMPDIR/semaphores" if command -v flock >/dev/null; then bats_run_under_lock() { flock "$BATS_SEMAPHORE_DIR" "$@" } elif command -v shlock >/dev/null; then bats_run_under_lock() { local lockfile="$BATS_SEMAPHORE_DIR/shlock.lock" while ! shlock -p $$ -f "$lockfile"; do sleep 1 done # we got the lock now, execute the command "$@" local status=$? # free the lock rm -f "$lockfile" return $status } else printf "ERROR: flock/shlock is required for parallelization within files!\n" >&2 exit 1 fi } # $1 - output directory for stdout/stderr # $@ - command to run # run the given command in a semaphore # block when there is no free slot for the semaphore # when there is a free slot, run the command in background # gather the output of the command in files in the given directory bats_semaphore_run() { local output_dir=$1 shift local semaphore_slot semaphore_slot=$(bats_semaphore_acquire_slot) bats_semaphore_release_wrapper "$output_dir" "$semaphore_slot" "$@" & printf "%d\n" "$!" } # $1 - output directory for stdout/stderr # $@ - command to run # this wraps the actual function call to install some traps on exiting bats_semaphore_release_wrapper() { local output_dir="$1" local semaphore_name="$2" shift 2 # all other parameters will be use for the command to execute # shellcheck disable=SC2064 # we want to expand the semaphore_name right now! trap "status=$?; bats_semaphore_release_slot '$semaphore_name'; exit $status" EXIT mkdir -p "$output_dir" "$@" 2>"$output_dir/stderr" >"$output_dir/stdout" local status=$? # bash bug: the exit trap is not called for the background process bats_semaphore_release_slot "$semaphore_name" trap - EXIT # avoid calling release twice return $status } bats_semaphore_acquire_while_locked() { if [[ $(bats_semaphore_get_free_slot_count) -gt 0 ]]; then local slot=0 while [[ -e "$BATS_SEMAPHORE_DIR/slot-$slot" ]]; do (( ++slot )) done if [[ $slot -lt $BATS_SEMAPHORE_NUMBER_OF_SLOTS ]]; then touch "$BATS_SEMAPHORE_DIR/slot-$slot" && printf "%d\n" "$slot" && return 0 fi fi return 1 } # block until a semaphore slot becomes free # prints the number of the slot that it received bats_semaphore_acquire_slot() { mkdir -p "$BATS_SEMAPHORE_DIR" # wait for a slot to become free # TODO: avoid busy waiting by using signals -> this opens op prioritizing possibilities as well while true; do # don't lock for reading, we are fine with spuriously getting no free slot if [[ $(bats_semaphore_get_free_slot_count) -gt 0 ]]; then bats_run_under_lock bash -c bats_semaphore_acquire_while_locked && break fi sleep 1 done } bats_semaphore_release_slot() { # we don't need to lock this, since only our process owns this file # and freeing a semaphore cannot lead to conflicts with others rm "$BATS_SEMAPHORE_DIR/slot-$1" # this will fail if we had not acquired a semaphore! } bats_semaphore_get_free_slot_count() { # find might error out without returning something useful when a file is deleted, # while the directory is traversed -> only continue when there was no error until used_slots=$(find "$BATS_SEMAPHORE_DIR" -name 'slot-*' 2>/dev/null | wc -l); do :; done echo $(( BATS_SEMAPHORE_NUMBER_OF_SLOTS - used_slots )) } PK K9[���M) M) test_functions.bashnu ȯ�� #!/usr/bin/bash BATS_TEST_DIRNAME="${BATS_TEST_FILENAME%/*}" BATS_TEST_NAMES=() # shellcheck source=lib/bats-core/warnings.bash source "$BATS_ROOT/lib/bats-core/warnings.bash" # find_in_bats_lib_path echoes the first recognized load path to # a library in BATS_LIB_PATH or relative to BATS_TEST_DIRNAME. # # Libraries relative to BATS_TEST_DIRNAME take precedence over # BATS_LIB_PATH. # # Library load paths are recognized using find_library_load_path. # # If no library is found find_in_bats_lib_path returns 1. find_in_bats_lib_path() { # <return-var> <library-name> local return_var="${1:?}" local library_name="${2:?}" local -a bats_lib_paths IFS=: read -ra bats_lib_paths <<< "$BATS_LIB_PATH" for path in "${bats_lib_paths[@]}"; do if [[ -f "$path/$library_name" ]]; then printf -v "$return_var" "%s" "$path/$library_name" # A library load path was found, return return 0 elif [[ -f "$path/$library_name/load.bash" ]]; then printf -v "$return_var" "%s" "$path/$library_name/load.bash" # A library load path was found, return return 0 fi done return 1 } # bats_internal_load expects an absolute path that is a library load path. # # If the library load path points to a file (a library loader) it is # sourced. # # If it points to a directory all files ending in .bash inside of the # directory are sourced. # # If the sourcing of the library loader or of a file in a library # directory fails bats_internal_load prints an error message and returns 1. # # If the passed library load path is not absolute or is not a valid file # or directory bats_internal_load prints an error message and returns 1. bats_internal_load() { local library_load_path="${1:?}" if [[ "${library_load_path:0:1}" != / ]]; then printf "Passed library load path is not an absolute path: %s\n" "$library_load_path" >&2 return 1 fi # library_load_path is a library loader if [[ -f "$library_load_path" ]]; then # shellcheck disable=SC1090 if ! source "$library_load_path"; then printf "Error while sourcing library loader at '%s'\n" "$library_load_path" >&2 return 1 fi return 0 fi printf "Passed library load path is neither a library loader nor library directory: %s\n" "$library_load_path" >&2 return 1 } # bats_load_safe accepts an argument called 'slug' and attempts to find and # source a library based on the slug. # # A slug can be an absolute path, a library name or a relative path. # # If the slug is an absolute path bats_load_safe attempts to find the library # load path using find_library_load_path. # What is considered a library load path is documented in the # documentation for find_library_load_path. # # If the slug is not an absolute path it is considered a library name or # relative path. bats_load_safe attempts to find the library load path using # find_in_bats_lib_path. # # If bats_load_safe can find a library load path it is passed to bats_internal_load. # If bats_internal_load fails bats_load_safe returns 1. # # If no library load path can be found bats_load_safe prints an error message # and returns 1. bats_load_safe() { local slug="${1:?}" if [[ ${slug:0:1} != / ]]; then # relative paths are relative to BATS_TEST_DIRNAME slug="$BATS_TEST_DIRNAME/$slug" fi if [[ -f "$slug.bash" ]]; then bats_internal_load "$slug.bash" return $? elif [[ -f "$slug" ]]; then bats_internal_load "$slug" return $? fi # loading from PATH (retained for backwards compatibility) if [[ ! -f "$1" ]] && type -P "$1" >/dev/null; then # shellcheck disable=SC1090 source "$1" return $? fi # No library load path can be found printf "bats_load_safe: Could not find '%s'[.bash]\n" "$slug" >&2 return 1 } bats_load_library_safe() { # <slug> local slug="${1:?}" library_path # Check for library load paths in BATS_TEST_DIRNAME and BATS_LIB_PATH if [[ ${slug:0:1} != / ]]; then if ! find_in_bats_lib_path library_path "$slug"; then printf "Could not find library '%s' relative to test file or in BATS_LIB_PATH\n" "$slug" >&2 return 1 fi else # absolute paths are taken as is library_path="$slug" if [[ ! -f "$library_path" ]]; then printf "Could not find library on absolute path '%s'\n" "$library_path" >&2 return 1 fi fi bats_internal_load "$library_path" return $? } # immediately exit on error, use bats_load_library_safe to catch and handle errors bats_load_library() { # <slug> if ! bats_load_library_safe "$@"; then exit 1 fi } # load acts like bats_load_safe but exits the shell instead of returning 1. load() { if ! bats_load_safe "$@"; then exit 1 fi } bats_redirect_stderr_into_file() { "$@" 2>>"$bats_run_separate_stderr_file" # use >> to see collisions' content } bats_merge_stdout_and_stderr() { "$@" 2>&1 } # write separate lines from <input-var> into <output-array> bats_separate_lines() { # <output-array> <input-var> local output_array_name="$1" local input_var_name="$2" if [[ $keep_empty_lines ]]; then local bats_separate_lines_lines=() if [[ -n "${!input_var_name}" ]]; then # avoid getting an empty line for empty input while IFS= read -r line; do bats_separate_lines_lines+=("$line") done <<<"${!input_var_name}" fi eval "${output_array_name}=(\"\${bats_separate_lines_lines[@]}\")" else # shellcheck disable=SC2034,SC2206 IFS=$'\n' read -d '' -r -a "$output_array_name" <<<"${!input_var_name}" || true # don't fail due to EOF fi } run() { # [!|-N] [--keep-empty-lines] [--separate-stderr] [--] <command to run...> # This has to be restored on exit from this function to avoid leaking our trap INT into surrounding code. # Non zero exits won't restore under the assumption that they will fail the test before it can be aborted, # which allows us to avoid duplicating the restore code on every exit path trap bats_interrupt_trap_in_run INT local expected_rc= local keep_empty_lines= local output_case=merged local has_flags= # parse options starting with - while [[ $# -gt 0 ]] && [[ $1 == -* || $1 == '!' ]]; do has_flags=1 case "$1" in '!') expected_rc=-1 ;; -[0-9]*) expected_rc=${1#-} if [[ $expected_rc =~ [^0-9] ]]; then printf "Usage error: run: '-NNN' requires numeric NNN (got: %s)\n" "$expected_rc" >&2 return 1 elif [[ $expected_rc -gt 255 ]]; then printf "Usage error: run: '-NNN': NNN must be <= 255 (got: %d)\n" "$expected_rc" >&2 return 1 fi ;; --keep-empty-lines) keep_empty_lines=1 ;; --separate-stderr) output_case="separate" ;; --) shift # eat the -- before breaking away break ;; *) printf "Usage error: unknown flag '%s'" "$1" >&2 return 1 ;; esac shift done if [[ -n $has_flags ]]; then bats_warn_minimum_guaranteed_version "Using flags on \`run\`" 1.5.0 fi local pre_command= case "$output_case" in merged) # redirects stderr into stdout and fills only $output/$lines pre_command=bats_merge_stdout_and_stderr ;; separate) # splits stderr into own file and fills $stderr/$stderr_lines too local bats_run_separate_stderr_file bats_run_separate_stderr_file="$(mktemp "${BATS_TEST_TMPDIR}/separate-stderr-XXXXXX")" pre_command=bats_redirect_stderr_into_file ;; esac local origFlags="$-" set +eET if [[ $keep_empty_lines ]]; then # 'output', 'status', 'lines' are global variables available to tests. # preserve trailing newlines by appending . and removing it later # shellcheck disable=SC2034 output="$("$pre_command" "$@"; status=$?; printf .; exit $status)" && status=0 || status=$? output="${output%.}" else # 'output', 'status', 'lines' are global variables available to tests. # shellcheck disable=SC2034 output="$("$pre_command" "$@")" && status=0 || status=$? fi bats_separate_lines lines output if [[ "$output_case" == separate ]]; then # shellcheck disable=SC2034 read -d '' -r stderr < "$bats_run_separate_stderr_file" || true bats_separate_lines stderr_lines stderr fi # shellcheck disable=SC2034 BATS_RUN_COMMAND="${*}" set "-$origFlags" if [[ ${BATS_VERBOSE_RUN:-} ]]; then printf "%s\n" "$output" fi if [[ -n "$expected_rc" ]]; then if [[ "$expected_rc" = "-1" ]]; then if [[ "$status" -eq 0 ]]; then BATS_ERROR_SUFFIX=", expected nonzero exit code!" return 1 fi elif [ "$status" -ne "$expected_rc" ]; then # shellcheck disable=SC2034 BATS_ERROR_SUFFIX=", expected exit code $expected_rc, got $status" return 1 fi elif [[ "$status" -eq 127 ]]; then # "command not found" bats_generate_warning 1 "$BATS_RUN_COMMAND" fi # don't leak our trap into surrounding code trap bats_interrupt_trap INT } setup() { return 0 } teardown() { return 0 } skip() { # if this is a skip in teardown ... if [[ -n "${BATS_TEARDOWN_STARTED-}" ]]; then # ... we want to skip the rest of teardown. # communicate to bats_exit_trap that the teardown was completed without error # shellcheck disable=SC2034 BATS_TEARDOWN_COMPLETED=1 # if we are already in the exit trap (e.g. due to previous skip) ... if [[ "$BATS_TEARDOWN_STARTED" == as-exit-trap ]]; then # ... we need to do the rest of the tear_down_trap that would otherwise be skipped after the next call to exit bats_exit_trap # and then do the exit (at the end of this function) fi # if we aren't in exit trap, the normal exit handling should suffice else # ... this is either skip in test or skip in setup. # Following variables are used in bats-exec-test which sources this file # shellcheck disable=SC2034 BATS_TEST_SKIPPED="${1:-1}" # shellcheck disable=SC2034 BATS_TEST_COMPLETED=1 fi exit 0 } bats_test_begin() { BATS_TEST_DESCRIPTION="$1" if [[ -n "$BATS_EXTENDED_SYNTAX" ]]; then printf 'begin %d %s\n' "$BATS_SUITE_TEST_NUMBER" "${BATS_TEST_NAME_PREFIX:-}$BATS_TEST_DESCRIPTION" >&3 fi setup } bats_test_function() { local test_name="$1" BATS_TEST_NAMES+=("$test_name") } # decides whether a failed test should be run again bats_should_retry_test() { # test try number starts at 1 # 0 retries means run only first try (( BATS_TEST_TRY_NUMBER <= BATS_TEST_RETRIES )) } PK K9[�90 validator.bashnu ȯ�� #!/usr/bin/bash bats_test_count_validator() { trap '' INT # continue forwarding header_pattern='[0-9]+\.\.[0-9]+' IFS= read -r header # repeat the header printf "%s\n" "$header" # if we detect a TAP plan if [[ "$header" =~ $header_pattern ]]; then # extract the number of tests ... local expected_number_of_tests="${header:3}" # ... count the actual number of [not ] oks... local actual_number_of_tests=0 while IFS= read -r line; do # forward line printf "%s\n" "$line" case "$line" in 'ok '*) (( ++actual_number_of_tests )) ;; 'not ok'*) (( ++actual_number_of_tests )) ;; esac done # ... and error if they are not the same if [[ "${actual_number_of_tests}" != "${expected_number_of_tests}" ]]; then printf '# bats warning: Executed %s instead of expected %s tests\n' "$actual_number_of_tests" "$expected_number_of_tests" return 1 fi else # forward output unchanged cat fi }PK K9[�DQ� � preprocessing.bashnu ȯ�� #!/usr/bin/bash BATS_TMPNAME="$BATS_RUN_TMPDIR/bats.$$" BATS_PARENT_TMPNAME="$BATS_RUN_TMPDIR/bats.$PPID" # shellcheck disable=SC2034 BATS_OUT="${BATS_TMPNAME}.out" # used in bats-exec-file bats_preprocess_source() { # export to make it visible to bats_evaluate_preprocessed_source # since the latter runs in bats-exec-test's bash while this runs in bats-exec-file's export BATS_TEST_SOURCE="${BATS_TMPNAME}.src" CHECK_BATS_COMMENT_COMMANDS=1 bats-preprocess "$BATS_TEST_FILENAME" >"$BATS_TEST_SOURCE" } bats_evaluate_preprocessed_source() { if [[ -z "${BATS_TEST_SOURCE:-}" ]]; then BATS_TEST_SOURCE="${BATS_PARENT_TMPNAME}.src" fi # Dynamically loaded user files provided outside of Bats. # shellcheck disable=SC1090 source "$BATS_TEST_SOURCE" } PK K9[��}��4 �4 tracing.bashnu ȯ�� PK K9[� �q 5 common.bashnu ȯ�� PK K9[��QMk k YO warnings.bashnu ȯ�� PK K9[V*G G W formatter.bashnu ȯ�� PK K9[�y��� � �p semaphore.bashnu ȯ�� PK K9[���M) M) � test_functions.bashnu ȯ�� PK K9[�90 F� validator.bashnu ȯ�� PK K9[�DQ� � �� preprocessing.bashnu ȯ�� PK s ʰ
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings