mirror of
https://github.com/containers/podman.git
synced 2025-06-21 17:38:12 +08:00
Merge pull request #20848 from edsantiago/safer_defer
deferred test failures: handle a corner case
This commit is contained in:
@ -254,10 +254,6 @@ function pasta_test_do() {
|
|||||||
assert "${output}" = "${expect}" "Mismatch between data sent and received"
|
assert "${output}" = "${expect}" "Mismatch between data sent and received"
|
||||||
}
|
}
|
||||||
|
|
||||||
function teardown() {
|
|
||||||
rm -f "${XFER_FILE}"
|
|
||||||
}
|
|
||||||
|
|
||||||
### Addresses ##################################################################
|
### Addresses ##################################################################
|
||||||
|
|
||||||
@test "IPv4 default address assignment" {
|
@test "IPv4 default address assignment" {
|
||||||
|
@ -210,13 +210,23 @@ function basic_setup() {
|
|||||||
immediate-assertion-failures
|
immediate-assertion-failures
|
||||||
}
|
}
|
||||||
|
|
||||||
function immediate-assertion-failures() {
|
# bail-now is how we terminate a test upon assertion failure.
|
||||||
|
# By default, and the vast majority of the time, it just triggers
|
||||||
|
# immediate test termination; but see defer-assertion-failures, below.
|
||||||
function bail-now() {
|
function bail-now() {
|
||||||
# "false" does not apply to "bail now"! It means "nonzero exit",
|
# "false" does not apply to "bail now"! It means "nonzero exit",
|
||||||
# which BATS interprets as "yes, bail immediately".
|
# which BATS interprets as "yes, bail immediately".
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Invoked on teardown: will terminate immediately if there have been
|
||||||
|
# any deferred test failures; otherwise will reset back to immediate
|
||||||
|
# test termination on future assertions.
|
||||||
|
function immediate-assertion-failures() {
|
||||||
|
function bail-now() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
# Any backlog?
|
# Any backlog?
|
||||||
if [[ -n "$ASSERTION_FAILURES" ]]; then
|
if [[ -n "$ASSERTION_FAILURES" ]]; then
|
||||||
local n=${#ASSERTION_FAILURES}
|
local n=${#ASSERTION_FAILURES}
|
||||||
@ -225,6 +235,9 @@ function immediate-assertion-failures() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Used in special test circumstances--typically multi-condition loops--to
|
||||||
|
# continue going even on assertion failures. The test will fail afterward,
|
||||||
|
# usually in teardown. This can be useful to show failure patterns.
|
||||||
function defer-assertion-failures() {
|
function defer-assertion-failures() {
|
||||||
function bail-now() {
|
function bail-now() {
|
||||||
ASSERTION_FAILURES+="!"
|
ASSERTION_FAILURES+="!"
|
||||||
|
Reference in New Issue
Block a user