Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint/lint1 tests/lint: add quotes around placeholde...



details:   https://anonhg.NetBSD.org/src/rev/65baf5827119
branches:  trunk
changeset: 367252:65baf5827119
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jun 19 11:50:42 2022 +0000

description:
tests/lint: add quotes around placeholders in a few messages

diffstat:

 tests/usr.bin/xlint/lint1/accept.sh        |  14 ++++++++------
 tests/usr.bin/xlint/lint1/check-expect.lua |   9 ++++++---
 tests/usr.bin/xlint/lint1/init.c           |   6 +++---
 tests/usr.bin/xlint/lint1/msg_024.c        |   6 +++---
 tests/usr.bin/xlint/lint1/msg_025.c        |   6 +++---
 tests/usr.bin/xlint/lint1/msg_026.c        |   6 +++---
 tests/usr.bin/xlint/lint1/msg_028.c        |   6 +++---
 tests/usr.bin/xlint/lint1/msg_029.c        |   6 +++---
 usr.bin/xlint/lint1/decl.c                 |  17 ++++++++---------
 usr.bin/xlint/lint1/err.c                  |  14 +++++++-------
 10 files changed, 47 insertions(+), 43 deletions(-)

diffs (283 lines):

diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/accept.sh
--- a/tests/usr.bin/xlint/lint1/accept.sh       Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/accept.sh       Sun Jun 19 11:50:42 2022 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: accept.sh,v 1.10 2022/06/17 20:23:58 rillig Exp $
+# $NetBSD: accept.sh,v 1.11 2022/06/19 11:50:42 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,11 +37,11 @@
 : "${archsubdir:=$(make -v ARCHSUBDIR)}"
 . './t_integration.sh'         # for configure_test_case
 
+done_tests=''
 for pattern in "$@"; do
        # shellcheck disable=SC2231
-       for test in *$pattern*.c; do
-               base=${test%.*}
-               cfile="$base.c"
+       for cfile in *$pattern*.c; do
+               base=${cfile%.*}
                expfile="$base.exp"
                ln_file="$base.exp-ln"
 
@@ -85,8 +85,10 @@
                                fi
                        fi
                esac
+
+               done_tests="$done_tests $cfile"
        done
 done
 
-# shellcheck disable=SC2035
-lua '../check-expect.lua' *.c
+# shellcheck disable=SC2086
+lua './check-expect.lua' $done_tests
diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/check-expect.lua
--- a/tests/usr.bin/xlint/lint1/check-expect.lua        Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/check-expect.lua        Sun Jun 19 11:50:42 2022 +0000
@@ -1,12 +1,12 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.1 2022/06/17 20:31:56 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.2 2022/06/19 11:50:42 rillig Exp $
 
 --[[
 
 usage: lua ./check-expect.lua *.c
 
 Check that the /* expect+-n: ... */ comments in the .c source files match the
-actual messages found in the corresponding .exp files.  The .exp files are 
+actual messages found in the corresponding .exp files.  The .exp files are
 expected in the current working directory.
 
 The .exp files are generated on the fly during the ATF tests, see
@@ -112,7 +112,10 @@
 local function load_exp(exp_fname)
 
   local lines = load_lines(exp_fname)
-  if lines == nil then return {} end
+  if lines == nil then
+    print_error("check-expect.lua: error: file " .. exp_fname .. " not found")
+    return
+  end
 
   local messages = {}
   for exp_lineno, line in ipairs(lines) do
diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/init.c
--- a/tests/usr.bin/xlint/lint1/init.c  Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/init.c  Sun Jun 19 11:50:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.11 2022/06/11 11:52:13 rillig Exp $ */
+/*     $NetBSD: init.c,v 1.12 2022/06/19 11:50:42 rillig Exp $ */
 # 3 "init.c"
 
 /*
@@ -108,14 +108,14 @@
 };
 
 
-/* expect+1: warning: cannot initialize extern declaration: extern_var [26] */
+/* expect+1: warning: cannot initialize extern declaration 'extern_var' [26] */
 extern int extern_var = 1;
 int defined_var = 1;
 /* expect+1: warning: static variable 'static_var' unused [226] */
 static int static_var = 1;
 /* expect+1: error: illegal storage class [8] */
 register int register_var = 1;
-/* expect+1: error: cannot initialize typedef: typedef_var [25] */
+/* expect+1: error: cannot initialize typedef 'typedef_var' [25] */
 typedef int typedef_var = 1;
 
 
diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/msg_024.c
--- a/tests/usr.bin/xlint/lint1/msg_024.c       Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_024.c       Sun Jun 19 11:50:42 2022 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_024.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
+/*     $NetBSD: msg_024.c,v 1.4 2022/06/19 11:50:42 rillig Exp $       */
 # 3 "msg_024.c"
 
-// Test for message: cannot initialize function: %s [24]
+// Test for message: cannot initialize function '%s' [24]
 
 typedef void (function)(void);
 
@@ -10,7 +10,7 @@
 {
 }
 
-/* expect+3: error: cannot initialize function: fn [24] */
+/* expect+3: error: cannot initialize function 'fn' [24] */
 /* The following message is strange but does not occur in practice. */
 /* expect+1: error: {}-enclosed initializer required [181] */
 function fn = definition;
diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/msg_025.c
--- a/tests/usr.bin/xlint/lint1/msg_025.c       Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_025.c       Sun Jun 19 11:50:42 2022 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_025.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
+/*     $NetBSD: msg_025.c,v 1.4 2022/06/19 11:50:42 rillig Exp $       */
 # 3 "msg_025.c"
 
-// Test for message: cannot initialize typedef: %s [25]
+// Test for message: cannot initialize typedef '%s' [25]
 
-/* expect+1: error: cannot initialize typedef: number [25] */
+/* expect+1: error: cannot initialize typedef 'number' [25] */
 typedef int number = 3;
diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/msg_026.c
--- a/tests/usr.bin/xlint/lint1/msg_026.c       Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_026.c       Sun Jun 19 11:50:42 2022 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: msg_026.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
+/*     $NetBSD: msg_026.c,v 1.4 2022/06/19 11:50:42 rillig Exp $       */
 # 3 "msg_026.c"
 
-// Test for message: cannot initialize extern declaration: %s [26]
+// Test for message: cannot initialize extern declaration '%s' [26]
 
-/* expect+1: warning: cannot initialize extern declaration: used [26] */
+/* expect+1: warning: cannot initialize extern declaration 'used' [26] */
 extern int used = 1;
 int defined = 1;
diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/msg_028.c
--- a/tests/usr.bin/xlint/lint1/msg_028.c       Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_028.c       Sun Jun 19 11:50:42 2022 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_028.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
+/*     $NetBSD: msg_028.c,v 1.4 2022/06/19 11:50:42 rillig Exp $       */
 # 3 "msg_028.c"
 
-// Test for message: redefinition of %s [28]
+// Test for message: redefinition of '%s' [28]
 
 int
 defined(int arg)
@@ -11,7 +11,7 @@
 
 int
 defined(int arg)
-/* expect+1: error: redefinition of defined [28] */
+/* expect+1: error: redefinition of 'defined' [28] */
 {
        return arg;
 }
diff -r 529dc57839b3 -r 65baf5827119 tests/usr.bin/xlint/lint1/msg_029.c
--- a/tests/usr.bin/xlint/lint1/msg_029.c       Sun Jun 19 11:31:19 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_029.c       Sun Jun 19 11:50:42 2022 +0000
@@ -1,12 +1,12 @@
-/*     $NetBSD: msg_029.c,v 1.4 2022/06/15 20:18:31 rillig Exp $       */
+/*     $NetBSD: msg_029.c,v 1.5 2022/06/19 11:50:42 rillig Exp $       */
 # 3 "msg_029.c"
 
-// Test for message: previously declared extern, becomes static: %s [29]
+// Test for message: '%s' was previously declared extern, becomes static [29]
 
 extern int function(void);
 
 static int function(void)
-/* expect+1: warning: previously declared extern, becomes static: function [29] */
+/* expect+1: warning: 'function' was previously declared extern, becomes static [29] */
 {
        return function();
 }
diff -r 529dc57839b3 -r 65baf5827119 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sun Jun 19 11:31:19 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Jun 19 11:50:42 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.287 2022/06/15 18:06:51 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.288 2022/06/19 11:50:42 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.287 2022/06/15 18:06:51 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.288 2022/06/19 11:50:42 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -2132,7 +2132,7 @@
                return true;
        }
        if (rsym->s_def == DEF && dsym->s_def == DEF) {
-               /* redefinition of %s */
+               /* redefinition of '%s' */
                error(28, dsym->s_name);
                print_previous_declaration(-1, rsym);
                return true;
@@ -2161,7 +2161,7 @@
                return true;
        }
        if (rsym->s_scl == EXTERN) {
-               /* previously declared extern, becomes static: %s */
+               /* '%s' was previously declared extern, becomes static */
                warning(29, dsym->s_name);
                print_previous_declaration(-1, rsym);
                return false;
@@ -2879,20 +2879,19 @@
        erred = false;
 
        if (sym->s_type->t_tspec == FUNC) {
-               /* cannot initialize function: %s */
+               /* cannot initialize function '%s' */
                error(24, sym->s_name);
                erred = true;
        } else if (sym->s_scl == TYPEDEF) {
-               /* cannot initialize typedef: %s */
+               /* cannot initialize typedef '%s' */
                error(25, sym->s_name);
                erred = true;
        } else if (sym->s_scl == EXTERN && sym->s_def == DECL) {
-               /* cannot initialize "extern" declaration: %s */
                if (dcs->d_kind == DK_EXTERN) {
-                       /* cannot initialize extern declaration: %s */
+                       /* cannot initialize extern declaration '%s' */
                        warning(26, sym->s_name);
                } else {
-                       /* cannot initialize extern declaration: %s */
+                       /* cannot initialize extern declaration '%s' */
                        error(26, sym->s_name);
                        erred = true;
                }
diff -r 529dc57839b3 -r 65baf5827119 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Jun 19 11:31:19 2022 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Jun 19 11:50:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.170 2022/06/15 18:06:51 rillig Exp $ */
+/*     $NetBSD: err.c,v 1.171 2022/06/19 11:50:42 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.170 2022/06/15 18:06:51 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.171 2022/06/19 11:50:42 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -78,12 +78,12 @@
        "redeclaration of formal parameter '%s'",                     /* 21 */
        "incomplete or misplaced function definition",                /* 22 */
        "undefined label '%s'",                                       /* 23 */
-       "cannot initialize function: %s",                             /* 24 */
-       "cannot initialize typedef: %s",                              /* 25 */
-       "cannot initialize extern declaration: %s",                   /* 26 */
+       "cannot initialize function '%s'",                            /* 24 */
+       "cannot initialize typedef '%s'",                             /* 25 */
+       "cannot initialize extern declaration '%s'",                  /* 26 */
        "redeclaration of '%s'",                                      /* 27 */
-       "redefinition of %s",                                         /* 28 */
-       "previously declared extern, becomes static: %s",             /* 29 */
+       "redefinition of '%s'",                                       /* 28 */
+       "'%s' was previously declared extern, becomes static",        /* 29 */
        "redeclaration of '%s'; ANSI C requires static",              /* 30 */
        "'%s' has incomplete type '%s'",                              /* 31 */
        "argument type defaults to 'int': %s",                        /* 32 */



Home | Main Index | Thread Index | Old Index