| 1 | #!/bin/sh |
| 2 | # Copyright (c) 2006 Karl Hasselström |
| 3 | test_description='Test the delete command (deleting many patches at once).' |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | test_expect_success \ |
| 7 | 'Initialize the StGIT repository' \ |
| 8 | 'stg init' |
| 9 | |
| 10 | test_expect_success \ |
| 11 | 'Create five applied and five unapplied patches' \ |
| 12 | ' |
| 13 | stg new foo0 -m foo0 && |
| 14 | echo foo0 > foo.txt && |
| 15 | stg add foo.txt && |
| 16 | stg refresh && |
| 17 | for i in 1 2 3 4 5 6 7 8 9; do |
| 18 | stg new foo$i -m foo$i && |
| 19 | echo foo$i >> foo.txt && |
| 20 | stg refresh; |
| 21 | done && |
| 22 | stg pop -n 5 |
| 23 | ' |
| 24 | |
| 25 | test_expect_success \ |
| 26 | 'Delete some patches' \ |
| 27 | ' |
| 28 | [ $(stg applied | wc -l) -eq 5 ] && |
| 29 | [ $(stg unapplied | wc -l) -eq 5 ] && |
| 30 | stg delete foo7 foo6 foo3 foo4 && |
| 31 | [ $(stg applied | wc -l) -eq 3 ] && |
| 32 | [ $(stg unapplied | wc -l) -eq 3 ] |
| 33 | ' |
| 34 | |
| 35 | test_expect_success \ |
| 36 | 'Delete some more patches, some of which do not exist' \ |
| 37 | ' |
| 38 | [ $(stg applied | wc -l) -eq 3 ] && |
| 39 | [ $(stg unapplied | wc -l) -eq 3 ] && |
| 40 | ! stg delete foo7 foo8 foo2 foo0 && |
| 41 | [ $(stg applied | wc -l) -eq 3 ] && |
| 42 | [ $(stg unapplied | wc -l) -eq 3 ] |
| 43 | ' |
| 44 | |
| 45 | test_expect_success \ |
| 46 | 'Delete a range of patches' \ |
| 47 | ' |
| 48 | [ $(stg applied | wc -l) -eq 3 ] && |
| 49 | [ $(stg unapplied | wc -l) -eq 3 ] && |
| 50 | stg delete foo1..foo8 && |
| 51 | [ $(stg applied | wc -l) -eq 1 ] && |
| 52 | [ $(stg unapplied | wc -l) -eq 1 ] |
| 53 | ' |
| 54 | |
| 55 | test_done |