2007-10-12 Frank Lichtenheld <djpig@debian.org>
+ * scripts/t/300_Dpkg_BuildOptions.t: New file.
+ Leads to the following fixes:
* scripts/Dpkg/BuildOptions.pm (parse): Add
- support for nocheck.
+ support for nocheck and make it actually work.
(set): Really set DEB_BUILD_OPTIONS. Discovered
by Daniel Shepler.
unless ($env) { return {}; }
my %opts;
- if ($env =~ s/(noopt|nostrip|nocheck),?//ig) {
+ while ($env =~ s/(noopt|nostrip|nocheck),?//i) {
$opts{lc $1} = '';
- } elsif ($env =~ s/(parallel)=(-?\d+),?//ig) {
+ }
+ while ($env =~ s/(parallel)=(-?\d+),?//i) {
$opts{lc $1} = $2;
}
}
$ENV{DEB_BUILD_OPTIONS} = $env if $env;
+ return $env;
}
1;
--- /dev/null
+# -*- mode: cperl;-*-
+
+use Test::More tests => 6;
+
+use strict;
+use warnings;
+
+use_ok('Dpkg::BuildOptions');
+
+$ENV{DEB_BUILD_OPTIONS} = 'foonostripbar,parallel=3,bazNOCHECK';
+
+my $dbo = Dpkg::BuildOptions::parse();
+
+my %dbo = (
+ nostrip => '',
+ nocheck => '',
+ parallel => 3,
+ );
+my %dbo2 = (
+ nocheck => '',
+ );
+
+
+is_deeply($dbo, \%dbo, 'parse');
+
+$dbo = Dpkg::BuildOptions::parse('no opt,no-strip,parallel = 5,nocheck');
+
+is_deeply($dbo, \%dbo2, 'parse (param)');
+
+$dbo->{parallel} = 5;
+$dbo->{noopt} = '';
+
+my $env = Dpkg::BuildOptions::set($dbo,1);
+
+is($ENV{DEB_BUILD_OPTIONS}, $env, 'set (return value)');
+is_deeply(Dpkg::BuildOptions::parse(), $dbo, 'set (env)');
+
+$ENV{DEB_BUILD_OPTIONS} = 'foobar';
+$dbo = { noopt => '' };
+$env = Dpkg::BuildOptions::set($dbo);
+is($env, "foobar,noopt,", 'set (append)');