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 tests/lint: fix preprocessor line ...



details:   https://anonhg.NetBSD.org/src/rev/e82fe7f74c18
branches:  trunk
changeset: 376685:e82fe7f74c18
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jun 28 17:53:21 2023 +0000

description:
tests/lint: fix preprocessor line number validation

When running the tests via ATF, the filename was an absolute filename,
while the preprocessing line in the test file uses a relative filename.
These two didn't match.

diffstat:

 tests/usr.bin/xlint/lint1/check-expect.lua |  6 +++---
 tests/usr.bin/xlint/lint1/msg_351.c        |  4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diffs (46 lines):

diff -r 89900473ac81 -r e82fe7f74c18 tests/usr.bin/xlint/lint1/check-expect.lua
--- a/tests/usr.bin/xlint/lint1/check-expect.lua        Wed Jun 28 15:04:07 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/check-expect.lua        Wed Jun 28 17:53:21 2023 +0000
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.2 2022/06/19 11:50:42 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.3 2023/06/28 17:53:21 rillig Exp $
 
 --[[
 
@@ -58,7 +58,7 @@ end
 --   },
 --   { "file.c(18)", "file.c(23)" }
 local function load_c(fname)
-
+  local basename = fname:match("([^/]+)$") or fname
   local lines = load_lines(fname)
   if lines == nil then return nil, nil end
 
@@ -87,7 +87,7 @@ local function load_c(fname)
 
     local ppl_lineno, ppl_fname = line:match("^#%s*(%d+)%s+\"([^\"]+)\"")
     if ppl_lineno ~= nil then
-      if ppl_fname == fname and tonumber(ppl_lineno) ~= phys_lineno + 1 then
+      if ppl_fname == basename and tonumber(ppl_lineno) ~= phys_lineno + 1 then
         print_error("error: %s:%d: preprocessor line number must be %d",
           fname, phys_lineno, phys_lineno + 1)
       end
diff -r 89900473ac81 -r e82fe7f74c18 tests/usr.bin/xlint/lint1/msg_351.c
--- a/tests/usr.bin/xlint/lint1/msg_351.c       Wed Jun 28 15:04:07 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_351.c       Wed Jun 28 17:53:21 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_351.c,v 1.4 2023/04/25 19:00:57 rillig Exp $       */
+/*     $NetBSD: msg_351.c,v 1.5 2023/06/28 17:53:21 rillig Exp $       */
 # 3 "msg_351.c"
 
 // Test for message 351: missing%s header declaration for '%s' [351]
@@ -39,7 +39,7 @@ static int static_func_def(void);
 int extern_func_decl(void);
 extern int extern_func_decl_verbose(void);
 
-# 29 "msg_351.c" 2
+# 43 "msg_351.c" 2
 /* expect+1: warning: static variable 'static_def' unused [226] */
 static int static_def;
 int external_def;



Home | Main Index | Thread Index | Old Index