pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/regress/tools
Module Name: pkgsrc
Committed By: rillig
Date: Fri Mar 22 20:56:16 UTC 2019
Modified Files:
pkgsrc/regress/tools: Makefile
pkgsrc/regress/tools/files: tests.subr
Added Files:
pkgsrc/regress/tools/files: logging-test.sh
Log Message:
regress/tools: demonstrate wrong quoting in tools wrapper logging
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 pkgsrc/regress/tools/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/regress/tools/files/logging-test.sh
cvs rdiff -u -r1.2 -r1.3 pkgsrc/regress/tools/files/tests.subr
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/regress/tools/Makefile
diff -u pkgsrc/regress/tools/Makefile:1.10 pkgsrc/regress/tools/Makefile:1.11
--- pkgsrc/regress/tools/Makefile:1.10 Sat Jun 11 11:36:14 2016
+++ pkgsrc/regress/tools/Makefile Fri Mar 22 20:56:16 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2016/06/11 11:36:14 rillig Exp $
+# $NetBSD: Makefile,v 1.11 2019/03/22 20:56:16 rillig Exp $
#
DISTNAME= # not applicable
@@ -14,7 +14,8 @@ LICENSE= 2-clause-bsd
WRKSRC= ${WRKDIR}
NO_CHECKSUM= yes
PLIST_SRC= # none
-REGRESS_TESTS= awk sed sh sort tar tr
+REGRESS_TESTS+= logging
+REGRESS_TESTS+= awk sed sh sort tar tr
USE_TOOLS+= awk sed sh sort tar tr
do-build:
Index: pkgsrc/regress/tools/files/tests.subr
diff -u pkgsrc/regress/tools/files/tests.subr:1.2 pkgsrc/regress/tools/files/tests.subr:1.3
--- pkgsrc/regress/tools/files/tests.subr:1.2 Thu Nov 24 19:20:18 2005
+++ pkgsrc/regress/tools/files/tests.subr Fri Mar 22 20:56:16 2019
@@ -1,4 +1,4 @@
-# $NetBSD: tests.subr,v 1.2 2005/11/24 19:20:18 rillig Exp $
+# $NetBSD: tests.subr,v 1.3 2019/03/22 20:56:16 rillig Exp $
#
# usage: testcase_start <testname>
@@ -8,9 +8,7 @@ testcase_start() {
# usage: assert_equal <testname> <expected> <got>
assert_equal() {
- case $2 in
- "$3") ;;
- *) echo "[assert_equal:$1] expected \"$2\", got \"$3\"." 1>&2
- return 1;;
- esac
+ [ "x$2" = "x$3" ] && return 0
+ printf "error: assert_equal failed for %s:\nexpected: %s\nbut got: %s\n" "$1" "$2" "$3" 1>&2
+ return 1
}
Added files:
Index: pkgsrc/regress/tools/files/logging-test.sh
diff -u /dev/null pkgsrc/regress/tools/files/logging-test.sh:1.1
--- /dev/null Fri Mar 22 20:56:16 2019
+++ pkgsrc/regress/tools/files/logging-test.sh Fri Mar 22 20:56:16 2019
@@ -0,0 +1,41 @@
+#! /bin/sh
+# $NetBSD: logging-test.sh,v 1.1 2019/03/22 20:56:16 rillig Exp $
+
+# Up to March 2019, the command logging for the wrapped tools didn't properly
+# quote the command line arguments. This meant the logging did not reflect
+# the actual tool command line.
+
+set -eu
+
+mydir=`dirname "$0"`
+. "${mydir}/tests.subr"
+
+tools_log="./tools.log"
+nopath_log="./nopath.log"
+
+rm -f "$tools_log" "$nopath_log"
+
+TOOLS_WRAPPER_LOG="$tools_log"
+export TOOLS_WRAPPER_LOG
+
+# Forcibly call the echo from the tools directory. This tool is wrapped and
+# logged.
+(exec echo "begin" "*" "*" "*" "end")
+
+unset TOOLS_WRAPPER_LOG
+
+# usage: assert_file_equals $filename <<EOF ... EOF
+assert_file_equals() {
+ actual=`cat "$1"`
+ expected=`cat`
+ assert_equal "$1" "$expected" "$actual"
+}
+
+sed 's,/.*/\.tools/,WRKDIR/.tools/,' < "$tools_log" > "$nopath_log"
+
+assert_file_equals "$nopath_log" <<EOF
+[*] WRKDIR/.tools/bin/echo begin * * * end
+<.> echo begin tools.log tools.log tools.log end
+EOF
+# FIXME: the above output is not quoted correctly.
+# The tools.log should not appear there.
Home |
Main Index |
Thread Index |
Old Index