Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 lint: fix integration test



details:   https://anonhg.NetBSD.org/src/rev/e775c2d8b3b0
branches:  trunk
changeset: 949143:e775c2d8b3b0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 02 19:22:42 2021 +0000

description:
lint: fix integration test

The body of an ATF test must never return 1 but instead report failure
via atf_fail.  Otherwise the following error message appears:

    Failed: Test case body returned a non-ok exit code, but this is
    not allowed

The test program t_integration intentionally bypasses the official ATF
API for performance reasons.  But even then, it should stick to the API
as close as possible.

diffstat:

 tests/usr.bin/xlint/lint1/t_integration.sh |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (35 lines):

diff -r b17ffe043531 -r e775c2d8b3b0 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh        Sat Jan 02 18:44:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh        Sat Jan 02 19:22:42 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.19 2021/01/02 11:12:34 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.20 2021/01/02 19:22:42 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -147,10 +147,10 @@
 
 test_case all_messages
 all_messages_body() {
-       local srcdir status msg base flags
+       local srcdir ok msg base flags
 
        srcdir="$(atf_get_srcdir)"
-       status="0"
+       ok="true"
 
        for msg in $(seq 0 329); do
                base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
@@ -160,9 +160,10 @@
                # shellcheck disable=SC2154 disable=SC2086
                ${Atf_Check} -s not-exit:0 -o "file:${base}.exp" -e empty \
                    ${LINT1} ${flags} "${base}.c" /dev/null \
-               || status="1"
+               || ok="false"
        done
-       return "${status}"
+
+       atf_check "${ok}"
 }
 
 



Home | Main Index | Thread Index | Old Index