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
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Debian::Debhelper::Sequence;
use Debian::Debhelper::SequencerUtil;
# Shorten variants of the sequences.
my @bd = (qw{
dh_testdir
dh_auto_configure
dh_auto_build
dh_auto_test
});
my @i = (qw{
dh_testroot
dh_prep
dh_auto_install
dh_install
dh_missing
});
my @ba = (
{
'command' => 'dh_strip',
'command-options' => [],
'sequence-limitation' => SEQUENCE_TYPE_ARCH_ONLY,
},
{
'command' => 'dh_makeshlibs',
'command-options' => [],
'sequence-limitation' => SEQUENCE_TYPE_ARCH_ONLY,
},
{
'command' => 'dh_shlibdeps',
'command-options' => [],
'sequence-limitation' => SEQUENCE_TYPE_ARCH_ONLY,
}
);
my @b=qw{
dh_installdeb
dh_gencontrol
dh_builddeb
};
my @c=qw{
dh_testdir
dh_auto_clean
dh_clean
};
my %sequences;
sub _add_sequence {
my @args = @_;
my $seq = Debian::Debhelper::Sequence->new(@args);
my $name = $seq->name;
$sequences{$name} = $seq;
if ($seq->allowed_subsequences eq SEQUENCE_ARCH_INDEP_SUBSEQUENCES) {
for my $subseq ((SEQUENCE_TYPE_ARCH_ONLY, SEQUENCE_TYPE_INDEP_ONLY)) {
my $subname = "${name}-${subseq}";
$sequences{$subname} = $seq;
}
}
return;
}
_add_sequence('build', SEQUENCE_ARCH_INDEP_SUBSEQUENCES, @bd);
_add_sequence('install', SEQUENCE_ARCH_INDEP_SUBSEQUENCES, to_rules_target("build"), @i);
_add_sequence('binary', SEQUENCE_ARCH_INDEP_SUBSEQUENCES, to_rules_target("install"), @ba, @b);
_add_sequence('clean', SEQUENCE_NO_SUBSEQUENCES, @c);
sub _cmd_names {
my (@input) = @_;
my @cmds;
for my $cmd (@input) {
if (ref($cmd) eq 'HASH') {
push(@cmds, $cmd->{'command'});
} else {
push(@cmds, $cmd);
}
}
return \@cmds;
}
my %sequences_unpacked = (
'build-indep' => _cmd_names(@bd),
'build-arch' => _cmd_names(@bd),
'build' => _cmd_names(@bd),
'install-indep' => _cmd_names(@bd, @i),
'install-arch' => _cmd_names(@bd, @i),
'install' => _cmd_names(@bd, @i),
'binary-indep' => _cmd_names(@bd, @i, @b),
'binary-arch' => _cmd_names(@bd, @i, @ba, @b),
'binary' => _cmd_names(@bd, @i, @ba, @b),
'clean' => _cmd_names(@c),
);
plan tests => 21 + 3 * scalar(keys(%sequences));
# We will horse around with %EXPLICIT_TARGETS in this test; it should
# definitely not attempt to read d/rules or the test will be break.
$Debian::Debhelper::SequencerUtil::RULES_PARSED = 1;
is_deeply(
[unpack_sequence(\%sequences, 'build')],
[[], $sequences_unpacked{'build'}],
'Inlined build sequence matches build-indep/build-arch');
is_deeply(
[unpack_sequence(\%sequences, 'install')],
[[], $sequences_unpacked{'install'}],
'Inlined install sequence matches build-indep/build-arch + install commands');
is_deeply(
[unpack_sequence(\%sequences, 'binary-arch')],
[[], $sequences_unpacked{'binary-arch'}],
'Inlined binary-arch sequence has all the commands');
is_deeply(
[unpack_sequence(\%sequences, 'binary-indep')],
[[], $sequences_unpacked{'binary-indep'}],
'Inlined binary-indep sequence has all the commands except @bd');
is_deeply(
[unpack_sequence(\%sequences, 'binary')],
[[], $sequences_unpacked{'binary'}],
'Inlined binary sequence has all the commands');
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, { 'build' => 1, 'build-arch' => 1, 'build-indep' => 1})],
[[], _cmd_names(@i, @ba, @b)],
'Inlined binary sequence with build-* done has @i, @ba and @b');
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, { 'build-arch' => 1, 'build-indep' => 1})],
[[], _cmd_names(@i, @ba, @b)],
'Inlined binary sequence with build-* done has @i, @ba and @b');
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, {}, 0)],
[[], _cmd_names(@bd, @i, @ba, @b)],
'Inlined binary sequence and arch:all + arch:any is reduced to @bd, @i, @ba and @b');
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, {}, FLAG_OPT_SOURCE_BUILDS_NO_ARCH_PACKAGES)],
[[], _cmd_names(@bd, @i, @b)],
'Inlined binary sequence and not arch:any is reduced to @bd, @i and @b');
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, {}, FLAG_OPT_SOURCE_BUILDS_NO_INDEP_PACKAGES)],
[[], _cmd_names(@bd, @i, @ba, @b)],
'Inlined binary sequence and not arch:all is reduced to @bd, @i, @ba and @b');
{
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'build-arch'} = 1;
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'build-indep'} = 1;
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, { 'build-arch' => 1, 'build-indep' => 1})],
[[], _cmd_names(@i, @ba, @b)],
'Inlined binary sequence with build-* done has @i, @ba and @b');
my $actual = [unpack_sequence(\%sequences, 'binary')];
# @i should be "-i"-only, @ba + @b should be both.
# Unfortunately, unpack_sequence cannot show that.
my $expected = [[to_rules_target('build-arch'), to_rules_target('build-indep')], _cmd_names(@i, @ba, @b)];
# Permit some fuzz on the order between build-arch and build-arch
if ($actual->[0][0] eq to_rules_target('build-indep')) {
$expected->[0][0] = to_rules_target('build-indep');
$expected->[0][1] = to_rules_target('build-arch');
}
is_deeply(
$actual,
$expected,
'Inlined binary sequence with explicit build-* has explicit d/rules build-{arch,indep} + @i, @ba, @b');
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, { 'build' => 1})],
[[], _cmd_names(@i, @ba, @b)],
'Inlined binary sequence with explicit build-* but done build has only @i, @ba and @b');
}
{
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'build-indep'} = 1;
is_deeply(
[ unpack_sequence(\%sequences, 'binary', 0, { 'build-arch' => 1 }) ],
[ [to_rules_target('build-indep')], _cmd_names(@i, @ba, @b) ],
'Inlined binary sequence with build-arch done and build-indep explicit has d/rules build-indep + @i, @ba and @b');
is_deeply(
[ unpack_sequence(\%sequences, 'binary-arch', 0, { 'build-arch' => 1 }) ],
[ [], _cmd_names(@i, @ba, @b) ],
'Inlined binary-arch sequence with build-arch done and build-indep explicit has @i, @ba and @b');
is_deeply(
[ unpack_sequence(\%sequences, 'binary-indep', 0, { 'build-arch' => 1 }) ],
[ [to_rules_target('build-indep')], _cmd_names(@i, @b) ],
'Inlined binary-indep sequence with build-arch done and build-indep explicit has d/rules build-indep + @i and @b');
}
{
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'build'} = 1;
is_deeply(
[unpack_sequence(\%sequences, 'binary')],
[[to_rules_target('build')], _cmd_names(@i, @ba, @b)],
'Inlined binary sequence has all the commands but build target is opaque');
is_deeply(
[unpack_sequence(\%sequences, 'binary', 0, { 'build' => 1, 'build-arch' => 1, 'build-indep' => 1})],
[[], _cmd_names(@i, @ba, @b)],
'Inlined binary sequence has all the commands with build-* done and not build-target');
is_deeply(
[unpack_sequence(\%sequences, 'build')],
[[], $sequences_unpacked{'build'}],
'build sequence is inlineable');
# Compat <= 8 ignores explicit targets!
for my $seq_name (sort(keys(%sequences))) {
is_deeply(
[unpack_sequence(\%sequences, $seq_name, 1)],
[[], $sequences_unpacked{$seq_name}],
"Compat <= 8 ignores explicit build target in sequence ${seq_name}");
}
}
{
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'install-arch'} = 1;
is_deeply(
[unpack_sequence(\%sequences, 'binary')],
# @bd_minimal, @bd and @i should be "-i"-only, @ba + @b should be both.
# Unfortunately, unpack_sequence cannot show that.
[[to_rules_target('install-arch')], _cmd_names(@bd, @i, @ba, @b)],
'Inlined binary sequence has all the commands');
# Compat <= 8 ignores explicit targets!
for my $seq_name (sort(keys(%sequences))) {
is_deeply(
[unpack_sequence(\%sequences, $seq_name, 1)],
[[], $sequences_unpacked{$seq_name}],
"Compat <= 8 ignores explicit install-arch target in sequence ${seq_name}");
}
}
{
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'install-arch'} = 1;
local $Debian::Debhelper::SequencerUtil::EXPLICIT_TARGETS{'build'} = 1;
my $actual = [unpack_sequence(\%sequences, 'binary')];
# @i should be "-i"-only, @ba + @b should be both.
# Unfortunately, unpack_sequence cannot show that.
my $expected = [[to_rules_target('build'), to_rules_target('install-arch')], _cmd_names(@i, @ba, @b)];
# Permit some fuzz on the order between build and install-arch
if ($actual->[0][0] eq to_rules_target('install-arch')) {
$expected->[0][0] = to_rules_target('install-arch');
$expected->[0][1] = to_rules_target('build');
}
is_deeply(
$actual,
$expected,
'Inlined binary sequence has all the commands');
# Compat <= 8 ignores explicit targets!
for my $seq_name (sort(keys(%sequences))) {
is_deeply(
[unpack_sequence(\%sequences, $seq_name, 1)],
[[], $sequences_unpacked{$seq_name}],
"Compat <= 8 ignores explicit build + install-arch targets in sequence ${seq_name}");
}
}
|