Skip to content

Commit ecb2cf6

Browse files
committed
tests/lint: run lint1 tests in one fell swoop
This generates fewer details in the ATF test reports, as the platform-specific tests that are skipped are not mentioned individually.
1 parent 5685e47 commit ecb2cf6

2 files changed

Lines changed: 34 additions & 27 deletions

File tree

tests/usr.bin/xlint/lint1/check-expect.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /usr/bin/lua
2-
-- $NetBSD: check-expect.lua,v 1.12 2024/01/28 08:54:27 rillig Exp $
2+
-- $NetBSD: check-expect.lua,v 1.13 2025/01/03 02:14:52 rillig Exp $
33

44
--[[
55
@@ -278,13 +278,17 @@ end
278278

279279

280280
local function main(args)
281-
local update = args[1] == "-u"
282-
if update then
283-
table.remove(args, 1)
281+
local update = false
282+
for _, arg in ipairs(args) do
283+
if arg == "-u" then
284+
update = true
285+
end
284286
end
285287

286288
for _, name in ipairs(args) do
287-
check_test(name, update)
289+
if name ~= "-u" then
290+
check_test(name, update)
291+
end
288292
end
289293
end
290294

tests/usr.bin/xlint/lint1/t_integration.sh

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: t_integration.sh,v 1.84 2024/06/08 06:42:59 rillig Exp $
1+
# $NetBSD: t_integration.sh,v 1.85 2025/01/03 02:14:52 rillig Exp $
22
#
33
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
44
# All rights reserved.
@@ -28,6 +28,7 @@
2828
: "${lint1:=/usr/libexec/lint1}"
2929
: "${archsubdir:=archsubdir_must_be_set}"
3030

31+
srcdir="$(atf_get_srcdir)"
3132

3233
configure_test_case()
3334
{
@@ -113,13 +114,14 @@ configure_test_case()
113114
export LC_ALL
114115
}
115116

116-
# shellcheck disable=SC2155
117+
tests_done=''
117118
check_lint1()
118119
{
119-
local src="$(atf_get_srcdir)/$1"
120-
local exp="${1%.c}.exp"
120+
local src="$1"
121+
local base="${src##*/}"
122+
local exp="${base%.c}.exp"
121123
local exp_ln="${src%.c}.exp-ln"
122-
local wrk_ln="${1%.c}.ln"
124+
local wrk_ln="${base%.c}.ln"
123125
local flags=""
124126
local skip=""
125127

@@ -131,13 +133,13 @@ check_lint1()
131133
configure_test_case "$src" # sets 'skip' and 'flags'
132134

133135
if [ "$skip" = "yes" ]; then
134-
atf_skip "unsuitable platform"
136+
return
135137
fi
138+
tests_done="$tests_done $src"
136139

137140
# shellcheck disable=SC2086
138141
atf_check -s 'exit' -o "save:$exp" \
139142
"$lint1" $flags "$src" "$wrk_ln"
140-
atf_check lua "$(atf_get_srcdir)/check-expect.lua" "$src"
141143

142144
if [ "$exp_ln" != '/dev/null' ]; then
143145
# Remove comments and whitespace from the .exp-ln file.
@@ -152,21 +154,22 @@ check_lint1()
152154
fi
153155
}
154156

157+
atf_test_case lint1
158+
lint1_head() {
159+
atf_set 'require.progs' "$lint1"
160+
}
161+
lint1_body() {
162+
local src
163+
164+
for src in "$srcdir"/*.c; do
165+
check_lint1 "$src"
166+
done
167+
168+
# shellcheck disable=SC2086
169+
atf_check lua "$srcdir/check-expect.lua" $tests_done
170+
}
171+
155172
atf_init_test_cases()
156173
{
157-
local src name
158-
159-
for src in "$(atf_get_srcdir)"/*.c; do
160-
src=${src##*/}
161-
name=${src%.c}
162-
163-
atf_test_case "$name"
164-
eval "${name}_head() {
165-
atf_set 'require.progs' '$lint1'
166-
}"
167-
eval "${name}_body() {
168-
check_lint1 '$name.c'
169-
}"
170-
atf_add_test_case "$name"
171-
done
174+
atf_add_test_case lint1
172175
}

0 commit comments

Comments
 (0)