Commit | Line | Data |
---|---|---|
121c14e5 KH |
1 | #!/bin/sh |
2 | ||
3 | test_description='Simple test cases for "stg redo"' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | # Ignore our own output files. | |
8 | cat > .git/info/exclude <<EOF | |
9 | /expected.txt | |
10 | EOF | |
11 | ||
12 | test_expect_success 'Initialize StGit stack with three patches' ' | |
13 | stg init && | |
14 | echo 000 >> a && | |
15 | git 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 | |
24 | ' | |
25 | ||
26 | cat > expected.txt <<EOF | |
27 | 000 | |
28 | 111 | |
29 | 222 | |
30 | EOF | |
31 | test_expect_success 'Pop one patch ...' ' | |
32 | stg pop && | |
33 | test "$(echo $(stg series))" = "+ p1 > p2 - p3" && | |
34 | test_cmp expected.txt a | |
35 | ' | |
36 | ||
37 | cat > expected.txt <<EOF | |
38 | 000 | |
39 | 111 | |
40 | 222 | |
41 | 333 | |
42 | EOF | |
43 | test_expect_success '... undo it ...' ' | |
44 | stg undo && | |
45 | test "$(echo $(stg series))" = "+ p1 + p2 > p3" && | |
46 | test_cmp expected.txt a | |
47 | ' | |
48 | ||
49 | cat > expected.txt <<EOF | |
50 | 000 | |
51 | 111 | |
52 | 222 | |
53 | EOF | |
54 | test_expect_success '... and redo' ' | |
55 | stg redo && | |
56 | test "$(echo $(stg series))" = "+ p1 > p2 - p3" && | |
57 | test_cmp expected.txt a | |
58 | ' | |
59 | ||
60 | cat > expected.txt <<EOF | |
61 | 000 | |
62 | EOF | |
63 | test_expect_success 'Pop three patches ...' ' | |
64 | stg push && | |
65 | stg pop && | |
66 | stg pop && | |
67 | stg pop && | |
68 | test "$(echo $(stg series))" = "- p1 - p2 - p3" && | |
69 | test_cmp expected.txt a | |
70 | ' | |
71 | ||
72 | cat > expected.txt <<EOF | |
73 | 000 | |
74 | 111 | |
75 | 222 | |
76 | 333 | |
77 | EOF | |
78 | test_expect_success '... undo it ...' ' | |
79 | stg undo && | |
80 | stg undo && | |
81 | stg undo && | |
82 | test "$(echo $(stg series))" = "+ p1 + p2 > p3" && | |
83 | test_cmp expected.txt a | |
84 | ' | |
85 | ||
86 | cat > expected.txt <<EOF | |
87 | 000 | |
88 | 111 | |
89 | EOF | |
90 | test_expect_success '... redo the first two pops ...' ' | |
91 | stg redo -n 2 && | |
92 | test "$(echo $(stg series))" = "> p1 - p2 - p3" && | |
93 | test_cmp expected.txt a | |
94 | ' | |
95 | ||
96 | cat > expected.txt <<EOF | |
97 | 000 | |
98 | EOF | |
99 | test_expect_success '... and the remaining one' ' | |
100 | stg redo && | |
101 | test "$(echo $(stg series))" = "- p1 - p2 - p3" && | |
102 | test_cmp expected.txt a | |
103 | ' | |
104 | ||
105 | cat > expected.txt <<EOF | |
106 | 000 | |
107 | EOF | |
108 | test_expect_success 'Redo past end of history' ' | |
109 | command_error stg redo && | |
110 | test "$(echo $(stg series))" = "- p1 - p2 - p3" && | |
111 | test_cmp expected.txt a | |
112 | ' | |
113 | ||
114 | test_done |