Re: [PATCH 12/12] t: detect errors outside of test cases
Patrick Steinhardt <ps@pks.im> writes:
Show 27 quoted lines
> We have recently merged a patch series that had a simple misspelling of
> `test_expect_success`. Instead of making our tests fail though, this
> typo went completely undetected and all of our tests passed, which is of
> course unfortunate. This is a more general issue with our test suite:
> all commands that run outside of a specific test case can fail, and if
> we don't explicitly check for such failure then this failure will be
> silently ignored.
>
> Improve the status quo by enabling the errexit option so that any such
> unchecked failures will cause us to abort immediately.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> t/test-lib.sh | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 81380fe978..c493e3c768 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -15,6 +15,10 @@
> # You should have received a copy of the GNU General Public License
> # along with this program. If not, see https://www.gnu.org/licenses/ .
>
> +# Enable the use of errexit so that any unexpected failures will cause us to
> +# abort tests, even when outside of a specific test case.
> +set -e
> # Test the binaries we have just built. The tests are kept in
> # t/ subdirectory and are run in 'trash directory' subdirectory.
> if test -z "$TEST_DIRECTORY"