Module Name:    src
Committed By:   schmonz
Date:           Tue Dec 27 12:09:19 UTC 2016

Modified Files:
        src/libexec/httpd/testsuite: html_cmp test-simple

Log Message:
When testing non-verbosely, show diff on failure. ok mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/libexec/httpd/testsuite/html_cmp
cvs rdiff -u -r1.2 -r1.3 src/libexec/httpd/testsuite/test-simple

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

Modified files:

Index: src/libexec/httpd/testsuite/html_cmp
diff -u src/libexec/httpd/testsuite/html_cmp:1.4 src/libexec/httpd/testsuite/html_cmp:1.5
--- src/libexec/httpd/testsuite/html_cmp:1.4	Fri Nov 18 09:51:31 2011
+++ src/libexec/httpd/testsuite/html_cmp	Tue Dec 27 12:09:19 2016
@@ -2,12 +2,20 @@
 #
 #	$eterna: html_cmp,v 1.9 2011/11/17 22:18:02 mrg Exp $
 #
-# like cmp(1) but compares to files after making their `Date: ' headers
-# the same, to allow `now' and `then' to work properly.  it also tries
-# to find servername's that might be the local host and converts those
-# as well..
+# like cmp(1)/diff(1) but compares to files after making their
+# `Date: ' headers the same, to allow `now' and `then' to work properly.
+# it also tries to find servername's that might be the local host and
+# converts those as well..
 #
-# it must be called like `cmp file1 file1' *only*.  
+# it must be called like `html_cmp cmp|diff file1 file1' *only*.
+
+if [ "cmp" = "$1" ]; then
+	cmd="cmp -s"
+elif [ "diff" = "$1" ]; then
+	cmd="diff -u"
+else
+	exit 77
+fi
 
 h=`hostname || uname -n`
 
@@ -17,10 +25,10 @@ sedcmd="s/^Date: .*/Date: nowish/;
 	s/^Server: .*/^Server: bozotic HTTP server version 5.08/;
 	s/^Content-Length: .*/Content-Length: 223/;"
 
-sed -e "$sedcmd" < "$1" > "f1.tmp.$$"
-sed -e "$sedcmd" < "$2" > "f2.tmp.$$"
+sed -e "$sedcmd" < "$2" > "f1.tmp.$$"
+sed -e "$sedcmd" < "$3" > "f2.tmp.$$"
 
-cmp -s "f1.tmp.$$" "f2.tmp.$$"
+${cmd} "f1.tmp.$$" "f2.tmp.$$"
 rv=$?
 rm -f "f1.tmp.$$" "f2.tmp.$$"
 

Index: src/libexec/httpd/testsuite/test-simple
diff -u src/libexec/httpd/testsuite/test-simple:1.2 src/libexec/httpd/testsuite/test-simple:1.3
--- src/libexec/httpd/testsuite/test-simple:1.2	Mon Sep 26 00:21:22 2016
+++ src/libexec/httpd/testsuite/test-simple	Tue Dec 27 12:09:19 2016
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: test-simple,v 1.2 2016/09/26 00:21:22 schmonz Exp $
+# $NetBSD: test-simple,v 1.3 2016/12/27 12:09:19 schmonz Exp $
 
 test="$1"
 bozohttpd="$2"
@@ -15,9 +15,9 @@ fi
 bozotestport=11111
 
 ${bozohttpd} ${datadir} < $test.in > tmp.$test.out
-if ./html_cmp $test.out tmp.$test.out; then
+if ./html_cmp cmp $test.out tmp.$test.out; then
 	exit 0
 else
-	[ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err; echo; cat $test.out`"
+	[ "yes" = "$verbose" ] || echo "Failed test $test: `cat tmp.$test.err; echo; ./html_cmp diff $test.out tmp.$test.out`"
 	exit 1
 fi

Reply via email to