3 # Copyright (c) 2006 Robin Rosenberg
6 test_description
='Test floating a number of patches to the top of the stack
12 test_expect_success
'Initialize the StGit repository' '
13 test_commit_bulk --message="p%s" 7 &&
17 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3 p4 p5 p6" &&
18 test "$(echo $(stg series --unapplied --noprefix))" = "p7"
21 test_expect_success
'Float p1 to top' '
23 test "$(echo $(stg series --applied --noprefix))" = "p2 p3 p4 p5 p6 p1"
26 test_expect_success
'Float p1 to top (noop)' '
28 test "$(echo $(stg series --applied --noprefix))" = "p2 p3 p4 p5 p6 p1"
31 test_expect_success
'Float p2 p3 to top' '
33 test "$(echo $(stg series --applied --noprefix))" = "p4 p5 p6 p1 p2 p3"
36 test_expect_success
'Float p5 p1 to top' '
38 test "$(echo $(stg series --applied --noprefix))" = "p4 p6 p2 p3 p5 p1"
41 test_expect_success
'Float p5 to top' '
43 test "$(echo $(stg series --applied --noprefix))" = "p4 p6 p2 p3 p1 p5"
46 test_expect_success
'Float p7 p6 to top' '
48 test "$(echo $(stg series --applied --noprefix))" = "p4 p2 p3 p1 p5 p7 p6"
51 cat > series.txt
<<EOF
60 test_expect_success
'Float with series file' '
61 stg float --series series.txt &&
62 test "$(echo $(stg series --applied --noprefix))" = "p1 p2 p3 p4 p5 p6 p7"
65 cat > rev-series.txt
<<EOF
74 test_expect_success
'Float with series from stdin' '
75 cat rev-series.txt | stg float -s - &&
76 test "$(echo $(stg series --applied --noprefix))" = "p7 p6 p5 p4 p3 p2 p1"
79 test_expect_success
'Attempt float with empty series' '
81 command_error stg float -s - 2>err &&
82 grep -e "No patches to float" err
85 test_expect_success
'Attempt float with series file and arguments' '
86 command_error stg float --series series.txt p1 2>err &&
87 grep -e "<patches> cannot be used with --series" err
90 test_expect_success
'Attempt float with no series file and no arguments' '
91 command_error stg float 2>err &&
92 grep -e "incorrect number of arguments" err
95 test_expect_success
'Series with bogus patch name' '
96 printf "p1\np2\np3\nBOGUS\np4\np5\np6\np7\n" |
97 command_error stg float --series=- 2>& 1 |
98 grep -e "Unknown patch name: BOGUS"