File: t4200-import-s.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 (297 lines) | stat: -rwxr-xr-x 6,341 bytes parent folder | download | duplicates (4)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/sh

# Copyright (c) 2015 Vincent Legoll

test_description='Test the import -s command'

. ./test-lib.sh

quilt --version 2> /dev/null

if [ "$?" = "127" ]
then
  echo "Cannot execute quilt, skipping this test..."
  test_done
  exit 0
fi

prepare_test_env () {
    # Initialize git tree
    mkdir s
    echo 0 > t
    echo 0 > s/u
    git add t s/u
    git commit -a -m initial

    # Initialize patch stacking tool
    stg init
}

cleanup_test () {
     stg delete ..
     rm -r patches .pc
}

after_test () {
    # Revert to master status : undedit files
    quilt pop -a
}

check_test () {
    # Test importing quilt series
     stg import -s patches/series
}

test_import_quilt_series_empty () {
    # Test empty patch
    quilt new empty.diff
    quilt refresh
}

test_import_quilt_series_comment_whitespace () {
    quilt new patch_before_comment.diff
    quilt add t
    echo 1 > t
    quilt refresh

    # Test comment indentation
    echo "# Test comment at beginning-of-line" >> patches/series
    echo " # Test <SPACE> character before comment" >> patches/series
    echo "	# Test <TAB> character before comment" >> patches/series

    quilt new patch_after_comments.diff
    quilt add t
    echo 2 > t
    quilt refresh
}

test_import_quilt_series_toplevel () {
    # Top-level edits

    quilt new patch.diff
    quilt add t
    echo 1 > t
    quilt refresh

    quilt new -p 0 patch-p0.diff
    quilt add t
    echo 2 > t
    quilt refresh

    quilt new -p 1 patch-p1.diff
    quilt add t
    echo 3 > t
    quilt refresh

    quilt new -p ab patch-pab.diff
    quilt add t
    echo 4 > t
    quilt refresh
}

test_import_quilt_series_subdir () {
    # Subdirectory edits

    quilt new patch-s.diff
    quilt add s/u
    echo 1 > s/u
    quilt refresh

    quilt new -p 0 patch-p0-s.diff
    quilt add s/u
    echo 2 > s/u
    quilt refresh

    quilt new -p 1 patch-p1-s.diff
    quilt add s/u
    echo 3 > s/u
    quilt refresh

    quilt new -p ab patch-pab-s.diff
    quilt add s/u
    echo 4 > s/u
    quilt refresh
}

test_import_quilt_series_should_fail_p_something_ok () {
    quilt new -p $1 patch-p$1.diff
    quilt add t
    echo 4 > t
    quilt refresh

    quilt new -p $1 patch-p$1-s.diff
    quilt add s/u
    echo 4 > s/u
    quilt refresh
}

test_import_quilt_series_should_fail_p_something_unexpected () {
    quilt new patch-p$1.diff
    quilt add t
    echo 4 > t
    quilt refresh

    quilt new patch-p$1-s.diff
    quilt add s/u
    echo 4 > s/u
    quilt refresh
}

test_expect_success \
    'Test quilt presence' \
    'quilt --version'

prepare_test_env

test_expect_success \
    'Import a quilt series with an empty patch' \
    'test_import_quilt_series_empty &&
     after_test &&
     check_test &&
     cleanup_test
    '

test_expect_success \
    'Import a quilt series with indented comments' \
    'test_import_quilt_series_comment_whitespace &&
     after_test &&
     check_test &&
     cleanup_test
    '

test_expect_success \
    'Import a quilt series with patches for toplevel files' \
    'test_import_quilt_series_toplevel &&
     after_test &&
     check_test &&
     cleanup_test
    '

test_expect_success \
    'Import a quilt series with patches for subdirectories files' \
    'test_import_quilt_series_subdir &&
     after_test &&
     check_test &&
     cleanup_test
    '

test_expect_code \
    2 \
    'Import a quilt series with unexpected "-p" in series' \
    'test_import_quilt_series_should_fail_p_something_unexpected '' &&
     after_test &&
     sed -e "s/^\(.*\)$/\1 -p/g" patches/series > series_messed &&
     mv series_messed patches/series &&
     check_test &&
     cleanup_test
    '

test_expect_code \
    2 \
    'Import a quilt series with unexpected "-p1" in series' \
    'test_import_quilt_series_should_fail_p_something_ok 1 &&
     after_test &&
     sed -e "s/^\(.*\)$/\1 -p1/g" patches/series > series_messed &&
     mv series_messed patches/series &&
     check_test &&
     cleanup_test
    '

test_expect_code \
    2 \
    'Import a quilt series with unexpected "-pab" in series' \
    'test_import_quilt_series_should_fail_p_something_ok ab &&
     after_test &&
     sed -e "s/^\(.*\)$/\1 -pab/g" patches/series > series_messed &&
     mv series_messed patches/series &&
     check_test &&
     cleanup_test
    '

test_expect_code \
    2 \
    'Import a quilt series with unexpected "-p000" in series' \
    'test_import_quilt_series_should_fail_p_something_unexpected 000 &&
     after_test &&
     sed -e "s/^\(.*\)$/\1 -p000/g" patches/series > series_messed &&
     mv series_messed patches/series &&
     check_test &&
     cleanup_test
    '

test_expect_code \
    2 \
    'Import a quilt series with unexpected "-p42" in series' \
    'test_import_quilt_series_should_fail_p_something_unexpected 42 &&
     after_test &&
     sed -e "s/^\(.*\)$/\1 -p42/g" patches/series > series_messed &&
     mv series_messed patches/series &&
     check_test &&
     cleanup_test
    '

test_expect_code \
    2 \
    'Import a quilt series with unexpected "-pYo" in series' \
    'test_import_quilt_series_should_fail_p_something_unexpected Yo &&
     after_test &&
     sed -e "s/^\(.*\)$/\1 -pYo/g" patches/series > series_messed &&
     mv series_messed patches/series &&
     check_test &&
     cleanup_test
    '

test_filename_with_spaces () {
    echo 1 > 'filename with space.txt'

    git add 'filename with space.txt'
    git commit -m initial

    quilt new patch-test-space-fn.diff
    quilt add 'filename with space.txt'

    echo 2 > 'filename with space.txt'

    quilt refresh
    quilt pop -a

    stg import -s patches/series
    stg series
}

test_subdir_patches () {
    echo 1 > 'filename.txt'

    git add 'filename.txt'
    git commit -m initial

    quilt new d1/patch-test-subdir-patches.diff
    quilt add 'filename.txt'

    echo 2 > 'filename.txt'

    quilt refresh

    quilt new d2/patch-test-subdir-patches.diff
    quilt add 'filename.txt'

    echo 3 > 'filename.txt'

    quilt refresh
    quilt pop -a

    stg import -s patches/series
    stg series
}

test_expect_success 'Quilt import filename with spaces' \
    'test_filename_with_spaces && \
     stg delete ..
    '

test_expect_success 'Quilt import series with subdirs' \
    'test_subdir_patches && \
     stg delete ..
    '

test_done