summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-test
diff options
context:
space:
mode:
authorDiego Sueiro <diego.sueiro@arm.com>2022-05-16 13:28:48 +0100
committerKhem Raj <raj.khem@gmail.com>2022-05-16 09:09:47 -0700
commit72fbb8379fc47ec77cdcb1c15e992d99d205ced2 (patch)
tree5512a77fa8bffc5ef0cfde8c5ba4d1d04ac0bab9 /meta-oe/recipes-test
parentf4d74702b27f0515e3605b95a675038b8cfd38b7 (diff)
downloadmeta-openembedded-72fbb8379fc47ec77cdcb1c15e992d99d205ced2.tar.gz
bats: upgrade 1.6.0 -> 1.6.1
The 1.6.1 incorporates the 0001-Fix-status-in-teardown-overriding-exit-code.patch backport patch. Changelog: ========== Fixed: ------ prevent teardown, teardown_file, and teardown_suite from overriding bats' exit code by setting $status (e.g. via calling run) (#581, #575) CRITICAL: this can return exit code 0 despite failed tests, thus preventing your CI from reporting test failures! The regression happened in version 1.6.0. Documentation: -------------- corrected invalid documentation of run -N (had =N instead) (#579) CRITICAL: using the incorrect form can lead to silent errors. See issue #578 for more details and how to find out if your tests are affected. Signed-off-by: Diego Sueiro <diego.sueiro@arm.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-test')
-rw-r--r--meta-oe/recipes-test/bats/bats_1.6.1.bb (renamed from meta-oe/recipes-test/bats/bats_1.6.0.bb)7
-rw-r--r--meta-oe/recipes-test/bats/files/0001-Fix-status-in-teardown-overriding-exit-code.patch150
2 files changed, 3 insertions, 154 deletions
diff --git a/meta-oe/recipes-test/bats/bats_1.6.0.bb b/meta-oe/recipes-test/bats/bats_1.6.1.bb
index df81595c9..7d72a5198 100644
--- a/meta-oe/recipes-test/bats/bats_1.6.0.bb
+++ b/meta-oe/recipes-test/bats/bats_1.6.1.bb
@@ -7,12 +7,11 @@ LICENSE = "MIT"
7LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2970203aedf9e829edb96a137a4fe81b" 7LIC_FILES_CHKSUM = "file://LICENSE.md;md5=2970203aedf9e829edb96a137a4fe81b"
8 8
9SRC_URI = "\ 9SRC_URI = "\
10 git://github.com/bats-core/bats-core.git;branch=master;protocol=https \ 10 git://github.com/bats-core/bats-core.git;branch=version/1.6.x;protocol=https \
11 file://0001-Fix-status-in-teardown-overriding-exit-code.patch \
12 " 11 "
13 12
14# v1.6.0 13# v1.6.1
15SRCREV = "210acf3a8ed318ddedad3137c15451739beba7d4" 14SRCREV = "1977254c2a7faa2e0af17355856f91dc471d1daa"
16 15
17S = "${WORKDIR}/git" 16S = "${WORKDIR}/git"
18 17
diff --git a/meta-oe/recipes-test/bats/files/0001-Fix-status-in-teardown-overriding-exit-code.patch b/meta-oe/recipes-test/bats/files/0001-Fix-status-in-teardown-overriding-exit-code.patch
deleted file mode 100644
index f4b1db931..000000000
--- a/meta-oe/recipes-test/bats/files/0001-Fix-status-in-teardown-overriding-exit-code.patch
+++ /dev/null
@@ -1,150 +0,0 @@
1From aa628ccdc4dec1c129c1bd98b53ef94d8c2e119a Mon Sep 17 00:00:00 2001
2From: Richard Neill <richard.neill@arm.com>
3Date: Mon, 9 May 2022 12:20:48 +0100
4Subject: [PATCH] Fix status in teardown* overriding exit code
5
6Patch fixes regression which produces false-negatives in v1.6.0, where the
7teardown function can cause BATS to report success even if test cases fail.
8Fixes: https://github.com/bats-core/bats-core/issues/575
9
10Upstream-Status: Backport [Adapted from https://github.com/bats-core/bats-core/commit/5f372058b05f817e4e3a8dab27f83c30fd467504]
11Signed-off-by: Richard Neill <richard.neill@arm.com>
12---
13 libexec/bats-core/bats-exec-file | 18 ++++++++----------
14 libexec/bats-core/bats-exec-suite | 12 ++++++------
15 libexec/bats-core/bats-exec-test | 8 ++++----
16 3 files changed, 18 insertions(+), 20 deletions(-)
17
18diff --git a/libexec/bats-core/bats-exec-file b/libexec/bats-core/bats-exec-file
19index 298441b..63452c7 100755
20--- a/libexec/bats-core/bats-exec-file
21+++ b/libexec/bats-core/bats-exec-file
22@@ -118,7 +118,6 @@ bats_run_teardown_file() {
23
24 bats_file_teardown_trap() {
25 bats_run_teardown_file
26- local status=0
27 bats_file_exit_trap
28 }
29
30@@ -144,9 +143,9 @@ bats_file_exit_trap() {
31 bats_print_failed_command "${stack_trace[@]}" >&3
32 bats_prefix_lines_for_tap_output < "$BATS_OUT" | bats_replace_filename >&3
33 rm -rf "$BATS_OUT"
34- status=1
35+ bats_exec_file_status=1
36 fi
37- exit $status
38+ exit $bats_exec_file_status
39 }
40
41 function setup_file() {
42@@ -250,15 +249,15 @@ bats_read_tests_list_file() {
43 }
44
45 bats_run_tests() {
46- status=0
47+ bats_exec_file_status=0
48
49 if [[ "$num_jobs" != 1 && "${BATS_NO_PARALLELIZE_WITHIN_FILE-False}" == False ]]; then
50 export BATS_SEMAPHORE_NUMBER_OF_SLOTS="$num_jobs"
51- bats_run_tests_in_parallel "$BATS_RUN_TMPDIR/parallel_output" || status=1
52+ bats_run_tests_in_parallel "$BATS_RUN_TMPDIR/parallel_output" || bats_exec_file_status=1
53 else
54 for test_name in "${tests_to_run[@]}"; do
55 if [[ "${BATS_INTERRUPTED-NOTSET}" != NOTSET ]]; then
56- status=130 # bash's code for SIGINT exits
57+ bats_exec_file_status=130 # bash's code for SIGINT exits
58 break
59 fi
60 # Only handle non-empty lines
61@@ -267,14 +266,13 @@ bats_run_tests() {
62 ((++test_number_in_file))
63 # deal with empty flags to avoid spurious "unbound variable" errors on Bash 4.3 and lower
64 if [[ "${#flags[@]}" -gt 0 ]]; then
65- "$BATS_LIBEXEC/bats-exec-test" "${flags[@]}" "$filename" "$test_name" "$test_number_in_suite" "$test_number_in_file" || status=1
66+ "$BATS_LIBEXEC/bats-exec-test" "${flags[@]}" "$filename" "$test_name" "$test_number_in_suite" "$test_number_in_file" || bats_exec_file_status=1
67 else
68- "$BATS_LIBEXEC/bats-exec-test" "$filename" "$test_name" "$test_number_in_suite" "$test_number_in_file" || status=1
69+ "$BATS_LIBEXEC/bats-exec-test" "$filename" "$test_name" "$test_number_in_suite" "$test_number_in_file" || bats_exec_file_status=1
70 fi
71 fi
72 done
73 fi
74- export status
75 }
76
77 bats_create_file_tempdirs() {
78@@ -322,4 +320,4 @@ bats_run_tests
79 trap bats_interrupt_trap INT
80 bats_run_teardown_file
81
82-exit $status
83+exit $bats_exec_file_status
84diff --git a/libexec/bats-core/bats-exec-suite b/libexec/bats-core/bats-exec-suite
85index 05c66f4..4d440ae 100755
86--- a/libexec/bats-core/bats-exec-suite
87+++ b/libexec/bats-core/bats-exec-suite
88@@ -135,10 +135,10 @@ bats_exit_trap() {
89 if [[ ${BATS_INTERRUPTED-NOTSET} != NOTSET ]]; then
90 printf "\n# Received SIGINT, aborting ...\n\n"
91 fi
92- exit "$status"
93+ exit "$bats_exec_suite_status"
94 }
95
96-status=0
97+bats_exec_suite_status=0
98 printf '1..%d\n' "${test_count}"
99
100 # No point on continuing if there's no tests.
101@@ -163,15 +163,15 @@ if [[ "$num_jobs" -gt 1 ]] && [[ -z "$bats_no_parallelize_across_files" ]]; then
102 # shellcheck disable=SC2086,SC2068
103 # we need to handle the quoting of ${flags[@]} ourselves,
104 # because parallel can only quote it as one
105- parallel --keep-order --jobs "$num_jobs" bats-exec-file "$(printf "%q " "${flags[@]}")" "{}" "$TESTS_LIST_FILE" ::: "${BATS_UNIQUE_TEST_FILENAMES[@]}" 2>&1 || status=1
106+ parallel --keep-order --jobs "$num_jobs" bats-exec-file "$(printf "%q " "${flags[@]}")" "{}" "$TESTS_LIST_FILE" ::: "${BATS_UNIQUE_TEST_FILENAMES[@]}" 2>&1 || bats_exec_suite_status=1
107 else
108 for filename in "${BATS_UNIQUE_TEST_FILENAMES[@]}"; do
109 if [[ "${BATS_INTERRUPTED-NOTSET}" != NOTSET ]]; then
110- status=130 # bash's code for SIGINT exits
111+ bats_exec_suite_status=130 # bash's code for SIGINT exits
112 break
113 fi
114- bats-exec-file "${flags[@]}" "$filename" "${TESTS_LIST_FILE}" || status=1
115+ bats-exec-file "${flags[@]}" "$filename" "${TESTS_LIST_FILE}" || bats_exec_suite_status=1
116 done
117 fi
118
119-exit "$status"
120+exit "$bats_exec_suite_status"
121diff --git a/libexec/bats-core/bats-exec-test b/libexec/bats-core/bats-exec-test
122index aae4572..57bdf18 100755
123--- a/libexec/bats-core/bats-exec-test
124+++ b/libexec/bats-core/bats-exec-test
125@@ -94,18 +94,18 @@ source "$BATS_ROOT/lib/bats-core/tracing.bash"
126
127 bats_teardown_trap() {
128 bats_check_status_from_trap
129- local status=0
130+ local bats_teardown_trap_status=0
131 # mark the start of this function to distinguish where skip is called
132 # parameter 1 will signify the reason why this function was called
133 # this is used to identify when this is called as exit trap function
134 BATS_TEARDOWN_STARTED=${1:-1}
135- teardown >>"$BATS_OUT" 2>&1 || status="$?"
136+ teardown >>"$BATS_OUT" 2>&1 || bats_teardown_trap_status="$?"
137
138- if [[ $status -eq 0 ]]; then
139+ if [[ $bats_teardown_trap_status -eq 0 ]]; then
140 BATS_TEARDOWN_COMPLETED=1
141 elif [[ -n "$BATS_TEST_COMPLETED" ]]; then
142 BATS_DEBUG_LAST_STACK_TRACE_IS_VALID=1
143- BATS_ERROR_STATUS="$status"
144+ BATS_ERROR_STATUS="$bats_teardown_trap_status"
145 fi
146
147 bats_exit_trap
148--
1492.25.1
150