summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/mv/update41
1 files changed, 41 insertions, 0 deletions
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