| 1 | #!/bin/sh |
| 2 | test_description='Test "stg delete --spill"' |
| 3 | . ./test-lib.sh |
| 4 | |
| 5 | test_expect_success 'Initialize the StGIT repository' ' |
| 6 | stg init |
| 7 | ' |
| 8 | |
| 9 | test_expect_success 'Create five applied and three unapplied patches' ' |
| 10 | for i in 0 1 2 3 4 5 6 7; do |
| 11 | echo $i >> foo && |
| 12 | git add foo && |
| 13 | git commit -m p$i |
| 14 | done |
| 15 | stg uncommit -n 8 && |
| 16 | stg pop -n 3 |
| 17 | ' |
| 18 | |
| 19 | test_expect_success 'Try to delete --spill an unapplied patch' ' |
| 20 | command_error stg delete --spill p7 && |
| 21 | test "$(echo $(stg series))" = "+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7" && |
| 22 | test "$(echo $(cat foo))" = "0 1 2 3 4" && |
| 23 | test "$(echo $(git diff-files))" = "" |
| 24 | ' |
| 25 | |
| 26 | test_expect_success 'Try to delete --spill a non-top patch' ' |
| 27 | command_error stg delete --spill p2 && |
| 28 | test "$(echo $(stg series))" = "+ p0 + p1 + p2 + p3 > p4 - p5 - p6 - p7" && |
| 29 | test "$(echo $(cat foo))" = "0 1 2 3 4" && |
| 30 | test "$(echo $(git diff-files))" = "" |
| 31 | ' |
| 32 | |
| 33 | test_expect_success 'Delete --spill one patch' ' |
| 34 | stg delete --spill p4 && |
| 35 | test "$(echo $(stg series))" = "+ p0 + p1 + p2 > p3 - p5 - p6 - p7" && |
| 36 | test "$(echo $(cat foo))" = "0 1 2 3 4" && |
| 37 | test "$(echo $(git diff-files))" = "" |
| 38 | ' |
| 39 | |
| 40 | test_expect_success 'Delete --spill several patches' ' |
| 41 | stg delete --spill p2 p3 p1 && |
| 42 | test "$(echo $(stg series))" = "> p0 - p5 - p6 - p7" && |
| 43 | test "$(echo $(cat foo))" = "0 1 2 3 4" && |
| 44 | test "$(echo $(git diff-files))" = "" |
| 45 | ' |
| 46 | |
| 47 | test_done |