Handle a --mkpath failure
[rsync.git] / testsuite / mkpath.test
1 #!/bin/sh
2
3 . "$suitedir/rsync.fns"
4
5 makepath "$fromdir"
6 makepath "$todir"
7
8 cp_p "$srcdir/rsync.h" "$fromdir/text"
9 cp_p "$srcdir/configure.ac" "$fromdir/extra"
10
11 cd "$tmpdir"
12
13 deep_dir=to/foo/bar/baz/down/deep
14
15 # Check that we can create several levels of dest dir
16 $RSYNC -aiv --mkpath from/text $deep_dir/new
17 test -f $deep_dir/new || test_fail "'new' file not found in $deep_dir dir"
18 rm -rf to/foo
19
20 $RSYNC -aiv --mkpath from/text $deep_dir/
21 test -f $deep_dir/text || test_fail "'text' file not found in $deep_dir dir"
22 rm $deep_dir/text
23
24 # Make sure we can handle an existing path
25 mkdir $deep_dir/new
26 $RSYNC -aiv --mkpath from/text $deep_dir/new
27 test -f $deep_dir/new/text || test_fail "'text' file not found in $deep_dir/new dir"
28
29 # ... and an existing path when an alternate dest filename is specified
30 $RSYNC -aiv --mkpath from/text $deep_dir/new/text2
31 test -f $deep_dir/new/text2 || test_fail "'text2' file not found in $deep_dir/new dir"
32 rm -rf to/foo
33
34 # Try the tests again with multiple source args
35 $RSYNC -aiv --mkpath from/ $deep_dir
36 test -f $deep_dir/extra || test_fail "'extra' file not found in $deep_dir dir"
37 rm -rf to/foo
38
39 $RSYNC -aiv --mkpath from/ $deep_dir/
40 test -f $deep_dir/text || test_fail "'text' file not found in $deep_dir dir"
41
42 # Make sure that we can handle no path
43 $RSYNC -aiv --mkpath from/text to_text
44 test -f to_text || test_fail "'to_text' file not found in current dir"
45
46 # The script would have aborted on error, so getting here means we've won.
47 exit 0