Follow upstream changes -- rest
[git-darcs-import.git] / tests / record_editor.sh
blob68b4866664ab8479b6008618110458c84d999866
1 #!/usr/bin/env bash
2 set -ev
4 # Some tests for 'darcs rec --edit-long-comment'
6 not () { "$@" && exit 1 || :; }
8 # trick: OS-detection (if needed)
9 if echo $OS | grep -i windows; then
10 echo This test does not work on Windows
11 exit 0
14 rm -rf temp1
16 export DARCS_EDITOR="/bin/cat -n"
17 # editor: space in command
18 mkdir temp1
19 cd temp1
20 darcs init
21 touch file.t
22 darcs add file.t
23 darcs record --edit-long-comment -a -m foo file.t | grep '2.*END OF DESCRIPTION'
24 cd ..
25 rm -rf temp1
27 # editor: space in path
28 mkdir temp2\ dir
29 cd temp2\ dir
30 darcs init
31 touch file.t
32 darcs add file.t
33 darcs record --edit-long-comment -a -m foo file.t | grep '2.*END OF DESCRIPTION'
34 cd ..
35 rm -rf temp2\ dir
37 export DARCS_EDITOR='grep "END OF"'
38 # editor: quoting in command
39 mkdir temp1
40 cd temp1
41 darcs init
42 touch file.t
43 darcs add file.t
44 darcs record --edit-long-comment -a -m foo file.t | grep 'END OF'
45 cd ..
46 rm -rf temp1
48 export DARCS_EDITOR='/bin/echo'
49 # editor: evil filename
50 mkdir temp1
51 cd temp1
52 darcs init
53 touch file.t
54 darcs add file.t
55 touch '; test-command'
56 echo > test-command << FOO
57 #!/bin/sh
58 echo EVIL
59 FOO
60 chmod u+x test-command
61 darcs record --logfile='; test-command' --edit-long-comment -a -m foo file.t > log
62 not grep EVIL log
63 cd ..
64 rm -rf temp1