浏览代码

Rewritten

Sergey Poznyakoff 21 年之前
父节点
当前提交
d584c1ed0f
共有 3 个文件被更改,包括 65 次插入37 次删除
  1. 29 2
      tests/after
  2. 22 26
      tests/before
  3. 14 9
      tests/preset.in

+ 29 - 2
tests/after

@@ -4,6 +4,33 @@
 cd ..
 exec 1> /dev/null
 exec 2> /dev/null
-echo $echo_n "$out$echo_c" | cmp -s - tmp-$$/stdout || exit 1
-echo $echo_n "$err$echo_c" | cmp -s - tmp-$$/stderr || exit 1
+
+compare() {
+    eval tempfile=tmp-$$/std${1}
+    eval echo \""\${$1}"\" | sed '$d' > ${tempfile}0
+    
+    sedscript=tmp-$$/${1}.sed
+    if eval test \".\${${1}_ignore}\" = .; then
+	:
+    else
+	eval echo \"\${${1}_ignore}\" | sed 's,^.*$,/&/d,;' > $sedscript
+	sed -f $sedscript ${tempfile} > ${tempfile}.1
+	mv ${tempfile}.1 ${tempfile}
+    fi
+    
+    if eval test -z "\${${1}_regex}" ; then
+	cmp -s ${tempfile}0 ${tempfile} || exit 1
+    else
+	awk '{print NR " " $0}' ${tempfile}0 > ${tempfile}.1
+	awk '{print NR " " $0}' ${tempfile} | join ${tempfile}.1 - |
+	while read NUM RE LINE
+	do
+	  echo "$LINE" | grep -- "$RE" >/dev/null || exit 1
+	done 
+    fi
+}
+
+compare out
+compare err
+
 rm -rf tmp-$$

+ 22 - 26
tests/before

@@ -1,38 +1,34 @@
 #! /bin/sh
 # Do common operations before a particular test.
 
+case $# in
+    0)   TAR_ARCHIVE_FORMATS=${TAR_ARCHIVE_FORMATS:-v7 oldgnu ustar posix gnu}
+         for format in $TAR_ARCHIVE_FORMATS
+         do
+	     $0 $format
+	     R=$?
+	     test $R -eq 0 || exit $R
+	 done
+	 exit 0;;
+    1)   if test "x$1" = xauto; then
+            TAR_OPTIONS=
+	 else    
+            TAR_OPTIONS="--format=$1"
+	 fi;;   
+    *)   echo "Too many arguments" >&2 
+         exit 2;;
+esac    
+
 mkdir tmp-$$
 cd tmp-$$
 
-case $srcdir in
-  /*|~*) ;;
-  *) srcdir=../$srcdir ;;
-esac
-
 out=
 err=
 
-echo $0 > checking
+export TAR_OPTIONS
+#echo "$0 $1"
+echo "$0 $1" > checking
 exec 1> stdout
 exec 2> stderr
 
-PATH=..:../../src:$PATH
-    
-prereq() {
-    if test $# -ne 0; then
-        case $TAR_OPTIONS in
-            --format=*)   FMTOPT=$TAR_OPTIONS;;
-            *)            FMTOPT=`tar --show-defaults`;;
-        esac
-
-        FORMAT=
-        for option
-        do
-            case $FMTOPT in
-                --format=$option*) FORMAT=$option
-       	                           break;;
-            esac
-        done
-        test -z "$FORMAT" && exit 77
-    fi
-}
+	    

+ 14 - 9
tests/preset.in

@@ -3,15 +3,20 @@
 
 PACKAGE=@PACKAGE@
 VERSION=@VERSION@
-top_srcdir=@top_srcdir@
-srcdir=@srcdir@
-
-echo_n='@ECHO_N@'
-echo_c='@ECHO_C@'
+top_srcdir=@abs_top_srcdir@
+srcdir=@abs_srcdir@
+PATH=@abs_builddir@:@abs_top_builddir@/src:$top_srcdir:$srcdir:$PATH
 
 export LANGUAGE
 LANGUAGE=
-export LANG
-LANG=
-export LC_MESSAGES
-LC_MESSAGES=
+export LC_ALL
+LC_ALL="C"
+
+skiptest() {
+    exit 77
+}
+
+star_prereq() {
+    test -z "$STAR_TESTSCRIPTS" && skiptest
+    test -r "$STAR_TESTSCRIPTS/$1" || skiptest
+}