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

Bug#692282: [new check] debian/tests/control but not (XS-)Testsuite: autopkgtest header in debian/control



Package: lintian
Version: 2.5.11
Followup-For: Bug #692282

Happy new year, and thanks for your advices. Here is a new attempt.

Adding the Testsuite field in data/common/source-fields causes the
generated "profiles/debian/main.profile" to change during build. It
should either be updated in the VCS/source package/whatever at the
same time, or excluded from lintian source package.

The debian-tests-control-is-not-a-regular-file tag lacks a reference,
as the current autopkgtest specification does not force the control
file to be a regular file. Any hint about this issue?

No check of debian/tests/control contents is done but a trivial one to
ensure that other ones may eventually be added.
diff --git a/checks/testsuite b/checks/testsuite
new file mode 100644
index 0000000..25f3e3d
--- /dev/null
+++ b/checks/testsuite
@@ -0,0 +1,40 @@
+# testsuite -- lintian check script -*- perl -*-
+
+package Lintian::testsuite;
+
+use strict;
+use warnings;
+
+use Lintian::Tags qw(tag);
+use Lintian::Util qw(fail file_is_encoded_in_non_utf8);
+
+sub run {
+    my ($pkg, $type, $info) = @_;
+    if ($type ne 'source') {
+        fail ('Testsuite check called for binary package.');
+    }
+
+    my $testsuite = $info->field ('testsuite');
+    my $control = $info->index ('debian/tests/control');
+
+    if (defined $testsuite xor defined $control) {
+        tag ('inconsistent-testsuite-field');
+    }
+    if (defined $testsuite and $testsuite ne 'autopkgtest') {
+        tag ('unknown-testsuite', $testsuite);
+    }
+    if (defined $control) {
+        if (not ($info->index ('debian/tests')->is_dir and $control->is_regular_file)) {
+            tag ('debian-tests-control-is-not-a-regular-file');
+        } else {
+            my $path = $info->unpacked ($control->name);
+
+            my $not_utf8_line = file_is_encoded_in_non_utf8 ($path, $type, $pkg);
+            if ($not_utf8_line) {
+                tag ('debian-tests-control-uses-obsolete-national-encoding', "at line $not_utf8_line");
+            }
+        }
+    }
+}
+
+1;
diff --git a/checks/testsuite.desc b/checks/testsuite.desc
new file mode 100644
index 0000000..243a4b8
--- /dev/null
+++ b/checks/testsuite.desc
@@ -0,0 +1,42 @@
+Check-Script: testsuite
+Type: source
+Needs-Info: index, unpacked
+Info: This script checks the Testsuite field in package dsc files,
+ and debian/tests/control if any.
+
+Tag: debian-tests-control-is-not-a-regular-file
+Severity: wishlist
+Certainty: certain
+Info: In case the dsc file contains a Testsuite field, "debian/tests"
+ must be a directory and contain a "control" regular file.
+# TODO: document this and add a reference here?
+
+Tag: debian-tests-control-uses-obsolete-national-encoding
+Severity: normal
+Certainty: certain
+Info: The debian/tests/control file should be valid UTF-8, an encoding
+ of the Unicode character set.
+ .
+ There are many ways to convert a file from an obsoleted encoding like
+ ISO-8859-1; you may for example use "iconv" like:
+ .
+  $ iconv -f ISO-8859-1 -t UTF-8 file > file.new
+  $ mv file.new file
+
+Tag: inconsistent-testsuite-field
+Severity: wishlist
+Certainty: certain
+Info: The package provides a debian/tests/control file but no
+ Testsuite field in the dsc file, or the field exists but not the
+ file.
+ .
+ For discoverability, packages shipping tests for the autopkgtest
+ testing framework should declare their presence in the package
+ description file.
+Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD
+
+Tag: unknown-testsuite
+Severity: normal
+Certainty: certain
+Info: Testsuite field in dsc file has a value other than autopkgtest.
+Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD
diff --git a/data/common/source-fields b/data/common/source-fields
index 17ed60c..334a1be 100644
--- a/data/common/source-fields
+++ b/data/common/source-fields
@@ -23,6 +23,7 @@ python-version
 ruby-versions
 source
 standards-version
+testsuite
 uploaders
 vcs-arch
 vcs-browser

Reply to: