[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/01: c/testsuite: Check for invalid dependency fields



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

nthykier pushed a commit to branch master
in repository lintian.

commit f0b319dd53124f97c25cc233bdbd3353c0afb9a8
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Jun 19 13:35:48 2016 +0000

    c/testsuite: Check for invalid dependency fields
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/testsuite.desc                                 | 15 +++++++++++++++
 checks/testsuite.pm                                   | 16 ++++++++++++++++
 debian/changelog                                      |  5 ++++-
 t/tests/testsuite-general/debian/debian/tests/control |  4 ++--
 t/tests/testsuite-general/desc                        |  1 +
 t/tests/testsuite-general/tags                        |  1 +
 6 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/checks/testsuite.desc b/checks/testsuite.desc
index a3e744e..4a53278 100644
--- a/checks/testsuite.desc
+++ b/checks/testsuite.desc
@@ -113,3 +113,18 @@ Info: The dsc file sets Testsuite to a value other than autopkgtest,
  the only one allowed. This field is most probably copied by
  dpkg-source from Testsuite in debian/control.
 Ref: https://anonscm.debian.org/git/autopkgtest/autopkgtest.git/tree/doc/README.package-tests.rst
+
+Tag: testsuite-dependency-has-unparsable-elements
+Severity: normal
+Certainty: possible
+Info: Lintian cannot parse the Depends field for the given autopkgtest.
+ .
+ Please double check that dependency the syntax is correct.
+ .
+ Note that Lintian has a whitelist of known "special" dependencies
+ permitted by autopkgtest (e.g. @builddep@).  Lintian does not accept
+ these as a part of an OR-clause.
+ .
+ If Lintian complains about a new special "@"-dependency, please file
+ a bug against Lintian and have it added to the whitelist.
+Ref: https://anonscm.debian.org/git/autopkgtest/autopkgtest.git/tree/doc/README.package-tests.rst
diff --git a/checks/testsuite.pm b/checks/testsuite.pm
index 02ebb68..716274f 100644
--- a/checks/testsuite.pm
+++ b/checks/testsuite.pm
@@ -23,6 +23,7 @@ use strict;
 use warnings;
 use autodie;
 
+use Lintian::Relation;
 use Lintian::Tags qw(tag);
 use Lintian::Util qw(
   file_is_encoded_in_non_utf8
@@ -65,6 +66,11 @@ my %KNOWN_TESTSUITES = map { $_ => 1 } qw(
   autopkgtest-pkg-ruby
 );
 
+my %KNOWN_SPECIAL_DEPENDS = map { $_ => 1 } qw(
+  @
+  @builddeps@
+);
+
 sub run {
     my ($pkg, $type, $info) = @_;
     my $testsuites = $info->field('testsuite', '');
@@ -173,6 +179,16 @@ sub check_control_paragraph {
             check_test_file($info, $directory, $testname, $line);
         }
     }
+    if (exists($paragraph->{'depends'})) {
+        my $dep = Lintian::Relation->new($paragraph->{'depends'});
+        for my $unparsable ($dep->unparsable_predicates) {
+            # @ is not a valid predicate in general, but autopkgtests
+            # allows it.
+            next if exists($KNOWN_SPECIAL_DEPENDS{$unparsable});
+            tag 'testsuite-dependency-has-unparsable-elements', "\"$unparsable\"",
+                "(in paragraph starting at line $line)";
+        }
+    }
     return;
 }
 
diff --git a/debian/changelog b/debian/changelog
index 08eef9a..20dbb34 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -43,11 +43,14 @@ lintian (2.5.45) UNRELEASED; urgency=medium
     + [JW] Fix false positive dev-pkg-without-shlib-symlink for GCC runtime
       libraries.  Thanks to Matthias Klose for the bug report.
       (Closes: #823833)
-  * checks/testsuite.pm:
+  * checks/testsuite.{desc,pm}:
     + [NT] Apply patch from Ondřej Nový to add more known
       autodep8 test suites.  (Closes: #823088)
     + [JW] Update autopkgtest specification URL.
       Thanks to Mattia Rizzolo for the bug report.
+    + [NT] Check for broken dependency fields in the autopkgtest control
+      file.  Thanks to Jérémy Bobbio for the suggestion.
+      (Closes: #795083)
   * checks/upstream-metadata.pm:
     + [JW] Include YAML validation error in the output.
   * checks/usrmerge.desc:
diff --git a/t/tests/testsuite-general/debian/debian/tests/control b/t/tests/testsuite-general/debian/debian/tests/control
index 0fef676..9f8f9a3 100644
--- a/t/tests/testsuite-general/debian/debian/tests/control
+++ b/t/tests/testsuite-general/debian/debian/tests/control
@@ -19,14 +19,14 @@ Depends: @
 
 Tests: test-2
 Test-Command: /bin/true
-Depends: @
+Depends: @, missing a comma
 
 Features: unknownfeature
 Restrictions: unknownrestriction
 
 Test-Command: /bin/true
 Restrictions: breaks-testbed, rw-build-tree, needs-root
-Depends: @
+Depends: @, @builddeps@
 
 Tests: test-1, test-2
 Depends: @
diff --git a/t/tests/testsuite-general/desc b/t/tests/testsuite-general/desc
index c483bbf..6d016ee 100644
--- a/t/tests/testsuite-general/desc
+++ b/t/tests/testsuite-general/desc
@@ -14,6 +14,7 @@ Test-For:
  missing-runtime-test-file
  missing-runtime-tests-field
  runtime-test-file-is-not-a-regular-file
+ testsuite-dependency-has-unparsable-elements
  unknown-runtime-tests-feature
  unknown-runtime-tests-field
  unknown-runtime-tests-restriction
diff --git a/t/tests/testsuite-general/tags b/t/tests/testsuite-general/tags
index 95dcb9a..e05e0b9 100644
--- a/t/tests/testsuite-general/tags
+++ b/t/tests/testsuite-general/tags
@@ -13,3 +13,4 @@ W: testsuite-general source: exclusive-runtime-tests-field tests, test-command p
 W: testsuite-general source: illegal-runtime-test-name under_score paragraph starting at line 5
 W: testsuite-general source: missing-runtime-test-file debian/tests/missing-test paragraph starting at line 5
 W: testsuite-general source: missing-runtime-tests-field tests || test-command paragraph starting at line 24
+W: testsuite-general source: testsuite-dependency-has-unparsable-elements "missing a comma" (in paragraph starting at line 20)

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


Reply to: