File: t1600-delete-one.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 (144 lines) | stat: -rwxr-xr-x 3,217 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
# Copyright (c) 2006 Karl Hasselström
test_description='Test the delete command (deleting one patch at a time).'
. ./test-lib.sh

test_expect_success \
    'Initialize the StGIT repository' \
    'stg init'

test_expect_success \
    'Create a patch' \
    '
    stg new foo -m foo &&
    echo foo > foo.txt &&
    stg add foo.txt &&
    stg refresh
    '

test_expect_success \
    'Invalid arguments' \
    '
    command_error stg delete --top foo 2>&1 |
    grep -e "Either --top or patches must be specified"
    '

test_expect_success \
    'Attempt delete --top with none applied' \
    '
    stg pop &&
    command_error stg delete --top 2>&1 |
    grep -e "No patches applied" &&
    stg push
    '

test_expect_success \
    'No patches specified' \
    '
    command_error stg delete 2>&1 |
    grep -e "No patches specified"
    '

test_expect_success \
    'Try to delete a non-existing patch' \
    '
    [ $(stg series --applied -c) -eq 1 ] &&
    command_error stg delete bar &&
    [ $(stg series --applied -c) -eq 1 ]
    '

test_expect_success \
    'Try to delete the topmost patch while dirty' \
    '
    echo dirty >> foo.txt &&
    [ $(stg series --applied -c) -eq 1 ] &&
    command_error stg delete foo &&
    [ $(stg series --applied -c) -eq 1 ] &&
    git reset --hard
    '

test_expect_success \
    'Delete the topmost patch' \
    '
    [ $(stg series --applied -c) -eq 1 ] &&
    stg delete foo &&
    [ $(stg series --applied -c) -eq 0 ]
    '

test_expect_success \
    'Create an unapplied patch' \
    '
    stg new foo -m foo &&
    echo foo > foo.txt &&
    stg add foo.txt &&
    stg refresh &&
    stg pop
    '

test_expect_success \
    'Delete an unapplied patch' \
    '
    [ $(stg series --unapplied -c) -eq 1 ] &&
    stg delete foo &&
    [ $(stg series --unapplied -c) -eq 0 ]
    '

test_expect_success \
    'Create three patches' \
    '
    stg new foo -m foo &&
    echo foo > foo.txt &&
    stg add foo.txt &&
    stg refresh &&
    stg new bar -m bar &&
    echo bar > bar.txt &&
    stg add bar.txt &&
    stg refresh &&
    stg new baz -m baz &&
    echo baz > baz.txt &&
    stg add baz.txt &&
    stg refresh
    '

test_expect_success \
    'Try to delete a topmost patch with --top option' \
    '
    [ $(stg series --applied -c) -eq 3 ] &&
    stg delete --top &&
    [ $(stg series --applied -c) -eq 2 ]
    '

test_expect_success \
    'Try to delete a non-topmost applied patch' \
    '
    [ $(stg series --applied -c) -eq 2 ] &&
    stg delete foo &&
    [ $(stg series --applied -c) -eq 1 ]
    '

test_expect_success \
    'Create another branch, and put one patch in each branch' \
    '
    stg branch --create br &&
    stg new baz -m baz &&
    echo baz > baz.txt &&
    stg add baz.txt &&
    stg refresh &&
    stg branch master &&
    stg new baz -m baz &&
    echo baz > baz.txt &&
    stg add baz.txt &&
    stg refresh
    '

test_expect_success \
    'Delete a patch in another branch' \
    '
    [ $(stg series --applied -c) -eq 2 ] &&
    [ $(stg series --applied -b br -c) -eq 1 ] &&
    stg delete -b br baz &&
    [ $(stg series --applied -c) -eq 2 ] &&
    [ $(stg series --applied -b br -c) -eq 0 ]
    '

test_done