Module Name: src Committed By: rillig Date: Tue Jun 29 09:44:25 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: Makefile Added Files: src/tests/usr.bin/xlint/lint1: accept.sh Log Message: tests/lint: add 'make accept' to update the expected output To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/accept.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/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.69 src/tests/usr.bin/xlint/lint1/Makefile:1.70 --- src/tests/usr.bin/xlint/lint1/Makefile:1.69 Tue Jun 29 09:19:17 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Tue Jun 29 09:44:25 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.69 2021/06/29 09:19:17 rillig Exp $ +# $NetBSD: Makefile,v 1.70 2021/06/29 09:44:25 rillig Exp $ NOMAN= # defined MAX_MESSAGE= 345 # see lint1/err.c @@ -161,4 +161,7 @@ sync-mi: .PHONY mv "$$mi.tmp" "$$mi"; \ cvs diff "$$mi" || true +accept: .PHONY + @sh ./accept.sh '' + .include <bsd.test.mk> Added files: Index: src/tests/usr.bin/xlint/lint1/accept.sh diff -u /dev/null src/tests/usr.bin/xlint/lint1/accept.sh:1.1 --- /dev/null Tue Jun 29 09:44:25 2021 +++ src/tests/usr.bin/xlint/lint1/accept.sh Tue Jun 29 09:44:25 2021 @@ -0,0 +1,90 @@ +#! /bin/sh +# $NetBSD: accept.sh,v 1.1 2021/06/29 09:44:25 rillig Exp $ +# +# Copyright (c) 2021 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# usage: accept.sh <pattern>... +# +# Accept the actual output from running the lint tests and save them +# back into the .exp files. + +set -eu + +. './t_integration.sh' + +for pattern in "$@"; do + for test in *$pattern*.c; do + base=${test%.*} + cfile="$base.c" + expfile="$base.exp" + tmpfile="$base.exp.tmp" + ln_file="$base.ln" + + configure_test_case "$cfile" + if [ $skip = yes ]; then + continue + fi + + if [ ! -f "$ln_file" ]; then + ln_file='/dev/null' + fi + + if "$lint1" $flags "$base.c" "$ln_file" > "$tmpfile"; then + if [ -s "$tmpfile" ]; then + echo "$base produces output but exits successfully" + sed 's,^,| ,' "$tmpfile" + fi + rm -f "$expfile" "$tmpfile" + else + if [ -f "$tmpfile" ] && cmp -s "$tmpfile" "$expfile"; then + rm "$tmpfile" + else + echo "replacing $base" + mv "$tmpfile" "$expfile" + fi + fi + + case "$base" in (msg_*) + if [ ! -f "$expfile" ]; then + echo "$base should produce warnings" + elif grep '^TODO: "Add example code' "$base.c" >/dev/null; then + : 'ok, this test is not yet written' + else + msgid=${base} + msgid=${msgid#msg_00} + msgid=${msgid#msg_0} + msgid=${msgid#msg_} + msgid=${msgid%_*} + if ! grep "\\[$msgid\\]" "$expfile" >/dev/null; then + echo "$base should trigger the message '$msgid'" + fi + fi + esac + + done +done + +lua '../check-expect.lua' *.c