Bug#692282: [new check] debian/tests/control but not (XS-)Testsuite: autopkgtest header in debian/control
Package: lintian
Followup-For: Bug #692282
> > if (not ($info->index ('debian/tests')->is_dir and $control->is_regular_file)) {
> directories must have a trailing "/" (i.e. 'debian/tests/').
Not sure to understand what you mean by "must".
On my machine, "$info->index ('debian/tests')->is_dir" returns true
when the directory exists, as I expected from the documentation.
diff --git a/checks/testsuite b/checks/testsuite
index 25f3e3d..db8ced2 100644
--- a/checks/testsuite
+++ b/checks/testsuite
@@ -1,37 +1,51 @@
# testsuite -- lintian check script -*- perl -*-
+# Copyright (C) 2013 Nicolas Boulenguez <nicolas@debian.org>
+
+# This file is part of lintian.
+
+# Lintian 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 3 of the License, or
+# (at your option) any later version.
+
+# Lintian 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 Lintian. If not, see <http://www.gnu.org/licenses/>.
+
package Lintian::testsuite;
use strict;
use warnings;
use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail file_is_encoded_in_non_utf8);
+use Lintian::Util qw(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');
+ tag 'inconsistent-testsuite-field';
}
if (defined $testsuite and $testsuite ne 'autopkgtest') {
- tag ('unknown-testsuite', $testsuite);
+ 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');
+ if (not $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");
+ tag 'debian-tests-control-uses-national-encoding', "at line $not_utf8_line";
}
}
}
diff --git a/checks/testsuite.desc b/checks/testsuite.desc
index 243a4b8..0210fae 100644
--- a/checks/testsuite.desc
+++ b/checks/testsuite.desc
@@ -1,4 +1,5 @@
Check-Script: testsuite
+Author: Nicolas Boulenguez <nicolas@debian.org>
Type: source
Needs-Info: index, unpacked
Info: This script checks the Testsuite field in package dsc files,
@@ -9,15 +10,14 @@ 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
+Tag: debian-tests-control-uses-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
+ There are many ways to convert a file from an encoding like
ISO-8859-1; you may for example use "iconv" like:
.
$ iconv -f ISO-8859-1 -t UTF-8 file > file.new
@@ -32,11 +32,13 @@ Info: The package provides a debian/tests/control file but no
.
For discoverability, packages shipping tests for the autopkgtest
testing framework should declare their presence in the package
- description file.
+ dsc file by adding "XS-Testsuite: autopkgtest" to their debian/control.
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.
+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 XS-Testsuite in debian/control.
Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD
diff --git a/checks/testsuite b/checks/testsuite
new file mode 100644
index 0000000..db8ced2
--- /dev/null
+++ b/checks/testsuite
@@ -0,0 +1,54 @@
+# testsuite -- lintian check script -*- perl -*-
+
+# Copyright (C) 2013 Nicolas Boulenguez <nicolas@debian.org>
+
+# This file is part of lintian.
+
+# Lintian 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 3 of the License, or
+# (at your option) any later version.
+
+# Lintian 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 Lintian. If not, see <http://www.gnu.org/licenses/>.
+
+package Lintian::testsuite;
+
+use strict;
+use warnings;
+
+use Lintian::Tags qw(tag);
+use Lintian::Util qw(file_is_encoded_in_non_utf8);
+
+sub run {
+ my ($pkg, $type, $info) = @_;
+
+ 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 $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-national-encoding', "at line $not_utf8_line";
+ }
+ }
+ }
+}
+
+1;
diff --git a/checks/testsuite.desc b/checks/testsuite.desc
new file mode 100644
index 0000000..0210fae
--- /dev/null
+++ b/checks/testsuite.desc
@@ -0,0 +1,44 @@
+Check-Script: testsuite
+Author: Nicolas Boulenguez <nicolas@debian.org>
+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.
+
+Tag: debian-tests-control-uses-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 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
+ dsc file by adding "XS-Testsuite: autopkgtest" to their debian/control.
+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: 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 XS-Testsuite in debian/control.
+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: