Forráskód Böngészése

Add tests for Ubuntu changelog parsing

Ubuntu's changelog parsing is nearly identical to Debian's, but may emit
an additional Launchpad-Bugs-Fixed header. Test that changelogs
matching the appropriate regex are parsed correctly both for Debian and
Ubuntu.

To do this, we take copies of the standard origin files and add an
internal mechanism allowing Dpkg::Vendor to be pointed at them; and we
run 600_Dpkg_Changelog.t a second time with DEB_VENDOR set, to avoid
duplicating lots of code. See the discussion in #536066 for background.
Colin Watson 16 éve
szülő
commit
2d4fd627d4

+ 2 - 0
debian/changelog

@@ -6,6 +6,8 @@ dpkg (1.15.8) UNRELEASED; urgency=low
     start and at the end of the process. With "3.0 (quilt)" source packages
     start and at the end of the process. With "3.0 (quilt)" source packages
     this ensures patches are applied even in case of binary-only builds.
     this ensures patches are applied even in case of binary-only builds.
     Closes: #572526
     Closes: #572526
+  * Merge non-regression test for Ubuntu's specificities concerning
+    changelog handling. Closes: #582389
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Require gettext 0.18:
   * Require gettext 0.18:

+ 4 - 1
scripts/Dpkg/Vendor.pm

@@ -28,6 +28,9 @@ use base qw(Exporter);
 our @EXPORT_OK = qw(get_vendor_info get_current_vendor get_vendor_file
 our @EXPORT_OK = qw(get_vendor_info get_current_vendor get_vendor_file
                     get_vendor_object run_vendor_hook);
                     get_vendor_object run_vendor_hook);
 
 
+my $origins = "/etc/dpkg/origins";
+$origins = $ENV{DPKG_ORIGINS_DIR} if $ENV{DPKG_ORIGINS_DIR};
+
 =encoding utf8
 =encoding utf8
 
 
 =head1 NAME
 =head1 NAME
@@ -84,7 +87,7 @@ sub get_vendor_file(;$) {
         push @tries, $vendor, lc($vendor), ucfirst($vendor), ucfirst(lc($vendor));
         push @tries, $vendor, lc($vendor), ucfirst($vendor), ucfirst(lc($vendor));
     }
     }
     foreach my $name (@tries) {
     foreach my $name (@tries) {
-        $file = "/etc/dpkg/origins/$name" if -e "/etc/dpkg/origins/$name";
+        $file = "$origins/$name" if -e "$origins/$name";
     }
     }
     return $file;
     return $file;
 }
 }

+ 2 - 0
scripts/Makefile.am

@@ -186,6 +186,7 @@ test_cases = \
 	t/400_Dpkg_Deps.t \
 	t/400_Dpkg_Deps.t \
 	t/500_Dpkg_Path.t \
 	t/500_Dpkg_Path.t \
 	t/600_Dpkg_Changelog.t \
 	t/600_Dpkg_Changelog.t \
+	t/600_Dpkg_Changelog_Ubuntu.t \
 	t/700_Dpkg_Control.t \
 	t/700_Dpkg_Control.t \
 	t/750_Dpkg_Substvars.t \
 	t/750_Dpkg_Substvars.t \
 	t/800_Dpkg_IPC.t \
 	t/800_Dpkg_IPC.t \
@@ -243,6 +244,7 @@ check: $(test_data) $(test_cases)
 	$(mkdir_p) $(test_tmpdir)
 	$(mkdir_p) $(test_tmpdir)
 	PATH="$(top_builddir)/src:$(top_builddir)/scripts:$(PATH)" \
 	PATH="$(top_builddir)/src:$(top_builddir)/scripts:$(PATH)" \
 	  srcdir=$(srcdir) DPKG_DATADIR=$(srcdir)/.. \
 	  srcdir=$(srcdir) DPKG_DATADIR=$(srcdir)/.. \
+	  DPKG_ORIGINS_DIR=$(srcdir)/t/origins \
 	  PERL5LIB=$(srcdir) PERL_DL_NONLAZY=1 \
 	  PERL5LIB=$(srcdir) PERL_DL_NONLAZY=1 \
 	  $(PERL) -I$(srcdir) -MExtUtils::Command::MM \
 	  $(PERL) -I$(srcdir) -MExtUtils::Command::MM \
 	          -e "test_harness($(TEST_VERBOSE), '.')" \
 	          -e "test_harness($(TEST_VERBOSE), '.')" \

+ 15 - 3
scripts/t/600_Dpkg_Changelog.t

@@ -25,7 +25,7 @@ BEGIN {
 	+ $no_err_examples * 2
 	+ $no_err_examples * 2
 	+ 26 # countme
 	+ 26 # countme
 	+ 13 # fields
 	+ 13 # fields
-	+ 21;
+	+ 22;
 
 
     require Test::More;
     require Test::More;
     import Test::More tests => $no_tests;
     import Test::More tests => $no_tests;
@@ -33,11 +33,14 @@ BEGIN {
 BEGIN {
 BEGIN {
     use_ok('Dpkg::Changelog');
     use_ok('Dpkg::Changelog');
     use_ok('Dpkg::Changelog::Debian');
     use_ok('Dpkg::Changelog::Debian');
+    use_ok('Dpkg::Vendor', qw(get_current_vendor));
 };
 };
 
 
 my $srcdir = $ENV{srcdir} || '.';
 my $srcdir = $ENV{srcdir} || '.';
 my $datadir = $srcdir . '/t/600_Dpkg_Changelog';
 my $datadir = $srcdir . '/t/600_Dpkg_Changelog';
 
 
+my $vendor = get_current_vendor();
+
 #########################
 #########################
 
 
 foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields",
 foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields",
@@ -181,11 +184,13 @@ Changes:
  fields (2.0-0etch1) stable; urgency=low
  fields (2.0-0etch1) stable; urgency=low
  .
  .
    * Upload to stable (Closes: #1111111, #2222222)
    * Upload to stable (Closes: #1111111, #2222222)
+   * Fix more stuff. (LP: #54321, #2424242)
  .
  .
  fields (2.0-1) unstable  frozen; urgency=medium
  fields (2.0-1) unstable  frozen; urgency=medium
  .
  .
    [ Frank Lichtenheld ]
    [ Frank Lichtenheld ]
    * Upload to unstable (Closes: #1111111, #2222222)
    * Upload to unstable (Closes: #1111111, #2222222)
+   * Fix stuff. (LP: #12345, #424242)
  .
  .
    [ Raphaël Hertzog ]
    [ Raphaël Hertzog ]
    * New upstream release.
    * New upstream release.
@@ -203,6 +208,9 @@ Changes:
 Xb-Userfield2: foobar
 Xb-Userfield2: foobar
 Xc-Userfield: foobar
 Xc-Userfield: foobar
 ';
 ';
+	if ($vendor eq 'Ubuntu') {
+	    $expected =~ s/^(Closes:.*)/$1\nLaunchpad-Bugs-Fixed: 12345 54321 424242 2424242/m;
+	}
 	cmp_ok($str,'eq',$expected,"fields handling");
 	cmp_ok($str,'eq',$expected,"fields handling");
 
 
 	$str = $changes->dpkg({ offset => 1, count => 2 });
 	$str = $changes->dpkg({ offset => 1, count => 2 });
@@ -218,6 +226,7 @@ Changes:
  .
  .
    [ Frank Lichtenheld ]
    [ Frank Lichtenheld ]
    * Upload to unstable (Closes: #1111111, #2222222)
    * Upload to unstable (Closes: #1111111, #2222222)
+   * Fix stuff. (LP: #12345, #424242)
  .
  .
    [ Raphaël Hertzog ]
    [ Raphaël Hertzog ]
    * New upstream release.
    * New upstream release.
@@ -230,6 +239,9 @@ Changes:
    * Beta
    * Beta
 Xc-Userfield: foobar
 Xc-Userfield: foobar
 ';
 ';
+	if ($vendor eq 'Ubuntu') {
+	    $expected =~ s/^(Closes:.*)/$1\nLaunchpad-Bugs-Fixed: 12345 424242/m;
+	}
 	cmp_ok($str,'eq',$expected,"fields handling 2");
 	cmp_ok($str,'eq',$expected,"fields handling 2");
 
 
 	$str = $changes->rfc822({ offset => 2, count => 2 });
 	$str = $changes->rfc822({ offset => 2, count => 2 });
@@ -276,11 +288,11 @@ Xb-Userfield2: foobar
 	    "get_timestamp");
 	    "get_timestamp");
 	my @items = $data[1]->get_change_items();
 	my @items = $data[1]->get_change_items();
 	is($items[0], "  [ Frank Lichtenheld ]\n", "change items 1");
 	is($items[0], "  [ Frank Lichtenheld ]\n", "change items 1");
-	is($items[3], "  * New upstream release.
+	is($items[4], "  * New upstream release.
     - implements a
     - implements a
     - implements b
     - implements b
 ", "change items 2");
 ", "change items 2");
-	is($items[4], "  * Update S-V.\n", "change items 3");
+	is($items[5], "  * Update S-V.\n", "change items 3");
     }
     }
 
 
     SKIP: {
     SKIP: {

+ 2 - 0
scripts/t/600_Dpkg_Changelog/fields

@@ -1,6 +1,7 @@
 fields (2.0-0etch1) stable; urgency=low
 fields (2.0-0etch1) stable; urgency=low
 
 
   * Upload to stable (Closes: #1111111, #2222222)
   * Upload to stable (Closes: #1111111, #2222222)
+  * Fix more stuff. (LP: #54321, #2424242)
 
 
  -- Frank Lichtenheld <frank@lichtenheld.de>  Sun, 13 Jan 2008 15:49:19 +0100
  -- Frank Lichtenheld <frank@lichtenheld.de>  Sun, 13 Jan 2008 15:49:19 +0100
 
 
@@ -8,6 +9,7 @@ fields (2.0-1) unstable  frozen; urgency=medium
 
 
   [ Frank Lichtenheld ]
   [ Frank Lichtenheld ]
   * Upload to unstable (Closes: #1111111, #2222222)
   * Upload to unstable (Closes: #1111111, #2222222)
+  * Fix stuff. (LP: #12345, #424242)
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * New upstream release.
   * New upstream release.

+ 21 - 0
scripts/t/600_Dpkg_Changelog_Ubuntu.t

@@ -0,0 +1,21 @@
+# -*- perl -*-
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+
+$ENV{DEB_VENDOR} = 'Ubuntu';
+my $srcdir = $ENV{srcdir} || '.';
+do "$srcdir/t/600_Dpkg_Changelog.t";

+ 3 - 0
scripts/t/origins/debian

@@ -0,0 +1,3 @@
+Vendor: Debian
+Vendor-URL: http://www.debian.org/
+Bugs: debbugs://bugs.debian.org

+ 1 - 0
scripts/t/origins/default

@@ -0,0 +1 @@
+debian

+ 4 - 0
scripts/t/origins/ubuntu

@@ -0,0 +1,4 @@
+Vendor: Ubuntu
+Vendor-URL: http://www.ubuntu.com/
+Bugs: https://bugs.launchpad.net/ubuntu/+filebug
+Parent: Debian