[Reproducible-commits] [dpkg] 31/74: dpkg-source: Generate Testsuite-Triggers field from test dependencies

Mattia Rizzolo mattia at debian.org
Sun Jul 3 22:22:54 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to annotated tag 1.18.8
in repository dpkg.

commit 90324cfa942ba23d5d44b28b1087fbd510340502
Author: Guillem Jover <guillem at debian.org>
Date:   Fri May 13 17:26:01 2016 +0200

    dpkg-source: Generate Testsuite-Triggers field from test dependencies
    
    Sometimes autopkgtests regress due to change in a package which is only
    a test dependency (Depends: in debian/tests/control), not a build or
    binary one. It is useful to trigger a test if such a test dependency
    changes.
    
    Record the union of all test dependency packages in a new
    Testsuite-Triggers field in the .dsc, so that they will be recorded in
    the Sources package index. Ignore versions and flatten OR dependencies
    as they are not interesting for determining reverse test dependencies
    and should not be (ab)used for replacing debian/tests/control parsing.
    
    Closes: #779559
    LP: #1491145
    Based-on-patch-by: Martin Pitt <martin.pitt at ubuntu.com>
    Signed-off-by: Guillem Jover <guillem at debian.org>
---
 debian/changelog                   |  3 +++
 scripts/Dpkg/Control/FieldsCore.pm |  8 ++++++--
 scripts/dpkg-source.pl             | 31 +++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1d1e334..63de0d3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,9 @@ dpkg (1.18.8) UNRELEASED; urgency=medium
     under either the dpkg system or user configuration directories.
     Closes: #539692, #765494
   * Check that debian/tests/control is a regular file before parsing it.
+  * Generate Testsuite-Triggers field from test dependencies in dpkg-source
+    into .dsc files. Based on a patch by Martin Pitt <martin.pitt at ubuntu.com>.
+    Closes: #779559
   * Perl modules:
     - Use warnings::warnif() instead of carp() for deprecated warnings.
     - Add new format_range() method and deprecate dpkg() and rfc822() methods
diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm
index 0c7ce4b..e3b4364 100644
--- a/scripts/Dpkg/Control/FieldsCore.pm
+++ b/scripts/Dpkg/Control/FieldsCore.pm
@@ -354,6 +354,10 @@ our %FIELDS = (
         allowed => ALL_SRC,
         separator => FIELD_SEP_COMMA,
     },
+    'Testsuite-Triggers' => {
+        allowed => ALL_SRC,
+        separator => FIELD_SEP_COMMA,
+    },
     'Timestamp' => {
         allowed => CTRL_CHANGELOG,
     },
@@ -439,8 +443,8 @@ our %FIELD_ORDER = (
         qw(Format Source Binary Architecture Version Origin Maintainer
         Uploaders Homepage Standards-Version Vcs-Browser
         Vcs-Arch Vcs-Bzr Vcs-Cvs Vcs-Darcs Vcs-Git Vcs-Hg Vcs-Mtn
-        Vcs-Svn Testsuite), &field_list_src_dep(), qw(Package-List),
-        @checksum_fields, qw(Files)
+        Vcs-Svn Testsuite Testsuite-Triggers), &field_list_src_dep(),
+        qw(Package-List), @checksum_fields, qw(Files)
     ],
     CTRL_FILE_CHANGES() => [
         qw(Format Date Source Binary Binary-Only Built-For-Profiles Architecture
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index 7d71e05..50885bb 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -41,7 +41,9 @@ use Dpkg::Deps;
 use Dpkg::Compression;
 use Dpkg::Conf;
 use Dpkg::Control::Info;
+use Dpkg::Control::Tests;
 use Dpkg::Control::Fields;
+use Dpkg::Index;
 use Dpkg::Substvars;
 use Dpkg::Version;
 use Dpkg::Vars;
@@ -359,6 +361,7 @@ if ($options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) {
 
     # Check if we have a testsuite, and handle manual and automatic values.
     set_testsuite_field($fields);
+    set_testsuite_triggers_field($fields, @binarypackages);
 
     # Scan fields of dpkg-parsechangelog
     foreach (keys %{$changelog}) {
@@ -515,6 +518,34 @@ sub set_testsuite_field
     $fields->{'Testsuite'} = join ', ', sort keys %testsuite;
 }
 
+sub set_testsuite_triggers_field
+{
+    my ($fields, @binarypackages) = @_;
+    my %testdeps;
+
+    # Never overwrite a manually defined field.
+    return if $fields->{'Testsuite-Triggers'};
+
+    # We only support autopkgtests.
+    return unless -e "$dir/debian/tests/control";
+
+    my $tests = Dpkg::Control::Tests->new();
+    $tests->load("$dir/debian/tests/control");
+
+    foreach my $test ($tests->get()) {
+        next unless $test->{Depends};
+
+        my $deps = deps_parse($test->{Depends}, use_arch => 0, tests_dep => 1);
+        deps_iterate($deps, sub { $testdeps{$_[0]->{package}} = 1 });
+    }
+
+    # Remove our own binaries and meta-depends.
+    foreach my $pkg (@binarypackages, qw(@ @builddeps@)) {
+        delete $testdeps{$pkg};
+    }
+    $fields->{'Testsuite-Triggers'} = join ', ', sort keys %testdeps;
+}
+
 sub setopmode {
     my $opmode = shift;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list