1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
#!/usr/bin/env bash
# Some tests for 'darcs record '
. lib
rm -rf temp1
mkdir temp1
cd temp1
darcs init
# issue308 - no patches and no deps for record should abort
darcs record -am foo --ask-deps | grep -i "Ok, if you don't want to record anything, that's fine!"
# RT#476 - --ask-deps works when there are no patches
touch t.f
darcs add t.f
darcs record -am add
echo a | darcs record -am foo --ask-deps | grep -i 'finished recording'
# RT#231 - special message is given for nonexistent directories
not darcs record -am foo not_there.txt > log 2>&1
grep -i 'non-existing' log
# RT#231 - a nonexistent file before an existing file is handled correctly
# test disabled, see tests/issue2494-output-of-record-with-file-arguments.sh
# which contains an updated test
# touch b.t
# darcs record -lam foo a.t b.t > log
# grep -i 'WARNING:.*a.t' log
# grep -iv 'WARNING:.*b.t' log
DIR="`pwd`"
touch date.t
darcs add date.t
darcs record -a -m foo "$DIR/date.t" | grep -i 'finished recording'
# issue396 - record -l ""
touch 'notnull.t'
darcs record -am foo -l "" notnull.t | grep -i 'finished recording'
# basic record
date >> date.t
darcs record -a -m basic_record date.t | grep -i 'finished recording'
# testing --logfile
date >> date.t
echo "second record\n" >> log.txt
darcs record -a -m 'second record' --logfile=log.txt date.t | grep -i 'finished recording'
echo text > file
darcs add file
# refuse empty patch name
# true command outputs nothing & ignores its arguments
DARCS_EDITOR=true not darcs record -a --edit-long-comment
# cat command reproduces its input unchanged
DARCS_EDITOR=cat not darcs record -a -m "" --edit-long-comment
not darcs record -a -m ""
# refuse patch name starting with "TAG "
# editor output will be "echo TAG _darcs/patch_description.txt"
DARCS_EDITOR='echo TAG ' not darcs record -a --edit-long-comment
# cat command reproduces its input unchanged
DARCS_EDITOR=cat not darcs record -a -m "TAG fake" --edit-long-comment
not darcs record -a -m "TAG fake"
cd ..
# record race
rm -rf foo1 foo2
mkdir foo1 foo2
cd foo1
darcs init
echo zig > foo
darcs add foo
darcs record -a -m add_foo -A x
echo zag >> foo
darcs record --ignore-time -a -m mod_foo -A x
cd ../foo2
darcs init
darcs pull -a ../foo1
cd ..
cmp foo1/foo foo2/foo
# record interactive
rm -rf temp1
mkdir temp1
cd temp1
darcs init
touch foo
darcs add foo
darcs record -a -m addfoo
darcs replace one two foo
darcs replace three four foo
darcs replace five six foo
echo sa | darcs record -m cancelled
darcs whatsnew
darcs changes > ch
not grep cancelled ch
cd ..
# Some tests for 'darcs rec --edit-long-comment'
rm -rf temp1
export DARCS_EDITOR="cat -n"
# editor: space in command
rm -rf temp1
mkdir temp1
cd temp1
darcs init
touch file.t
darcs add file.t
echo y | darcs record --edit-long-comment -a -m foo file.t | grep '# Please enter'
cd ..
# editor: space in path
rm -rf temp2\ dir
mkdir temp2\ dir
cd temp2\ dir
darcs init
touch file.t
darcs add file.t
echo y | darcs record --edit-long-comment -a -m foo file.t | grep '# Please enter'
cd ..
# make sure summaries are coalesced
rm -rf temp3
mkdir temp3
cd temp3
darcs init
cat > file <<EOF
1
2
3
4
EOF
darcs add file
darcs rec -a -m "init" file
cat > file <<EOF
A
2
3
B
EOF
echo y | darcs record --edit-long-comment -a -m edit | grep -c "./file" | grep 1
cd ..
export DARCS_EDITOR='grep "# Please enter"'
# editor: quoting in command
rm -rf temp1
mkdir temp1
cd temp1
darcs init
touch file.t
darcs add file.t
echo y | darcs record --edit-long-comment -a -m foo file.t | grep '# Please enter'
cd ..
export DARCS_EDITOR='echo'
# editor: evil filename
rm -rf temp1
darcs init temp1
cd temp1
touch file.t
darcs add file.t
touch '; test-command'
echo > test-command << FOO
#!/bin/sh
echo EVIL
FOO
chmod u+x test-command
echo y | darcs record --logfile='; test-command' --edit-long-comment -a -m foo file.t > log
not grep EVIL log
cd ..
## Test for issue142 - darcs record --logfile foo should not
rm -rf temp1
darcs init temp1
cd temp1
touch f g
touch log
darcs record -alm f --logfile log f
not darcs record -alm g --logfile missing g
cd ..
## Test for issue1845 - darcs record f, for f a removed file should work
## Public domain - 2010 Petr Rockai
rm -rf temp1
darcs init temp1
cd temp1
echo 'Example content.' > f
darcs rec -lam "first"
rm -f f
echo ny | darcs record f 2>&1 | tee log
not grep "None of the files" log
cd ..
# issue1472 - "darcs record ./foo" shouldn't even TRY to read ./bar
rm -rf temp1
darcs init temp1
mkdir temp1/d/
echo 'Example content.' >temp1/f
echo 'Similar content.' >temp1/d/f
chmod 0 temp1/f # Make temp1/f unreadable
darcs record --repo temp1 -lam 'Only changes to temp1/d/.' d
# issue1871 - `darcs record .` should work for tracked changes
# in a subdirectory even if the subdirectory itself is not known yet.
rm -rf temp1
darcs init temp1
cd temp1
mkdir d
echo 'Example content.' > d/f
darcs add d/f
echo ny | darcs record
echo ny | darcs record . > log
not grep "None of the files" log
cd ..
|