Module Name:    src
Committed By:   rillig
Date:           Fri Jan  3 02:14:52 UTC 2025

Modified Files:
        src/tests/usr.bin/xlint/lint1: check-expect.lua t_integration.sh

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/check-expect.lua
cvs rdiff -u -r1.84 -r1.85 src/tests/usr.bin/xlint/lint1/t_integration.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/check-expect.lua
diff -u src/tests/usr.bin/xlint/lint1/check-expect.lua:1.12 src/tests/usr.bin/xlint/lint1/check-expect.lua:1.13
--- src/tests/usr.bin/xlint/lint1/check-expect.lua:1.12	Sun Jan 28 08:54:27 2024
+++ src/tests/usr.bin/xlint/lint1/check-expect.lua	Fri Jan  3 02:14:52 2025
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.12 2024/01/28 08:54:27 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.13 2025/01/03 02:14:52 rillig Exp $
 
 --[[
 
@@ -278,13 +278,17 @@ end
 
 
 local function main(args)
-  local update = args[1] == "-u"
-  if update then
-    table.remove(args, 1)
+  local update = false
+  for _, arg in ipairs(args) do
+    if arg == "-u" then
+      update = true
+    end
   end
 
   for _, name in ipairs(args) do
-    check_test(name, update)
+    if name ~= "-u" then
+      check_test(name, update)
+    end
   end
 end
 

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.84 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.85
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.84	Sat Jun  8 06:42:59 2024
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Fri Jan  3 02:14:52 2025
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.84 2024/06/08 06:42:59 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.85 2025/01/03 02:14:52 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -28,6 +28,7 @@
 : "${lint1:=/usr/libexec/lint1}"
 : "${archsubdir:=archsubdir_must_be_set}"
 
+srcdir="$(atf_get_srcdir)"
 
 configure_test_case()
 {
@@ -113,13 +114,14 @@ configure_test_case()
 	export LC_ALL
 }
 
-# shellcheck disable=SC2155
+tests_done=''
 check_lint1()
 {
-	local src="$(atf_get_srcdir)/$1"
-	local exp="${1%.c}.exp"
+	local src="$1"
+	local base="${src##*/}"
+	local exp="${base%.c}.exp"
 	local exp_ln="${src%.c}.exp-ln"
-	local wrk_ln="${1%.c}.ln"
+	local wrk_ln="${base%.c}.ln"
 	local flags=""
 	local skip=""
 
@@ -131,13 +133,13 @@ check_lint1()
 	configure_test_case "$src"	# sets 'skip' and 'flags'
 
 	if [ "$skip" = "yes" ]; then
-		atf_skip "unsuitable platform"
+		return
 	fi
+	tests_done="$tests_done $src"
 
 	# shellcheck disable=SC2086
 	atf_check -s 'exit' -o "save:$exp" \
 	    "$lint1" $flags "$src" "$wrk_ln"
-	atf_check lua "$(atf_get_srcdir)/check-expect.lua" "$src"
 
 	if [ "$exp_ln" != '/dev/null' ]; then
 		# Remove comments and whitespace from the .exp-ln file.
@@ -152,21 +154,22 @@ check_lint1()
 	fi
 }
 
-atf_init_test_cases()
-{
-	local src name
+atf_test_case lint1
+lint1_head() {
+	atf_set 'require.progs' "$lint1"
+}
+lint1_body() {
+	local src
 
-	for src in "$(atf_get_srcdir)"/*.c; do
-		src=${src##*/}
-		name=${src%.c}
-
-		atf_test_case "$name"
-		eval "${name}_head() {
-			atf_set 'require.progs' '$lint1'
-		}"
-		eval "${name}_body() {
-			check_lint1 '$name.c'
-		}"
-		atf_add_test_case "$name"
+	for src in "$srcdir"/*.c; do
+		check_lint1 "$src"
 	done
+
+	# shellcheck disable=SC2086
+	atf_check lua "$srcdir/check-expect.lua" $tests_done
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case lint1
 }

Reply via email to