expand coverage of test_update_single_file: test file deletion during update
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
diff --git a/regress/cmdline/update.sh b/regress/cmdline/update.sh
index 97e1238..2623bfe 100755
--- a/regress/cmdline/update.sh
+++ b/regress/cmdline/update.sh
@@ -2269,7 +2269,11 @@ test_update_single_file() {
git_commit $testroot/repo -m "add files a and b, change c"
local commit_id2=`git_show_head $testroot/repo`
- got checkout $testroot/repo $testroot/wt > /dev/null
+ (cd $testroot/repo && git rm -qf c)
+ git_commit $testroot/repo -m "remove file c"
+ local commit_id3=`git_show_head $testroot/repo`
+
+ got checkout -c $commit_id2 $testroot/repo $testroot/wt > /dev/null
ret="$?"
if [ "$ret" != "0" ]; then
test_done "$testroot" "$ret"
@@ -2304,7 +2308,7 @@ test_update_single_file() {
echo "U c" > $testroot/stdout.expected
echo "Updated to commit $commit_id2" >> $testroot/stdout.expected
- (cd $testroot/wt && got update c > $testroot/stdout)
+ (cd $testroot/wt && got update -c $commit_id2 c > $testroot/stdout)
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
@@ -2321,8 +2325,54 @@ test_update_single_file() {
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/content.expected $testroot/content
+ test_done "$testroot" "$ret"
+ return 1
fi
- test_done "$testroot" "$ret"
+
+ echo "D c" > $testroot/stdout.expected
+ echo "Updated to commit $commit_id3" >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update -c $commit_id3 c \
+ > $testroot/stdout 2> $testroot/stderr)
+
+ echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo -n > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ echo "D c" > $testroot/stdout.expected
+ echo "Updated to commit $commit_id3" >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update -c $commit_id3 > $testroot/stdout)
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ if [ -e $testroot/wt/c ]; then
+ echo "removed file c still exists on disk" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ test_done "$testroot" "0"
+ return 0
}