3 test_description
='Test stg show'
7 test_expect_success
'Create some patches' '
9 for x in aaa bbb ccc ddd; do
10 stg new -m patch-$x &&
11 echo "$x" >> foo.txt &&
17 test_expect_success
'Invalid -a/-u options' '
18 command_error stg show --applied --unapplied 2>&1 |
19 grep -e "cannot use both --applied and --unapplied"
22 test_expect_success
'Invalid arg with -a' '
23 command_error stg show --applied patch-aaa 2>&1 |
24 grep -e "patches may not be given with --applied or --unapplied"
27 test_expect_success
'Invalid patch name' '
28 command_error stg show bad-patch-name 2>&1 |
29 grep -e "bad-patch-name: Unknown patch or revision name"
32 test_expect_success
'Show patch' '
37 test_expect_success
'Bad diff opts' '
38 command_error stg show --diff-opts=--this-is-bad 2>&1 |
39 grep -e "unrecognized argument: --this-is-bad"
42 test_expect_success
'Show patch range' '
43 stg show patch-bbb..patch-ddd > show-range.txt &&
44 test $(grep -c -E "\+(aaa|bbb|ccc|ddd)" show-range.txt) = "3" &&
45 test $(grep -c -E "\+aaa" show-range.txt) = "0"
48 test_expect_success
'Show unapplied' '
50 stg show --unapplied > show-unapplied.txt &&
51 test $(grep -c -E "\+(aaa|bbb|ccc|ddd)" show-unapplied.txt) = "2" &&
52 test $(grep -c -E "\+(aaa|bbb)" show-unapplied.txt) = "0" &&
53 for pn in $(stg series --unapplied --noprefix); do
54 grep -e "$pn" show-unapplied.txt
58 test_expect_success
'Show applied' '
59 stg show --applied > show-applied.txt &&
60 test $(grep -c -E "\+(aaa|bbb|ccc|ddd)" show-applied.txt) = "2" &&
61 test $(grep -c -E "\+(ccc|ddd)" show-applied.txt) = "0"
62 for pn in $(stg series --applied --noprefix); do
63 grep -e "$pn" show-applied.txt
67 test_expect_success
'Show head' '
68 stg show > show-head.txt
69 test "$(cat show-head.txt)" = "$(stg show $(stg top))" &&
70 test "$(cat show-head.txt)" = "$(stg show $(stg id $(stg top)))"
73 test_expect_success
'Show by name' '
74 stg show patch-aaa patch-ddd > show-a-d.txt &&
75 test $(grep -c -E "\+(aaa|bbb|ccc|ddd)" show-a-d.txt) = "2" &&
76 test $(grep -c -E "\+(bbb|ccc)" show-a-d.txt) = "0"
79 test_expect_success
'Run show on empty patch' '
81 stg new -m "empty message" empty &&
82 stg show empty > show-empty.txt &&
83 grep "empty message" show-empty.txt
86 test_expect_success
'Run show --stat on empty patch' '
87 test "$(stg show --stat)" = "$(cat show-empty.txt)"
90 test_expect_success
'Run show --stat on patches' '
91 stg show --stat patch-aaa patch-ddd > show-a-d-stat.txt &&
92 test $(grep -c -e " foo.txt | 1 \+" show-a-d-stat.txt) = "2" &&
93 test $(grep -c -E "patch-aaa|patch-ddd" show-a-d-stat.txt) = "2"