summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/t/Dpkg_Changelog.t234
1 files changed, 137 insertions, 97 deletions
diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t
index 1369aeff3..1ca238acd 100644
--- a/scripts/t/Dpkg_Changelog.t
+++ b/scripts/t/Dpkg_Changelog.t
@@ -60,110 +60,150 @@ foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields",
my $all_versions = join( '/', map { $_->get_version() } @data);
sub check_options {
- my ($changes, $data, $options, $count, $versions,
- $check_name) = @_;
-
- my @cnt = $changes->get_range($options);
- cmp_ok( @cnt, '==', $count, "$check_name -> count" );
- if ($count == @$data) {
- is_deeply( \@cnt, $data, "$check_name -> returns all" );
+ my (%opts) = @_;
+ my @cnt = $changes->get_range($opts{range});
+ cmp_ok(@cnt, '==', $opts{count}, "$opts{name} -> count");
+ if ($opts{count} == @{$opts{data}}) {
+ is_deeply(\@cnt, $opts{data}, "$opts{name} -> returns all");
} else {
- is( join( '/', map { $_->get_version() } @cnt),
- $versions, "$check_name -> versions" );
+ is_deeply([ map { $_->get_version() } @cnt ],
+ $opts{versions}, "$opts{name} -> versions" );
}
}
- check_options( $changes, \@data,
- { count => 3 }, 3, '2:2.0-1/1:2.0~rc2-3/1:2.0~rc2-2',
- 'positive count' );
- check_options( $changes, \@data,
- { count => -3 }, 3,
- '1:2.0~rc2-1sarge2/1:2.0~rc2-1sarge1/1.5-1',
- 'negative count' );
- check_options( $changes, \@data,
- { count => 1 }, 1, '2:2.0-1',
- 'count 1' );
- check_options( $changes, \@data,
- { count => 1, default_all => 1 }, 1, '2:2.0-1',
- 'count 1 (d_a 1)' );
- check_options( $changes, \@data,
- { count => -1 }, 1, '1.5-1',
- 'count -1' );
-
- check_options( $changes, \@data,
- { count => 3, offset => 2 }, 3,
- '1:2.0~rc2-2/1:2.0~rc2-1sarge3/1:2.0~rc2-1sarge2',
- 'positive count + positive offset' );
- check_options( $changes, \@data,
- { count => -3, offset => 4 }, 3,
- '1:2.0~rc2-3/1:2.0~rc2-2/1:2.0~rc2-1sarge3',
- 'negative count + positive offset' );
-
- check_options( $changes, \@data,
- { count => 4, offset => 5 }, 2,
- '1:2.0~rc2-1sarge1/1.5-1',
- 'positive count + positive offset (>max)' );
- check_options( $changes, \@data,
- { count => -4, offset => 2 }, 2,
- '2:2.0-1/1:2.0~rc2-3',
- 'negative count + positive offset (<0)' );
-
- check_options( $changes, \@data,
- { count => 3, offset => -4 }, 3,
- '1:2.0~rc2-1sarge3/1:2.0~rc2-1sarge2/1:2.0~rc2-1sarge1',
- 'positive count + negative offset' );
- check_options( $changes, \@data,
- { count => -3, offset => -3 }, 3,
- '1:2.0~rc2-3/1:2.0~rc2-2/1:2.0~rc2-1sarge3',
- 'negative count + negative offset' );
-
- check_options( $changes, \@data,
- { count => 5, offset => -2 }, 2,
- '1:2.0~rc2-1sarge1/1.5-1',
- 'positive count + negative offset (>max)' );
- check_options( $changes, \@data,
- { count => -5, offset => -4 }, 3,
- '2:2.0-1/1:2.0~rc2-3/1:2.0~rc2-2',
- 'negative count + negative offset (<0)' );
-
- check_options( $changes, \@data,
- { count => 7 }, 7, '',
- 'count 7 (max)' );
- check_options( $changes, \@data,
- { count => -7 }, 7, '',
- 'count -7 (-max)' );
- check_options( $changes, \@data,
- { count => 10 }, 7, '',
- 'count 10 (>max)' );
- check_options( $changes, \@data,
- { count => -10 }, 7, '',
- 'count -10 (<-max)' );
-
- check_options( $changes, \@data,
- { from => '1:2.0~rc2-1sarge3' }, 4,
- '2:2.0-1/1:2.0~rc2-3/1:2.0~rc2-2/1:2.0~rc2-1sarge3',
- 'from => "1:2.0~rc2-1sarge3"' );
- check_options( $changes, \@data,
- { since => '1:2.0~rc2-1sarge3' }, 3,
- '2:2.0-1/1:2.0~rc2-3/1:2.0~rc2-2',
- 'since => "1:2.0~rc2-1sarge3"' );
+ my %ref = (
+ changes => $changes,
+ data => \@data,
+ );
+
+ check_options(%ref, range => { count => 3 },
+ count => 3,
+ versions => [ '2:2.0-1', '1:2.0~rc2-3', '1:2.0~rc2-2' ],
+ name => 'positive count');
+ check_options(%ref, range => { count => -3 },
+ count => 3,
+ versions => [
+ '1:2.0~rc2-1sarge2',
+ '1:2.0~rc2-1sarge1',
+ '1.5-1',
+ ],
+ name => 'negative count');
+ check_options(%ref, range => { count => 1 },
+ count => 1,
+ versions => [ '2:2.0-1' ],
+ name => 'count 1');
+ check_options(%ref, range => { count => 1, default_all => 1 },
+ count => 1,
+ versions => [ '2:2.0-1' ],
+ name => 'count 1 (d_a 1)');
+ check_options(%ref, range => { count => -1 },
+ count => 1,
+ versions => [ '1.5-1' ],
+ name => 'count -1');
+
+ check_options(%ref, range => { count => 3, offset => 2 },
+ count => 3,
+ versions => [
+ '1:2.0~rc2-2',
+ '1:2.0~rc2-1sarge3',
+ '1:2.0~rc2-1sarge2',
+ ],
+ name => 'positive count + positive offset');
+ check_options(%ref, range => { count => -3, offset => 4 },
+ count => 3,
+ versions => [
+ '1:2.0~rc2-3',
+ '1:2.0~rc2-2',
+ '1:2.0~rc2-1sarge3',
+ ],
+ name => 'negative count + positive offset');
+
+ check_options(%ref, range => { count => 4, offset => 5 },
+ count => 2,
+ versions => [ '1:2.0~rc2-1sarge1', '1.5-1' ],
+ name => 'positive count + positive offset (>max)');
+ check_options(%ref, range => { count => -4, offset => 2 },
+ count => 2,
+ versions => [ '2:2.0-1', '1:2.0~rc2-3' ],
+ name => 'negative count + positive offset (<0)');
+
+ check_options(%ref, range => { count => 3, offset => -4 },
+ count => 3,
+ versions => [
+ '1:2.0~rc2-1sarge3',
+ '1:2.0~rc2-1sarge2',
+ '1:2.0~rc2-1sarge1',
+ ],
+ name => 'positive count + negative offset');
+ check_options(%ref, range => { count => -3, offset => -3 },
+ count => 3,
+ versions => [
+ '1:2.0~rc2-3',
+ '1:2.0~rc2-2',
+ '1:2.0~rc2-1sarge3',
+ ],
+ name => 'negative count + negative offset');
+
+ check_options(%ref, range => { count => 5, offset => -2 },
+ count => 2,
+ versions => [ '1:2.0~rc2-1sarge1', '1.5-1' ],
+ name => 'positive count + negative offset (>max)');
+ check_options(%ref, range => { count => -5, offset => -4 },
+ count => 3,
+ versions => [ '2:2.0-1', '1:2.0~rc2-3', '1:2.0~rc2-2' ],
+ name => 'negative count + negative offset (<0)');
+
+ check_options(%ref, range => { count => 7 },
+ count => 7,
+ name => 'count 7 (max)');
+ check_options(%ref, range => { count => -7 },
+ count => 7,
+ name => 'count -7 (-max)');
+ check_options(%ref, range => { count => 10 },
+ count => 7,
+ name => 'count 10 (>max)');
+ check_options(%ref, range => { count => -10 },
+ count => 7,
+ name => 'count -10 (<-max)');
+
+ check_options(%ref, range => { from => '1:2.0~rc2-1sarge3' },
+ count => 4,
+ versions => [
+ '2:2.0-1',
+ '1:2.0~rc2-3',
+ '1:2.0~rc2-2',
+ '1:2.0~rc2-1sarge3',
+ ],
+ name => 'from => "1:2.0~rc2-1sarge3"');
+ check_options(%ref, range => { since => '1:2.0~rc2-1sarge3' },
+ count => 3,
+ versions => [
+ '2:2.0-1',
+ '1:2.0~rc2-3',
+ '1:2.0~rc2-2',
+ ],
+ name => 'since => "1:2.0~rc2-1sarge3"');
$SIG{__WARN__} = sub {};
- check_options( $changes, \@data,
- { since => 0 }, 7, '',
- 'since => 0 returns all');
+ check_options(%ref, range => { since => 0 },
+ count => 7,
+ name => 'since => 0 returns all');
delete $SIG{__WARN__};
- check_options( $changes, \@data,
- { to => '1:2.0~rc2-1sarge2' }, 3,
- '1:2.0~rc2-1sarge2/1:2.0~rc2-1sarge1/1.5-1',
- 'to => "1:2.0~rc2-1sarge2"' );
- ## no critic (ControlStructures::ProhibitUntilBlocks)
- check_options( $changes, \@data,
- { until => '1:2.0~rc2-1sarge2' }, 2,
- '1:2.0~rc2-1sarge1/1.5-1',
- 'until => "1:2.0~rc2-1sarge2"' );
- ## use critic
- #TODO: test combinations
+ check_options(%ref, range => { to => '1:2.0~rc2-1sarge2' },
+ count => 3,
+ versions => [
+ '1:2.0~rc2-1sarge2',
+ '1:2.0~rc2-1sarge1',
+ '1.5-1',
+ ],
+ name => 'to => "1:2.0~rc2-1sarge2"');
+ ## no critic (ControlStructures::ProhibitUntilBlocks)
+ check_options(%ref, range => { until => '1:2.0~rc2-1sarge2' },
+ count => 2,
+ versions => [ '1:2.0~rc2-1sarge1', '1.5-1' ],
+ name => 'until => "1:2.0~rc2-1sarge2"');
+ ## use critic
+ #TODO: test combinations
}
if ($file eq "$datadir/fields") {
my $str = $changes->format_range('dpkg', { all => 1 });