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: allow custom flags to be spe...
details: https://anonhg.NetBSD.org/src/rev/e2deea70c48a
branches: trunk
changeset: 958570:e2deea70c48a
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 10 21:26:12 2021 +0000
description:
lint: allow custom flags to be specified in all unit tests
Previously, only the tests called msg_*.c could use this feature. Since
it is useful for other tests as well, enable it everywhere.
diffstat:
tests/usr.bin/xlint/lint1/t_integration.sh | 51 ++++++++++++++++++-----------
1 files changed, 31 insertions(+), 20 deletions(-)
diffs (83 lines):
diff -r 4defdb611b27 -r e2deea70c48a tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jan 10 21:20:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jan 10 21:26:12 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.24 2021/01/10 18:06:38 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.25 2021/01/10 21:26:12 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -29,17 +29,44 @@
Names=
+extract_flags()
+{
+ local extract_flags_awk
+
+ # shellcheck disable=SC2016
+ extract_flags_awk='
+ BEGIN {
+ flags = "-g -S -w"
+ }
+ /^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ {
+ if ($2 == "lint1-flags:")
+ flags = ""
+ for (i = 3; i < NF; i++)
+ flags = flags " " $i
+ }
+ END {
+ print flags
+ }
+ '
+
+ awk "$extract_flags_awk" "$@"
+}
+
+# shellcheck disable=SC2155
check_lint1()
{
local src="$(atf_get_srcdir)/$1"
local exp="${src%.c}.exp"
+ local flags="$(extract_flags "${src}")"
if [ -f "${exp}" ]; then
+ # shellcheck disable=SC2086
atf_check -s not-exit:0 -o "file:${exp}" -e empty \
- ${LINT1} -g -S -w "${src}" /dev/null
+ ${LINT1} ${flags} "${src}" /dev/null
else
+ # shellcheck disable=SC2086
atf_check -s exit:0 \
- ${LINT1} -g -S -w "${src}" /dev/null
+ ${LINT1} ${flags} "${src}" /dev/null
fi
}
@@ -155,25 +182,9 @@
srcdir="$(atf_get_srcdir)"
ok="true"
- # shellcheck disable=SC2016
- extract_flags_awk='
- BEGIN {
- flags = "-g -S -w"
- }
- /^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ {
- if ($2 == "lint1-flags:")
- flags = ""
- for (i = 3; i < NF; i++)
- flags = flags " " $i
- }
- END {
- print flags
- }
- '
-
for msg in $(seq 0 329); do
base="$(printf '%s/msg_%03d' "${srcdir}" "${msg}")"
- flags="$(awk "$extract_flags_awk" "${base}.c")"
+ flags="$(extract_flags "${base}.c")"
# shellcheck disable=SC2154 disable=SC2086
${Atf_Check} -s not-exit:0 -o "file:${base}.exp" -e empty \
Home |
Main Index |
Thread Index |
Old Index