From 742dc8804a9170f7651d4881f9a3fcb7b88b711f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 6 Aug 2001 15:50:45 +0000 Subject: *** empty log message *** --- tests/mv/update | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 tests/mv/update (limited to 'tests/mv') diff --git a/tests/mv/update b/tests/mv/update new file mode 100755 index 000000000..4a3c2f551 --- /dev/null +++ b/tests/mv/update @@ -0,0 +1,41 @@ +#!/bin/sh +# make sure --update works as advertised + +if test "$VERBOSE" = yes; then + set -x + mv --version +fi + +. $srcdir/../envvar-check +. $srcdir/../lang-default + +pwd=`pwd` +tmp=mv-update.$$ +trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0 +trap '(exit $?); exit' 1 2 13 15 + +framework_failure=0 +mkdir $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +echo old > old || framework_failure=1 +touch -d yesterday old || framework_failure=1 +echo new > new || framework_failure=1 + +if test $framework_failure = 1; then + echo 'failure in testing framework' 1>&2 + (exit 1); exit +fi + +fail=0 + +# This is a no-op. +mv --update old new || fail=1 +case "`cat new`" in new) ;; *) fail=1 ;; esac +case "`cat old`" in old) ;; *) fail=1 ;; esac + +# This will actually do the rename. +mv --update new old || fail=1 +test -f new && fail=1 +case "`cat old`" in new) ;; *) fail=1 ;; esac + +(exit $fail); exit -- cgit v1.2.3-70-g09d2