From: Robert Fairley Date: Thu, 5 Jul 2018 16:30:05 +0000 (-0400) Subject: tests: Move assert_fail function to tests/libtest.sh X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~21^2~15 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4f096c8f11c06883c5eec03c0ad6d962f3d82a4d;p=ostree.git tests: Move assert_fail function to tests/libtest.sh This moves the assert_fail function definition which was defined and called in tests/test-remote-headers.sh. Done in preparation for use of the assert_fail function in other test files. Closes: #1669 Approved by: jlebon --- diff --git a/tests/libtest.sh b/tests/libtest.sh index 388408df..f09f4a2c 100755 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -648,3 +648,12 @@ assert_not_ref () { fatal "rev-parse $2 unexpectedly succeeded!" fi } + +assert_fail () { + set +e + $@ + if [ $? = 0 ] ; then + echo 1>&2 "$@ did not fail"; exit 1 + fi + set -euo pipefail +} diff --git a/tests/test-remote-headers.sh b/tests/test-remote-headers.sh index a4ee386f..a41d087a 100755 --- a/tests/test-remote-headers.sh +++ b/tests/test-remote-headers.sh @@ -33,15 +33,6 @@ setup_fake_remote_repo1 "archive" "" \ --expected-header baz=badger \ --expected-header "User-Agent=libostree/$V dodo/2.15" -assert_fail (){ - set +e - $@ - if [ $? = 0 ] ; then - echo 1>&2 "$@ did not fail"; exit 1 - fi - set -euo pipefail -} - cd ${test_tmpdir} rm repo -rf mkdir repo