Tests redirect to err file when grepping stderr
[stgit.git] / t / t3104-redo.sh
blobe47932291ff9f28361f19de588f4c67601efe0ac
1 #!/bin/sh
3 test_description='Simple test cases for "stg redo"'
5 . ./test-lib.sh
7 # Ignore our own output files.
8 cat >> .git/info/exclude <<EOF
9 /expected.txt
10 EOF
12 test_expect_success 'Initialize StGit stack with three patches' '
13 stg init &&
14 echo 000 >> a &&
15 stg add a &&
16 git commit -m a &&
17 echo 111 >> a &&
18 git commit -a -m p1 &&
19 echo 222 >> a &&
20 git commit -a -m p2 &&
21 echo 333 >> a &&
22 git commit -a -m p3 &&
23 stg uncommit -n 3
26 test_expect_success 'Invalid number of patches to redo' '
27 command_error stg redo -n0 2>err &&
28 grep -e "Bad number of undos to redo" err
31 cat > expected.txt <<EOF
32 000
33 111
34 222
35 EOF
36 test_expect_success 'Pop one patch ...' '
37 stg pop &&
38 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
39 test_cmp expected.txt a
42 cat > expected.txt <<EOF
43 000
44 111
45 222
46 333
47 EOF
48 test_expect_success '... undo it ...' '
49 stg undo &&
50 test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
51 test_cmp expected.txt a
54 cat > expected.txt <<EOF
55 000
56 111
57 222
58 EOF
59 test_expect_success '... and redo' '
60 stg redo &&
61 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
62 test_cmp expected.txt a
65 cat > expected.txt <<EOF
66 000
67 EOF
68 test_expect_success 'Pop three patches ...' '
69 stg push &&
70 stg pop &&
71 stg pop &&
72 stg pop &&
73 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
74 test_cmp expected.txt a
77 cat > expected.txt <<EOF
78 000
79 111
80 222
81 333
82 EOF
83 test_expect_success '... undo it ...' '
84 stg undo &&
85 stg undo &&
86 stg undo &&
87 test "$(echo $(stg series))" = "+ p1 + p2 > p3" &&
88 test_cmp expected.txt a
91 cat > expected.txt <<EOF
92 000
93 111
94 EOF
95 test_expect_success '... redo the first two pops ...' '
96 stg redo -n 2 &&
97 test "$(echo $(stg series))" = "> p1 - p2 - p3" &&
98 test_cmp expected.txt a
101 cat > expected.txt <<EOF
104 test_expect_success '... and the remaining one' '
105 stg redo &&
106 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
107 test_cmp expected.txt a
110 cat > expected.txt <<EOF
113 test_expect_success 'Redo past end of history' '
114 command_error stg redo &&
115 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
116 test_cmp expected.txt a
119 test_done