3 # Copyright (c) 2006 Ilpo Järvinen
6 test_description
='Test "stg goto"'
10 test_expect_success
'Initialize stgit repository' '
12 for i in 1 2 3 4 5; do
13 stg new p$i -m "patch $i" &&
20 test_expect_success
'Test invalid number of arguments' '
21 command_error stg goto 2>&1 |
22 grep -e "incorrect number of arguments"
25 test_expect_success
'Goto current patch' '
26 stg goto $(stg top) &&
27 test "$(echo $(stg top))" = "p5"
30 test_expect_success
'Attempt goto invalid patch' '
31 command_error stg goto p999 2>&1 |
32 grep -e "Patch \"p999\" does not exist"
35 test_expect_success
'Goto a patch' '
37 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" &&
38 test "$(echo $(stg series --unapplied --noprefix))" = "p4 p5"
41 test_expect_success
'Refuse to go to a hidden patch' '
42 stg new h0 -m "hidden patch" &&
44 command_error stg goto h0 2>&1 | grep -e "Cannot goto a hidden patch" &&
45 test "$(echo $(stg series --hidden --noprefix))" = "h0" &&
46 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3" &&
47 test "$(echo $(stg series --unapplied --noprefix))" = "p4 p5"
50 test_expect_success
'Goto with merge check' '
51 stg goto --merged p5 &&
52 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3 p4 p5" &&
53 test "$(echo $(stg series --unapplied --noprefix))" = ""
56 test_expect_success
'Goto with ambiguous patch substring' '
58 command_error stg goto p 2>&1 |
59 grep "Ambiguous patch name \"p\""