/[cvs]/ccvs/src/sanity.sh
ViewVC logotype

Diff of /ccvs/src/sanity.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1094 by mdb, Wed Oct 5 00:47:37 2005 UTC revision 1.1095 by dprice, Wed Oct 5 02:40:05 2005 UTC
# Line 723  tempname=$TMPDIR/$tempfile Line 723  tempname=$TMPDIR/$tempfile
723  # Make sure various tools work the way we expect, or try to find  # Make sure various tools work the way we expect, or try to find
724  # versions that do.  # versions that do.
725  : ${AWK=awk}  : ${AWK=awk}
726    : ${DIFF=diff}
727  : ${EXPR=expr}  : ${EXPR=expr}
728  : ${ID=id}  : ${ID=id}
729  : ${TR=tr}  : ${TR=tr}
# Line 770  find_tool () Line 771  find_tool ()
771    # Make sure the default tool is just the first real command name    # Make sure the default tool is just the first real command name
772    for default_TOOL in $clist `IFS=:; echo $default_TOOL`; do break; done    for default_TOOL in $clist `IFS=:; echo $default_TOOL`; do break; done
773    TOOL=""    TOOL=""
774      TEST_MARGINALS=0
775    for trytool in $clist ; do    for trytool in $clist ; do
776      pass=:      pass=:
777        MARGINALS=0
778      for tooltest in $tooltests; do      for tooltest in $tooltests; do
779        result=`eval $tooltest $trytool`        result=`eval $tooltest $trytool 2>&1`
780        rc=$?        rc=$?
781        echo "Running $tooltest $trytool" >>$LOGFILE        echo "Running $tooltest $trytool" >>$LOGFILE
782        if test -n "$result"; then        if test -n "$result"; then
# Line 783  find_tool () Line 786  find_tool ()
786          echo "PASS: $tooltest $trytool" >>$LOGFILE          echo "PASS: $tooltest $trytool" >>$LOGFILE
787        elif test "$rc" = "77"; then        elif test "$rc" = "77"; then
788          echo "MARGINAL: $tooltest $trytool; rc=$rc" >>$LOGFILE          echo "MARGINAL: $tooltest $trytool; rc=$rc" >>$LOGFILE
789          TOOL=$trytool          MARGINALS=`expr $MARGINALS + 1`
790          pass=false          pass=false
791        else        else
792          set_bad_tool $trytool          set_bad_tool $trytool
# Line 795  find_tool () Line 798  find_tool ()
798        echo $trytool        echo $trytool
799        return 0        return 0
800      fi      fi
801        if test $MARGINALS -gt 0 \
802           && (test -z "$TOOL" || test $MARGINALS -lt $TEST_MARGINALS); then
803          if is_bad_tool $trytool; then
804            # Ignore tools with some MARGINAL results and some FAIL
805            :
806          else
807            TOOL=$trytool
808            TEST_MARGINALS=$MARGINALS
809          fi
810        fi
811    done    done
812    if test -n "$TOOL"; then    if test -n "$TOOL"; then
813      echo "Notice: The default version of $dTn (\`$default_TOOL')" >>$LOGFILE      echo "Notice: The default version of $dTn (\`$default_TOOL')" >>$LOGFILE
# Line 838  for pass in false :; do Line 851  for pass in false :; do
851    esac    esac
852  done  done
853    
854    
855    
856    # Test if diff supports the -u option, falling back on -c, then no arguments.
857    #
858    # Set $diff_u to `$1 -u' if $1 -u works, `$1 -c' if not and $1 -c
859    # works, and `$1' otherwise.
860    #
861    # $diff_u is intended to be used for tests expecting no differences, since the
862    # non-matching output is going to vary depending on what version of diff is
863    # found.  Used in tests which expect no differences, output will always mean
864    # errors and will make the error log more verbose, and correspondingly more
865    # readable by a human, regardless of the source.
866    diff_u_test()
867    {
868      diff=$1
869      touch sanity.1 sanity.2
870      if output=`$diff -u sanity.1 sanity.2 2>&1` && test -z "$output"; then
871        diff_u="$diff -u"
872        retval=0
873      elif output=`$diff -c sanity.1 sanity.2 2>&1` && test -z "$output"; then
874        diff_u="$diff -c"
875        retval=77
876      elif output=`$diff sanity.1 sanity.2 2>&1` && test -z "$output"; then
877        echo "A diff that supports the -u or -c options and which does not output"
878        echo "text when files are identical can make the output of some of this"
879        echo "script's tests more readable on failure."
880        diff_u=$diff
881        retval=77
882      else
883        echo "This test suite requires either \`diff' or \`cmp' to run."
884        retval=1
885      fi
886      rm sanity.1 sanity.2
887      return $retval
888    }
889    
890    
891    
892    # Test if diff supports the -u, --recursive, && --exclude options.
893    diff_recursive_test()
894    {
895      diff=$1
896      mkdir sanitydir.1
897      mkdir sanitydir.2
898      mkdir sanitydir.1/CVS
899      mkdir sanitydir.2/CVS
900      touch sanitydir.1/sanity.1 sanitydir.1/sanity.2 sanitydir.1/CVS/fileX \
901            sanitydir.2/sanity.1 sanitydir.2/sanity.2 sanitydir.2/CVS/fileY
902    
903      if $diff -u --recursive --exclude=CVS sanitydir.1 sanitydir.2 \
904               >/dev/null 2>&1; then
905        retval=0
906      else
907        echo "GNU diff can make the output of some tests more readable."
908        retval=77
909      fi
910      rm -r sanitydir.1 sanitydir.2
911      return $retval
912    }
913    
914    DIFF=`find_tool diff $DIFF:gdiff:cmp \
915                    version_test diff_u_test diff_recursive_test`
916    # Make sure $diff_u is set based on the tool find_tool returned.
917    diff_u_test $DIFF
918    
919    
920    
921  # Cause NextStep 3.3 users to lose in a more graceful fashion.  # Cause NextStep 3.3 users to lose in a more graceful fashion.
922  expr_tooltest1 ()  expr_tooltest1 ()
923  {  {
# Line 1482  run_filter () Line 1562  run_filter ()
1562      sed '${/^$/d}' <$1 >$1.filter1      sed '${/^$/d}' <$1 >$1.filter1
1563      # Run the filter      # Run the filter
1564      eval "$TEST_FILTER" <$1.filter1 >$1.filter2      eval "$TEST_FILTER" <$1.filter1 >$1.filter2
1565      diff -u $1 $1.filter2 \      $diff_u $1 $1.filter2 \
1566              >$1.diff              >$1.diff
1567      mv $1.filter2 $1      mv $1.filter2 $1
1568      rm $1.filter1      rm $1.filter1
# Line 1711  fi Line 1791  fi
1791    
1792    
1793    
1794  # a simple function to compare directory contents  if diff_recursive_test $DIFF >/dev/null 2>&1; then
1795  #    directory_cmp ()
1796  # Returns: 0 for same, 1 for different    {
1797  #      $DIFF -u --recursive --exclude=CVS $1 $2
1798  directory_cmp ()    }
1799  {  else
1800          OLDPWD=`pwd`    # a simple function to compare directory contents
1801          DIR_1=$1    #
1802          DIR_2=$2    # Returns: 0 for same, 1 for different
1803      #
1804          cd $DIR_1    directory_cmp ()
1805          find . -print | fgrep -v /CVS | sort > $TESTDIR/dc$$d1    {
1806        OLDPWD=`pwd`
1807          # go back where we were to avoid symlink hell...      DIR_1=$1
1808          cd $OLDPWD      DIR_2=$2
1809          cd $DIR_2  
1810          find . -print | fgrep -v /CVS | sort > $TESTDIR/dc$$d2      cd $DIR_1
1811        find . -print | fgrep -v /CVS | sort > $TESTDIR/dc$$d1
1812          if diff $TESTDIR/dc$$d1 $TESTDIR/dc$$d2 >/dev/null 2>&1  
1813          then      # go back where we were to avoid symlink hell...
1814                  :      cd $OLDPWD
1815          else      cd $DIR_2
1816                  return 1      find . -print | fgrep -v /CVS | sort > $TESTDIR/dc$$d2
1817    
1818        if $diff_u $TESTDIR/dc$$d1 $TESTDIR/dc$$d2
1819        then
1820          :
1821        else
1822          echo "directory_cmp: file lists of \`$DIR_1' & \`$DIR_2' differ" >&2
1823          return 1
1824        fi
1825        cd $OLDPWD
1826        while read a
1827        do
1828          if test -f $DIR_1/"$a" ; then
1829            cmp $DIR_1/"$a" $DIR_2/"$a"
1830            if test $? -ne 0 ; then
1831              return 1
1832          fi          fi
1833          cd $OLDPWD        fi
1834          while read a      done < $TESTDIR/dc$$d1
1835          do      rm -f $TESTDIR/dc$$*
1836                  if test -f $DIR_1/"$a" ; then      return 0
1837                          cmp -s $DIR_1/"$a" $DIR_2/"$a"    }
1838                          if test $? -ne 0 ; then  fi
                                 return 1  
                         fi  
                 fi  
         done < $TESTDIR/dc$$d1  
         rm -f $TESTDIR/dc$$*  
         return 0  
 }  
1839    
1840    
1841    
# Line 6103  U file3" Line 6191  U file3"
6191                  fi                  fi
6192    
6193                  # Make sure that we joined the correct change to file1                  # Make sure that we joined the correct change to file1
6194                  if echo line2 from branch1 | cmp - file1 >/dev/null; then                  dotest death-87a "echo line2 from branch1 |$diff_u - file1"
                     pass 87a  
                 else  
                     fail 87a  
                 fi  
6195    
6196                  # update                  # update
6197                  if ${CVS} update  ; then                  if ${CVS} update  ; then
# Line 9028  N first-dir/imported-f3 Line 9112  N first-dir/imported-f3
9112  N first-dir/imported-f4  N first-dir/imported-f4
9113  No conflicts created by this import"  No conflicts created by this import"
9114    
9115                  dotest import-96.5 "cmp ../imported-f2-orig.tmp imported-f2" ''                  dotest import-96.5 "$diff_u ../imported-f2-orig.tmp imported-f2"
9116    
9117                  cd ..                  cd ..
9118    
# Line 9137  U first-dir/imported-f3 Line 9221  U first-dir/imported-f3
9221  U first-dir/imported-f4  U first-dir/imported-f4
9222  Use the following command to help the merge:"  Use the following command to help the merge:"
9223    
9224                  dotest import-106.5 "cmp ../imported-f2-orig.tmp imported-f2" \                  dotest import-106.5 "$diff_u ../imported-f2-orig.tmp imported-f2"
 ''  
9225    
9226                  cd ..                  cd ..
9227    
# Line 16495  new revision: 1\.2; previous revision: 1 Line 16578  new revision: 1\.2; previous revision: 1
16578            dotest devcom-20 "echo no | $testcvs unedit abc" \            dotest devcom-20 "echo no | $testcvs unedit abc" \
16579  "abc has been modified; revert changes? "  "abc has been modified; revert changes? "
16580    
16581            dotest devcom-21 "echo changedabc | cmp - abc"            dotest devcom-21 "echo changedabc |$diff_u - abc"
16582    
16583            # OK, now confirm the unedit            # OK, now confirm the unedit
16584            dotest devcom-22 "echo yes |$testcvs unedit abc" \            dotest devcom-22 "echo yes |$testcvs unedit abc" \
16585  "abc has been modified; revert changes? "  "abc has been modified; revert changes? "
16586    
16587            dotest devcom-23 "echo abc |cmp - abc"            dotest devcom-23 "echo abc |$diff_u - abc"
16588    
16589            dotest devcom-24 "$testcvs watchers" ''            dotest devcom-24 "$testcvs watchers" ''
16590    
# Line 23396  EOF Line 23479  EOF
23479            $testcvs -z5 -Q diff --side-by-side -W 500 -r 1.1 -r 1.2 \            $testcvs -z5 -Q diff --side-by-side -W 500 -r 1.1 -r 1.2 \
23480               aaa > good.dif               aaa > good.dif
23481        
23482            dotest sshstdio-6 "diff -u wrapper.dif good.dif"            dotest sshstdio-6 "$diff_u wrapper.dif good.dif"
23483    
23484            dokeep            dokeep
23485            cd ../..            cd ../..
# Line 23978  ${SPROG} add: use .${SPROG} commit. to a Line 24061  ${SPROG} add: use .${SPROG} commit. to a
24061            ls -l kw >${TESTDIR}/1/stamp.kw.add            ls -l kw >${TESTDIR}/1/stamp.kw.add
24062            # "cvs add" should not muck with the timestamp.            # "cvs add" should not muck with the timestamp.
24063            dotest stamps-4aa \            dotest stamps-4aa \
24064  "cmp ${TESTDIR}/1/stamp.aa.touch ${TESTDIR}/1/stamp.aa.add" ''  "$diff_u $TESTDIR/1/stamp.aa.touch $TESTDIR/1/stamp.aa.add"
24065            dotest stamps-4kw \            dotest stamps-4kw \
24066  "cmp ${TESTDIR}/1/stamp.kw.touch ${TESTDIR}/1/stamp.kw.add" ''  "$diff_u $TESTDIR/1/stamp.kw.touch $TESTDIR/1/stamp.kw.add"
24067            sleep 60            sleep 60
24068            dotest stamps-5 "${testcvs} -q ci -m add" \            dotest stamps-5 "${testcvs} -q ci -m add" \
24069  "$CVSROOT_DIRNAME/first-dir/aa,v  <--  aa  "$CVSROOT_DIRNAME/first-dir/aa,v  <--  aa
# Line 24000  initial revision: 1\.1" Line 24083  initial revision: 1\.1"
24083            # reported in "cvs log kw" matched stamp.kw.ci.  But that would            # reported in "cvs log kw" matched stamp.kw.ci.  But that would
24084            # be a lot of work.            # be a lot of work.
24085            dotest stamps-6aa \            dotest stamps-6aa \
24086              "cmp ${TESTDIR}/1/stamp.aa.add ${TESTDIR}/1/stamp.aa.ci" ''  "$diff_u $TESTDIR/1/stamp.aa.add $TESTDIR/1/stamp.aa.ci"
24087            if cmp ${TESTDIR}/1/stamp.kw.add ${TESTDIR}/1/stamp.kw.ci >/dev/null            dotest_fail stamps-6kw \
24088            then  "cmp $TESTDIR/1/stamp.kw.add $TESTDIR/1/stamp.kw.ci >/dev/null"
             fail stamps-6kw  
           else  
             pass stamps-6kw  
           fi  
24089            cd ../..            cd ../..
24090            sleep 60            sleep 60
24091            mkdir 2            mkdir 2
# Line 24023  U first-dir/kw" Line 24102  U first-dir/kw"
24102            dotest_fail stamps-8aa \            dotest_fail stamps-8aa \
24103  "cmp $TESTDIR/1/stamp.aa.ci $TESTDIR/1/stamp.aa.get >/dev/null"  "cmp $TESTDIR/1/stamp.aa.ci $TESTDIR/1/stamp.aa.get >/dev/null"
24104            dotest stamps-8kw \            dotest stamps-8kw \
24105  "cmp $TESTDIR/1/stamp.kw.ci $TESTDIR/1/stamp.kw.get"  "$diff_u $TESTDIR/1/stamp.kw.ci $TESTDIR/1/stamp.kw.get"
24106    
24107            # Now we want to see what "cvs update" does.            # Now we want to see what "cvs update" does.
24108            sleep 60            sleep 60
# Line 27352  Merging differences between 1\.1\.1\.1 a Line 27431  Merging differences between 1\.1\.1\.1 a
27431            cd ..            cd ..
27432            rm mine/.#*            rm mine/.#*
27433    
           # If you have GNU's version of diff, you may try  
           # uncommenting the following line which will give more  
           # fine-grained information about how cvs differed from the  
           # correct result:  
           #dotest diffmerge1_cmp "diff -u --recursive --exclude=CVS comp_me mine" ''  
27434            dotest diffmerge1_cmp "directory_cmp comp_me mine"            dotest diffmerge1_cmp "directory_cmp comp_me mine"
27435    
27436            # Clean up after ourselves:            # Clean up after ourselves:
# Line 31671  new revision: 1.2; previous revision: 1. Line 31745  new revision: 1.2; previous revision: 1.
31745            # Did the CVSROOT/CVS/Template file get the updated version?            # Did the CVSROOT/CVS/Template file get the updated version?
31746            if $remote; then            if $remote; then
31747              dotest template-rcsinfo-4r \              dotest template-rcsinfo-4r \
31748  "cmp CVS/Template ${TESTDIR}/template/temp.def" ''  "$diff_u CVS/Template $TESTDIR/template/temp.def"
31749            else            else
31750              dotest template-rcsinfo-4 \              dotest template-rcsinfo-4 \
31751  "test ! -f CVS/Template" ''  "test ! -f CVS/Template" ''
# Line 31682  new revision: 1.2; previous revision: 1. Line 31756  new revision: 1.2; previous revision: 1.
31756            # Did the CVSROOT/CVS/Template file get the updated version?            # Did the CVSROOT/CVS/Template file get the updated version?
31757            if $remote; then            if $remote; then
31758              dotest template-rcsinfo-5r \              dotest template-rcsinfo-5r \
31759  "cmp CVS/Template ${TESTDIR}/template/temp.def" ''  "$diff_u CVS/Template $TESTDIR/template/temp.def"
31760            else            else
31761              dotest template-rcsinfo-5 \              dotest template-rcsinfo-5 \
31762  "test ! -f CVS/Template" ''  "test ! -f CVS/Template" ''
# Line 31704  ${SPROG} checkout: Updating second" Line 31778  ${SPROG} checkout: Updating second"
31778              # The value of the CVS/Template should be equal to the              # The value of the CVS/Template should be equal to the
31779              # file called out in the rcsinfo file.              # file called out in the rcsinfo file.
31780              dotest template-first-r-4 \              dotest template-first-r-4 \
31781  "cmp first/CVS/Template ${TESTDIR}/template/temp.first" ''  "$diff_u first/CVS/Template $TESTDIR/template/temp.first"
31782              dotest template-first-r-5 \              dotest template-first-r-5 \
31783  "cmp first/subdir/CVS/Template ${TESTDIR}/template/temp.subdir" ''  "$diff_u first/subdir/CVS/Template $TESTDIR/template/temp.subdir"
31784              dotest template-first-r-6 \              dotest template-first-r-6 \
31785  "cmp second/CVS/Template ${TESTDIR}/template/temp.def" ''  "$diff_u second/CVS/Template $TESTDIR/template/temp.def"
31786            else            else
31787              # When in local mode CVS/Template must NOT exist              # When in local mode CVS/Template must NOT exist
31788              dotest_fail template-first-1 "test -f first/CVS/Template" ''              dotest_fail template-first-1 "test -f first/CVS/Template" ''
# Line 31724  ${SPROG} checkout: Updating second" Line 31798  ${SPROG} checkout: Updating second"
31798  "Directory ${CVSROOT_DIRNAME}/second/otherdir added to the repository"  "Directory ${CVSROOT_DIRNAME}/second/otherdir added to the repository"
31799            if $remote; then            if $remote; then
31800              dotest template-add-2r \              dotest template-add-2r \
31801  "cmp otherdir/CVS/Template ${TESTDIR}/template/temp.def" ''  "$diff_u otherdir/CVS/Template $TESTDIR/template/temp.def"
31802            else            else
31803              dotest_fail template-add-2 "test -f otherdir/CVS/Template" ''              dotest_fail template-add-2 "test -f otherdir/CVS/Template" ''
31804            fi            fi
# Line 31744  ${SPROG} update: Updating second/otherdi Line 31818  ${SPROG} update: Updating second/otherdi
31818    
31819            if $remote; then            if $remote; then
31820              dotest template-second-r-1 \              dotest template-second-r-1 \
31821  "cmp first/CVS/Template ${TESTDIR}/template/temp.first" ''  "$diff_u first/CVS/Template $TESTDIR/template/temp.first"
31822              dotest template-second-r-2 \              dotest template-second-r-2 \
31823  "cmp first/subdir/CVS/Template ${TESTDIR}/template/temp.subdir" ''  "$diff_u first/subdir/CVS/Template $TESTDIR/template/temp.subdir"
31824              dotest template-second-r-3 \              dotest template-second-r-3 \
31825  "cmp second/CVS/Template ${TESTDIR}/template/temp.def" ''  "$diff_u second/CVS/Template $TESTDIR/template/temp.def"
31826              dotest template-second-r-4 \              dotest template-second-r-4 \
31827  "cmp second/otherdir/CVS/Template ${TESTDIR}/template/temp.def" ''  "$diff_u second/otherdir/CVS/Template $TESTDIR/template/temp.def"
31828            else            else
31829              # When in local mode CVS/Template must NOT exist              # When in local mode CVS/Template must NOT exist
31830              dotest_fail template-second-1 "test -f CVS/Template" ''              dotest_fail template-second-1 "test -f CVS/Template" ''
# Line 31793  ${SPROG} update: Updating second/otherdi Line 31867  ${SPROG} update: Updating second/otherdi
31867            # Did the CVSROOT/CVS/Template file get the updated version?            # Did the CVSROOT/CVS/Template file get the updated version?
31868            if $remote; then            if $remote; then
31869              dotest template-norcsinfo-r-2 \              dotest template-norcsinfo-r-2 \
31870  "cmp CVS/Template ${TESTDIR}/template/temp.def" ''  "$diff_u CVS/Template $TESTDIR/template/temp.def"
31871            else            else
31872              dotest_fail template-norcsinfo-2 "test -f CVS/Template" ''              dotest_fail template-norcsinfo-2 "test -f CVS/Template" ''
31873            fi            fi
# Line 35554  You have \[0\] altered files in this rep Line 35628  You have \[0\] altered files in this rep
35628                      $CVSROOT_DIRNAME/CVSROOT/posttag \                      $CVSROOT_DIRNAME/CVSROOT/posttag \
35629                      $SECONDARY_CVSROOT_DIRNAME/CVSROOT/postwatch \                      $SECONDARY_CVSROOT_DIRNAME/CVSROOT/postwatch \
35630                      $CVSROOT_DIRNAME/CVSROOT/postwatch; do                      $CVSROOT_DIRNAME/CVSROOT/postwatch; do
35631              if cmp $file $TESTDIR/`basename $file`-clean >/dev/null 2>&1; then              if $diff_u $file $TESTDIR/`basename $file`-clean >>$LOGFILE 2>&1; then
35632                  :;                  :;
35633              else              else
35634                  echo "\`$file' and \`$TESTDIR/`basename $file`-clean' differ." \                  echo "\`$file' and \`$TESTDIR/`basename $file`-clean' differ." \

Legend:
Removed from v.1.1094  
changed lines
  Added in v.1.1095

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26