3 test_description
='Run "stg clean"'
7 test_expect_success
'Initialize StGit stack' '
19 test_expect_success
'Test too many arguments' '
20 command_error stg clean p0 2>&1 |
21 grep -e "incorrect number of arguments"
24 test_expect_success
'Clean empty patches' '
25 [ "$(echo $(stg series --applied --noprefix))" = "e0 p0 e1" ] &&
26 [ "$(echo $(stg series --unapplied --noprefix))" = "e2" ] &&
28 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
29 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
32 test_expect_success
'Selectively clean applied and unapplied patches' '
36 stg clean --applied &&
37 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
38 [ "$(echo $(stg series --unapplied --noprefix))" = "e4" ] &&
39 stg clean --unapplied &&
40 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
41 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
44 test_expect_success
'Ensure hidden patches are not cleaned' '
48 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
49 [ "$(echo $(stg series --hidden --noprefix))" = "e5" ] &&
50 [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
53 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
54 [ "$(echo $(stg series --hidden --noprefix))" = "" ] &&
55 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
58 test_expect_success
'Create a conflict' '
64 echo quux > foo.txt &&
69 test_expect_success
'Make sure conflicting patches are preserved' '
71 [ "$(echo $(stg series --applied --noprefix))" = "p0 p2 p1" ] &&
72 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]