Merge branch 'darcs' into master
[git-darcs-import.git] / tests / add-formerly-pl.sh
blob0c6b35a0cefff42651172f35c7d026a6c6470c44
1 #!/usr/bin/env bash
2 set -ev
4 # Some tests for 'darcs add'
6 not () { "$@" && exit 1 || :; }
8 rm -rf temp1 temp2
10 # set up the repository
11 mkdir temp1
12 cd temp1
13 darcs init
15 # Make sure that messages about directories call them directories
16 mkdir foo.d
17 mkdir oof.d
18 darcs add foo.d
19 darcs add oof.d
20 not darcs add foo.d 2> log
21 grep -i directory log
22 # Try adding the same directory when it's already in the repo
23 not darcs add foo.d oof.d 2> log
24 grep -i directories log
26 # Make sure that messages about files call them files
27 touch bar
28 touch baz
29 darcs add bar
30 darcs add baz
31 not darcs add bar 2> log
32 grep -i 'following file is' log
33 not darcs add bar baz 2> log
34 grep -i 'following files are' log
36 # Make sure that messages about both files and directories say so
37 not darcs add bar foo.d 2> log
38 grep -i 'files and directories' log
40 # Make sure that parent directories are added for files
41 mkdir -p a.d/aa.d/aaa.d
42 mkdir -p b.d/bb.d
43 touch a.d/aa.d/aaa.d/baz
44 touch a.d/aa.d/aaa.d/bar
45 darcs add a.d/aa.d/aaa.d/bar a.d/aa.d/aaa.d/baz b.d/bb.d 2> log
46 test ! -s log # no output
48 # Make sure that darcs doesn\'t complains about duplicate adds when adding parent dirs.
49 mkdir c.d
50 touch c.d/baz
51 darcs add c.d/baz c.d 2> log
52 test ! -s log # no output
54 # Make sure that add output looks good when adding files in subdir
55 mkdir d.d
56 touch d.d/foo
57 darcs add -rv d.d | grep 'd.d/foo'
59 # 'adding a non-existent dir and file gives the expected message
60 not darcs add notadir/notafile 2> log
61 grep -i 'does not exist' log
63 cd ..
64 rm -rf temp1