File: t2500-clean.sh

package info (click to toggle)
stgit 0.19-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,748 kB
  • sloc: python: 10,558; sh: 5,739; lisp: 2,678; makefile: 142; perl: 42
file content (75 lines) | stat: -rwxr-xr-x 2,184 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh

test_description='Run "stg clean"'

. ./test-lib.sh

test_expect_success 'Initialize StGit stack' '
    stg init &&
    stg new e0 -m e0 &&
    stg new p0 -m p0 &&
    echo foo > foo.txt &&
    stg add foo.txt &&
    stg refresh &&
    stg new e1 -m e1 &&
    stg new e2 -m e2 &&
    stg pop
'

test_expect_success 'Test too many arguments' '
    command_error stg clean p0 2>&1 |
    grep -e "incorrect number of arguments"
'

test_expect_success 'Clean empty patches' '
    [ "$(echo $(stg series --applied --noprefix))" = "e0 p0 e1" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "e2" ] &&
    stg clean &&
    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'

test_expect_success 'Selectively clean applied and unapplied patches' '
    stg new e3 -m e3 &&
    stg new e4 -m e4 &&
    stg pop &&
    stg clean --applied &&
    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "e4" ] &&
    stg clean --unapplied &&
    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'

test_expect_success 'Ensure hidden patches are not cleaned' '
    stg new e5 -m e5 &&
    stg hide e5 &&
    stg clean &&
    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
    [ "$(echo $(stg series --hidden --noprefix))" = "e5" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
    stg unhide e5 &&
    stg clean &&
    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
    [ "$(echo $(stg series --hidden --noprefix))" = "" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'

test_expect_success 'Create a conflict' '
    stg new p1 -m p1 &&
    echo bar > foo.txt &&
    stg refresh &&
    stg pop &&
    stg new p2 -m p2
    echo quux > foo.txt &&
    stg refresh &&
    conflict stg push
'

test_expect_success 'Make sure conflicting patches are preserved' '
    stg clean &&
    [ "$(echo $(stg series --applied --noprefix))" = "p0 p2 p1" ] &&
    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
'

test_done