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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
# file : tests/pkg-status.testscript
# license : MIT; see accompanying LICENSE file
.include common.testscript \
config.testscript \
remote.testscript \
remote-git.testscript
# Source repository:
#
# pkg-status
# |-- extra -> stable (prerequisite)
# | |-- libbar-1.1.0+1.tar.gz
# | `-- repositories.manifest
# |
# |-- stable
# | |-- libbar-1.0.0.tar.gz
# | |-- libfoo-1.0.0.tar.gz
# | `-- repositories.manifest
# |
# |-- testing -> stable (complement), extra (prerequisite)
# | |-- libbar-1.0.0+1.tar.gz
# | |-- libbar-1.1.0.tar.gz
# | `-- repositories.manifest
# |
# |-- unstable -> testing (complement)
# | |-- libbar-2.0.0.tar.gz
# | `-- repositories.manifest
# |
# `-- git
# |-- libbar.git -> style-basic.git (prerequisite)
# |-- style-basic.git
# `-- style.git
# Prepare repositories used by tests if running in the local mode.
#
+if! $remote
cp -r $src/extra $out/extra
cp -r $src/stable $out/stable
cp -r $src/testing $out/testing
cp -r $src/unstable $out/unstable
c = [cmdline] $rep_create 2>!
$c $out/extra &$out/extra/packages.manifest
$c $out/stable &$out/stable/packages.manifest
$c $out/testing &$out/testing/packages.manifest
$c $out/unstable &$out/unstable/packages.manifest
# Create git repositories.
#
$git_extract $src/git/style.tar
$git_extract $src/git/libbar.tar
$git_extract $src/git/style-basic.tar &$out_git/state0/***
end
rep_add += -d cfg 2>!
rep_fetch += -d cfg --auth all --trust-yes 2>!
pkg_fetch += 2>!
pkg_build += -d cfg --yes 2>!
pkg_purge += -d cfg 2>!
pkg_drop += -d cfg --yes 2>!
: lines
:
{
+$clone_cfg
: basics
:
{
+$clone_cfg
: not-fetched
:
{
+$clone_cfg
: libfoo-1.0.0
:
$clone_cfg;
$* libfoo/1.0.0 >'libfoo unknown 1.0.0'
: libfoo
:
$clone_cfg;
$* libfoo >'libfoo unknown'
}
: rep-fetched
:
{
+$clone_cfg && $rep_add $rep/stable && $rep_fetch
+cp -r cfg ./fetched
+$pkg_fetch libfoo/1.0.0 -d fetched &fetched/libfoo-1.0.0.tar.gz
: libfoo-1.0.0
:
$clone_cfg;
$* libfoo/1.0.0 >'libfoo available 1.0.0'
: libfoo-1.0.0+0
:
$clone_cfg;
$* libfoo/1.0.0+0 >'libfoo available 1.0.0'
: libfoo
:
$clone_cfg;
$* libfoo >'libfoo available 1.0.0'
: pkg-fetched
:
{
clone_cfg = cp -r ../../fetched cfg
: libfoo-1.0.0
:
$clone_cfg;
$* libfoo/1.0.0 >'libfoo fetched 1.0.0'
: libfoo
:
$clone_cfg;
$* libfoo >'libfoo fetched 1.0.0'
}
}
}
: multiple-versions
{
# Prepare the nested tests to copy the root configuration. Note that they
# must provide the destination directory name as an argument.
#
clone_cfg = cp -r $~/../cfg
: extra
:
{
# Here we, first, prepare 2 configurations that derive from each other,
# and then spawn 2 tests on them.
#
+$clone_cfg extra && $rep_add -d extra $rep/extra && $rep_fetch -d extra
+cp -r extra extra-stable
+$rep_add -d extra-stable $rep/stable && $rep_fetch -d extra-stable
: libbar
:
$* -d ../extra libbar >'libbar available 1.1.0+1 [1.0.0]'
: libbar-stable
:
$* -d ../extra-stable libbar >'libbar available 1.1.0+1 1.0.0'
}
: testing
:
{
+$clone_cfg ./ && $rep_add $rep/testing && $rep_fetch
clone_cfg = cp -r ../cfg ./
: no-version
:
{
$clone_cfg;
$* libbar >'libbar available [1.1.0+1] 1.1.0 1.0.0+1 1.0.0'
}
: no-revision
:
{
$clone_cfg;
$* libbar/1.0.0 >'libbar available 1.0.0+1 1.0.0'
}
: zero-revision
:
{
$clone_cfg;
$* libbar/1.0.0+0 >'libbar available 1.0.0'
}
: recursive
:
{
$clone_cfg;
$pkg_build libbar;
$* libbar --recursive >>EOO;
!libbar configured 1.1.0 available [1.1.0+1]
libbaz configured 1.0.0
EOO
$pkg_drop libbar
}
}
: unstable
:
{
# Here we, first, prepare 3 configurations that derive from each other,
# and then spawn 3 tests on them.
#
+$clone_cfg ./ && $rep_add $rep/unstable && $rep_fetch
+cp -r cfg fetched1
+$pkg_fetch libbar/1.0.0+1 -d fetched1 &fetched1/libbar-1.0.0+1.tar.gz
+cp -r fetched1 fetched2
+$pkg_purge -d fetched2 libbar &!fetched2/libbar-1.0.0+1.tar.gz
+$pkg_fetch libbar/2.0.0 -d fetched2 &fetched2/libbar-2.0.0.tar.gz
: not-fetched
:
$* -d ../cfg libbar >'libbar available 2.0.0 [1.1.0+1] 1.1.0 1.0.0+1 1.0.0'
: fetched-1
:
$* -d ../fetched1 libbar >'libbar fetched 1.0.0+1 available 2.0.0 [1.1.0+1] 1.1.0'
: fetched-2
:
$* -d ../fetched2 libbar >'libbar fetched 2.0.0'
}
}
: git-rep
:
if! $git_supported
{
# Skip git repository tests.
#
}
else
{
rep = "$rep_git/state0"
test.cleanups += &cfg/.bpkg/repos/*/***
: complement-cycle
:
: Make sure that we properly handle the root<->style repository dependency
: cycle while searching for the style-basic package, that is an available
: package but not from the user-added repository (or its complement), and
: so is not detected as buildable by the status command. Note that the root
: repository is the default complement for git repositories (see
: rep_fetch() implementation for the reasoning).
:
$clone_root_cfg;
$rep_add "$rep/libbar.git#master" && $rep_add "$rep/style.git#master";
$rep_fetch 2>!;
$* style-basic >~'%style-basic available \[1\.1\.0-a\.0\..+\]%'
}
}
: json
:
{
test.arguments += --stdout-format json
+$clone_cfg
: not-fetched
:
{
+$clone_cfg
: libfoo-1.0.0
:
$clone_cfg;
$* libfoo/1.0.0 >>EOO
[
{
"name": "libfoo",
"status": "unknown",
"version": "1.0.0"
}
]
EOO
: libfoo
:
$clone_cfg;
$* libfoo >>EOO
[
{
"name": "libfoo",
"status": "unknown"
}
]
EOO
}
: fetched
:
{
+$clone_cfg
+$rep_add $rep/testing && $rep_fetch
: recursive
:
{
$clone_cfg;
$pkg_build libbar;
$* libbar --recursive --constraint >>EOO;
[
{
"name": "libbar",
"status": "configured",
"version": "1.1.0",
"hold_package": true,
"available_versions": [
{
"version": "1.1.0+1",
"dependency": true
}
],
"dependencies": [
{
"name": "libbaz",
"constraint": "^1.0.0",
"status": "configured",
"version": "1.0.0"
}
]
}
]
EOO
$pkg_drop libbar
}
}
}
|