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

[lintian] 01/04: t/runtests, Test::Lintian::Harness: Add support for "Test-Conflicts"



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

abe pushed a commit to branch master
in repository lintian.

commit 56dd603bd468a30e12f5aee85c946c63f9d233db
Author: Axel Beckert <abe@deuxchevaux.org>
Date:   Tue Nov 14 04:33:55 2017 +0100

    t/runtests, Test::Lintian::Harness: Add support for "Test-Conflicts"
    
    Also document the new field in t/tests/README.
---
 debian/changelog            |  3 +++
 lib/Test/Lintian/Harness.pm | 11 ++++++-----
 t/runtests                  | 12 ++++++------
 t/tests/README              |  8 +++++++-
 4 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 090bcd0..8f5e9e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,9 @@ lintian (2.5.60) UNRELEASED; urgency=medium
   * data/spelling/corrections:
     + [PW] Add several corrections.
 
+  * lib/Test/Lintian/Harness.pm, t/runtests, t/tests/README:
+    + [AB] Add support for a "Test-Conflicts" field.
+
  -- Chris Lamb <lamby@debian.org>  Thu, 09 Nov 2017 09:09:49 +0000
 
 lintian (2.5.59) unstable; urgency=medium
diff --git a/lib/Test/Lintian/Harness.pm b/lib/Test/Lintian/Harness.pm
index d351f97..6c28364 100644
--- a/lib/Test/Lintian/Harness.pm
+++ b/lib/Test/Lintian/Harness.pm
@@ -193,7 +193,10 @@ sub check_test_depends {
 
     # dpkg-checkbuilddeps requires that the Source: field is present.
     print {$test_fd} "Source: bd-test-pkg\n";
-    print {$test_fd} "Build-Depends: $testdata->{'test-depends'}\n";
+    print {$test_fd} "Build-Depends: $testdata->{'test-depends'}\n"
+      if $testdata->{'test-depends'};
+    print {$test_fd} "Build-Conflicts: $testdata->{'test-conflicts'}\n"
+      if $testdata->{'test-conflicts'};
     close($test_fd);
 
     $pid = open($fd, '-|');
@@ -207,10 +210,8 @@ sub check_test_depends {
     eval {close($fd);};
     $err = $@;
     unlink($test_file);
-    if (
-        $missing =~ s{\A dpkg-checkbuilddeps: [ ] (?:error: [ ])?
-                         Unmet [ ] build [ ] dependencies: \s* }{}xsm
-      ) {
+    if ($missing =~ s{\A dpkg-checkbuilddeps: [ ] (?:error: [ ])? }{}xsm) {
+        $missing =~ s{ \b build \b }{test}gxi;
         chomp($missing);
         if ($missing =~ s{\n}{\\n}gxsm) {
             # We expect exactly one line.
diff --git a/t/runtests b/t/runtests
index 97fda17..4002bf0 100755
--- a/t/runtests
+++ b/t/runtests
@@ -335,10 +335,10 @@ sub test_package {
         return $test_state->skip_test("(disabled) $reason");
     }
 
-    if ($testdata->{'test-depends'}) {
+    if ($testdata->{'test-depends'} or $testdata->{'test-conflicts'}) {
         my $missing = check_test_depends($testdata);
         if ($missing) {
-            return $test_state->skip_test("Missing Depends: $missing");
+            return $test_state->skip_test($missing);
         }
     }
 
@@ -539,12 +539,12 @@ sub test_changes {
         return $test_state->skip_test('architecture mismatch');
     }
 
-    if ($testdata->{'test-depends'}) {
+    if ($testdata->{'test-depends'} or $testdata->{'test-conflicts'}) {
         # Not sure this makes sense for .changes tests, but at least it
         # makes it consistent.
         my $missing = check_test_depends($testdata);
         if ($missing) {
-            return $test_state->skip_test("Missing Depends: $missing");
+            return $test_state->skip_test($missing);
         }
     }
 
@@ -605,10 +605,10 @@ sub generic_test_runner {
         return $test_state->skip_test("(disabled) $reason");
     }
 
-    if ($testdata->{'test-depends'}) {
+    if ($testdata->{'test-depends'} or $testdata->{'test-conflicts'}) {
         my $missing = check_test_depends($testdata);
         if ($missing) {
-            return $test_state->skip_test("Missing Depends: $missing");
+            return $test_state->skip_test($missing);
         }
     }
 
diff --git a/t/tests/README b/t/tests/README
index cfb5759..934cc73 100644
--- a/t/tests/README
+++ b/t/tests/README
@@ -128,7 +128,13 @@ current stable.  In this case, you can use:
 
     Test-Depends: <dpkg depends field>
 
-If any of the dependencies are unavailable, the test will be skipped.
+Sometimes tests fail if certain non-required packages are installed.
+If you notice such a case, you can use:
+
+    Test-Conflicts: <dpkg conflicts field>
+
+If any of the dependencies are unavailable or conflicts are present,
+the test will be skipped.
 
 All other fields in the .desc file are optional and control the values
 filled into the template control and changelog files by the test suite

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


Reply to: