The following commit has been merged in the master branch:
commit 394e14ffc28160feaa6ef55f4b7ac815a455d1de
Author: Raphaël Hertzog <[email protected]>
Date: Fri Oct 30 11:42:56 2009 +0100
Add supplementary non-regression tests for Dpkg::Changelog related modules
diff --git a/scripts/t/600_Dpkg_Changelog.t b/scripts/t/600_Dpkg_Changelog.t
index 67d26ed..f21f0e2 100644
--- a/scripts/t/600_Dpkg_Changelog.t
+++ b/scripts/t/600_Dpkg_Changelog.t
@@ -8,10 +8,10 @@ use File::Basename;
BEGIN {
my $no_examples = 4;
my $no_err_examples = 1;
- my $no_tests = $no_examples * 4
+ my $no_tests = $no_examples * 5
+ $no_err_examples * 2
+ 26 # countme
- + 2 # fields
+ + 13 # fields
+ 21;
require Test::More;
@@ -32,23 +32,20 @@ foreach my $file ("$srcdir/countme", "$srcdir/shadow",
"$srcdir/fields",
my $changes = Dpkg::Changelog::Debian->new(verbose => 0);
$changes->load($file);
- my $errors = $changes->get_parse_errors();
- my $basename = basename( $file );
-# use Data::Dumper;
-# diag(Dumper($changes));
+ open(CLOG, "<", "$file") || die "Can't open $file\n";
+ my $content = join("", <CLOG>);
+ close(CLOG);
+ cmp_ok($content, 'eq', "$changes", "string output of Dpkg::Changelog on
$file");
+ my $errors = $changes->get_parse_errors();
+ my $basename = basename( $file );
is($errors, '', "Parse example changelog $file without errors" );
my @data = @$changes;
+ ok(@data, "data is not empty");
- ok( @data, "data is not empty" );
-
- my $str = $changes->dpkg();
-
-# is( $str, `dpkg-parsechangelog -l$file`,
-# 'Output of dpkg_str equal to output of dpkg-parsechangelog' );
-
+ my $str;
if ($file eq "$srcdir/countme") {
# test range options
cmp_ok( @data, '==', 7, "no options -> count" );
@@ -172,17 +169,25 @@ Changes:
.
* Upload to stable (Closes: #1111111, #2222222)
.
- fields (2.0-1) unstable; urgency=medium
+ fields (2.0-1) unstable frozen; urgency=medium
.
+ [ Frank Lichtenheld ]
* Upload to unstable (Closes: #1111111, #2222222)
.
+ [ Raphael Hertzog ]
+ * New upstream release.
+ - implements a
+ - implements b
+ * Update S-V.
+ .
fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
.
* Beta
.
- fields (1.0) experimental; urgency=high
+ fields (1.0) experimental; urgency=high,xb-userfield2=foobar
.
* First upload (Closes: #1000000)
+Xb-Userfield2: foobar
Xc-Userfield: foobar
';
cmp_ok($str,'eq',$expected,"fields handling");
@@ -190,16 +195,23 @@ Xc-Userfield: foobar
$str = $changes->dpkg({ offset => 1, count => 2 });
$expected = 'Source: fields
Version: 2.0-1
-Distribution: unstable
+Distribution: unstable frozen
Urgency: medium
Maintainer: Frank Lichtenheld <[email protected]>
Date: Sun, 12 Jan 2008 15:49:19 +0100
Closes: 1111111 2222222
Changes:
- fields (2.0-1) unstable; urgency=medium
+ fields (2.0-1) unstable frozen; urgency=medium
.
+ [ Frank Lichtenheld ]
* Upload to unstable (Closes: #1111111, #2222222)
.
+ [ Raphael Hertzog ]
+ * New upstream release.
+ - implements a
+ - implements b
+ * Update S-V.
+ .
fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
.
* Beta
@@ -207,14 +219,56 @@ Xc-Userfield: foobar
';
cmp_ok($str,'eq',$expected,"fields handling 2");
- }
+ $str = $changes->rfc822({ offset => 2, count => 2 });
+ $expected = 'Source: fields
+Version: 2.0~b1-1
+Distribution: unstable
+Urgency: low
+Maintainer: Frank Lichtenheld <[email protected]>
+Date: Sun, 11 Jan 2008 15:49:19 +0100
+Changes:
+ fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
+ .
+ * Beta
+Xc-Userfield: foobar
-# if ($file eq 'Changes') {
-# my $v = $data[0]->Version;
-# $v =~ s/[a-z]$//;
-# cmp_ok( $v, 'eq', $Parse::DebianChangelog::VERSION,
-# 'version numbers in module and Changes match' );
-# }
+Source: fields
+Version: 1.0
+Distribution: experimental
+Urgency: high
+Maintainer: Frank Lichtenheld <[email protected]>
+Date: Sun, 10 Jan 2008 15:49:19 +0100
+Closes: 1000000
+Changes:
+ fields (1.0) experimental; urgency=high,xb-userfield2=foobar
+ .
+ * First upload (Closes: #1000000)
+Xb-Userfield2: foobar
+
+';
+ cmp_ok($str, 'eq', $expected, "fields handling 3");
+
+ # Test Dpkg::Changelog::Entry methods
+ is($data[1]->get_version(), "2.0-1", "get_version");
+ is($data[1]->get_source(), "fields", "get_source");
+ is(scalar $data[1]->get_distributions(), "unstable",
"get_distribution");
+ is(join("|", $data[1]->get_distributions()), "unstable|frozen",
+ "get_distributions");
+ is($data[3]->get_optional_fields(),
+ "Urgency: high\nCloses: 1000000\nXb-Userfield2: foobar\n",
+ "get_optional_fields");
+ is($data[1]->get_maintainer(), 'Frank Lichtenheld <[email protected]>',
+ "get_maintainer");
+ is($data[1]->get_timestamp(), 'Sun, 12 Jan 2008 15:49:19 +0100',
+ "get_timestamp");
+ my @items = $data[1]->get_change_items();
+ is($items[0], " [ Frank Lichtenheld ]\n", "change items 1");
+ is($items[3], " * New upstream release.
+ - implements a
+ - implements b
+", "change items 2");
+ is($items[4], " * Update S-V.\n", "change items 3");
+ }
SKIP: {
skip("avoid spurious warning with only one entry", 2)
diff --git a/scripts/t/600_Dpkg_Changelog/fields
b/scripts/t/600_Dpkg_Changelog/fields
index 5f08b71..143f2e4 100644
--- a/scripts/t/600_Dpkg_Changelog/fields
+++ b/scripts/t/600_Dpkg_Changelog/fields
@@ -4,10 +4,17 @@ fields (2.0-0etch1) stable; urgency=low
-- Frank Lichtenheld <[email protected]> Sun, 13 Jan 2008 15:49:19 +0100
-fields (2.0-1) unstable; urgency=medium
+fields (2.0-1) unstable frozen; urgency=medium
+ [ Frank Lichtenheld ]
* Upload to unstable (Closes: #1111111, #2222222)
+ [ Raphael Hertzog ]
+ * New upstream release.
+ - implements a
+ - implements b
+ * Update S-V.
+
-- Frank Lichtenheld <[email protected]> Sun, 12 Jan 2008 15:49:19 +0100
fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
@@ -16,8 +23,16 @@ fields (2.0~b1-1) unstable; urgency=low,xc-userfield=foobar
-- Frank Lichtenheld <[email protected]> Sun, 11 Jan 2008 15:49:19 +0100
-fields (1.0) experimental; urgency=high
+fields (1.0) experimental; urgency=high,xb-userfield2=foobar
* First upload (Closes: #1000000)
-- Frank Lichtenheld <[email protected]> Sun, 10 Jan 2008 15:49:19 +0100
+
+fields (0.5) experimental
+
+ * This entry is in an older changelog format and it should not be
+ parsed. So let's put some non-conforming content.
+
+This line starts on the first column.
+-- Raphael Hertzog
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]