Allow $RSYNC_TEST_TMP to indicate a good tmp dir for our tests.
[rsync/rsync.git] / testsuite / merge.test
index 1c1586f..4e76102 100644 (file)
@@ -9,44 +9,49 @@
 
 . "$suitedir/rsync.fns"
 
-set -x
-
 # Build some files/dirs/links to copy
 
-from1dir="${fromdir}1"
-from2dir="${fromdir}2"
-from3dir="${fromdir}3"
-
-mkdir "$from1dir" "$from2dir" "$from3dir"
-mkdir "$from2dir"/sub1 "$from3dir"/sub1
-mkdir "$from3dir"/sub2 "$from1dir"/dir-and-not-dir
-mkdir "$chkdir" "$chkdir"/sub1 "$chkdir"/sub2
-echo "one" >"$from1dir"/one
-cp -p "$from1dir"/one "$from2dir"/one
-cp -p "$from1dir"/one "$from3dir"/one
-echo "two" >"$from1dir"/two
-echo "three" >"$from2dir"/three
-echo "four" >"$from3dir"/four
-echo "five" >"$from1dir"/five
-echo "six" >"$from3dir"/six
-echo "sub1" >"$from2dir"/sub1/uno
-cp -p "$from2dir"/sub1/uno "$from3dir"/sub1/uno
-echo "sub2" >"$from3dir"/sub1/dos
-echo "sub3" >"$from2dir"/sub1/tres
-echo "subby" >"$from3dir"/sub2/subby
-echo "not-dir" >"$from3dir"/dir-and-not-dir
-
-cp -p "$from1dir"/one "$from1dir"/two "$from2dir"/three "$from3dir"/four "$from1dir"/five "$from3dir"/six "$chkdir"
-cp -p "$from3dir"/dir-and-not-dir "$chkdir"
-cp -p "$from2dir"/sub1/uno "$from3dir"/sub1/dos "$from2dir"/sub1/tres "$chkdir"/sub1
-cp -p "$from3dir"/sub2/subby "$chkdir"/sub2
+# Use local dirnames to better exercise the arg-parsing code.
+cd "$tmpdir"
+
+mkdir from1 from2 from3 deep
+mkdir from2/sub1 from3/sub1
+mkdir from3/sub2 from1/dir-and-not-dir
+mkdir chk chk/sub1 chk/sub2 chk/dir-and-not-dir
+echo "one" >from1/one
+cp_touch from1/one from2/one
+cp_touch from1/one from3/one
+echo "two" >from1/two
+echo "three" >from2/three
+echo "four" >from3/four
+echo "five" >from1/five
+echo "six" >from3/six
+echo "sub1" >from2/sub1/uno
+cp_touch from2/sub1/uno from3/sub1/uno
+echo "sub2" >from3/sub1/dos
+echo "sub3" >from2/sub1/tres
+echo "subby" >from3/sub2/subby
+echo "extra" >from1/dir-and-not-dir/inside
+echo "not-dir" >from3/dir-and-not-dir
+echo "arg-test" >deep/arg-test
+echo "shallow" >shallow
+
+cp_touch from1/one from1/two from2/three from3/four from1/five from3/six chk
+cp_touch deep/arg-test shallow chk
+cp_touch from1/dir-and-not-dir/inside chk/dir-and-not-dir
+cp_touch from2/sub1/uno from3/sub1/dos from2/sub1/tres chk/sub1
+cp_touch from3/sub2/subby chk/sub2
+
+# Make sure that time has moved on.
+sleep 1
 
 # Get rid of any directory-time differences
-touch "$from1dir" "$from2dir" "$from3dir" \
-    "$from2dir"/sub1 "$from3dir"/sub1 "$from3dir"/sub2 \
-    "$chkdir" "$chkdir"/sub1 "$chkdir"/sub2
+$RSYNC -av --existing -f 'exclude,! */' from1/ from2/
+$RSYNC -av --existing -f 'exclude,! */' from2/ from3/
+$RSYNC -av --existing -f 'exclude,! */' from1/ chk/
+$RSYNC -av --existing -f 'exclude,! */' from3/ chk/
 
-checkit "$RSYNC -aHvv \"$from1dir/\" \"$from2dir/\" \"$from3dir/\" \"$todir/\"" "$chkdir" "$todir"
+checkit "$RSYNC -avv deep/arg-test shallow from1/ from2/ from3/ to/" "$chkdir" "$todir"
 
 # The script would have aborted on error, so getting here means we've won.
 exit 0