[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



On 2013-01-25 20:46, Nicolas Boulenguez wrote:
> Package: lintian
> Followup-For: Bug #692282
> 
>> Checks for "syntax errors"/unparseable control file. Check that all
>> paragraphs have a "Tests" field. Or even check that all the
>> restrictions are known.
> 
> Here is a suggestion for review.

Hi,

Thanks for the code.  I have attached a small diff for some stylistic
things (note the test .desc changes also prevents a "synopsis not
phrased properly tag").

Secondly, one of the "testsuite"-tests fails with your changes.  Please
see test.log.

~Niels

commit a336c2cbf8d08e3ba7493e8feaeba1c9f2012ae2 Author: Niels Thykier Date: Fri Feb 8 12:13:13 2013 +0100 stuff Signed-off-by: Niels Thykier diff --git a/checks/testsuite b/checks/testsuite index db8ced2..e8dd64e 100644 --- a/checks/testsuite +++ b/checks/testsuite @@ -23,7 +23,29 @@ use strict; use warnings; use Lintian::Tags qw(tag); -use Lintian::Util qw(file_is_encoded_in_non_utf8); +use Lintian::Util qw( + file_is_encoded_in_non_utf8 + read_dpkg_control +); + +my @mandatory_fields = qw( + tests +); +my %expected_fields = map { $_ => 1 } qw( + tests + restrictions + features + depends + tests-directory +); +my %expected_features = map { $_ => 1 } qw( +); +my %expected_restrictions = map { $_ => 1 } qw( + breaks-testbed + build-needed + needs-root + rw-build-tree +); sub run { my ($pkg, $type, $info) = @_; @@ -47,8 +69,78 @@ sub run { if ($not_utf8_line) { tag 'debian-tests-control-uses-national-encoding', "at line $not_utf8_line"; } + + check_control_contents ($info, $path); + } + } +} +sub check_control_contents { + my ($info, $path) = @_; + + my @paragraphs; + if (not eval { @paragraphs = read_dpkg_control ($path); }) { + chomp $@; + $@ =~ s/^syntax error at //; + tag 'syntax-error-in-debian-tests-control', $@; + } else { + for (@paragraphs) { + check_control_paragraph ($info, $_); + } + } +} +sub check_control_paragraph { + my ($info, $paragraph) = @_; + + for (@mandatory_fields) { + if (not exists $paragraph->{$_}) { + tag 'missing-runtime-tests-field', $_; + } + } + for (keys %$paragraph) { + if (not exists $expected_fields {$_}) { + tag 'unknown-runtime-tests-field', $_; + } + } + if (exists $paragraph->{'features'}) { + for (split ' ', $paragraph->{'features'}) { + if (not exists $expected_features {$_}) { + tag 'unknown-runtime-tests-feature', $_; + } } } + if (exists $paragraph->{'restrictions'}) { + for (split ' ', $paragraph->{'restrictions'}) { + if (not exists $expected_restrictions {$_}) { + tag 'unknown-runtime-tests-restriction', $_; + } + } + } + if (exists $paragraph->{'tests'}) { + my $directory; + if (exists $paragraph->{'tests-directory'}) { + $directory = $paragraph->{'tests-directory'}; + } else { + $directory = 'debian/tests'; + } + for (split ' ', $paragraph->{'tests'}) { + check_test_file ($info, $directory, $_); + } + } +} +sub check_test_file { + my ($info, $directory, $name) = @_; + + if ($name !~ /^[[:digit:][:lower:]\+\-\.\/]*$/) { + tag 'illegal-runtime-test-name', $name; + } + my $path = "$directory/$name"; + my $index = $info->index ($path); + if (not defined $index) { + tag 'missing-runtime-test-file', $path; + } elsif (not $index->is_regular_file) { + tag 'runtime-test-file-is-not-a-regular-file', $path; + } + # Test files are allowed not to be executable. } 1; diff --git a/checks/testsuite.desc b/checks/testsuite.desc index 0210fae..cf9c3f7 100644 --- a/checks/testsuite.desc +++ b/checks/testsuite.desc @@ -23,6 +23,14 @@ Info: The debian/tests/control file should be valid UTF-8, an encoding $ iconv -f ISO-8859-1 -t UTF-8 file > file.new $ mv file.new file +Tag: illegal-runtime-test-name +Severity: normal +Certainty: certain +Info: Runtime test names in debian/tests/control are only allowed to + contain decimal digits, lowercase ASCII letters, plus or minus signs, + dots or slashes. +Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD + Tag: inconsistent-testsuite-field Severity: wishlist Certainty: certain @@ -35,6 +43,61 @@ Info: The package provides a debian/tests/control file but no 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: missing-runtime-tests-field +Severity: normal +Certainty: certain +Info: A mandatory field is missing in some paragraph of the + debian/tests/control file. +Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD + +Tag: missing-runtime-test-file +Severity: normal +Certainty: possible +Info: A test file listed in the debian/tests/control file does not + exist in the package source. +Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD + +Tag: runtime-test-file-is-not-a-regular-file +Severity: wishlist +Certainty: certain +Info: A runtime test listed by debian/tests/control is not a regular + file. +Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD + +Tag: syntax-error-in-debian-tests-control +Severity: normal +Certainty: certain +Info: The debian/tests/control file didn't pass Debian control file + syntax check. + . + This issue may hide other issues as Lintian skips some checks on the + file in this case. +Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD + +Tag: unknown-runtime-tests-feature +Severity: pedantic +Certainty: wild-guess +Info: A paragraph in debian/tests/control mentions a non standard + value for the Features field. Though allowed, this may indicate an + error, as the value will be ignored. +Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD + +Tag: unknown-runtime-tests-field +Severity: pedantic +Certainty: wild-guess +Info: A paragraph in debian/tests/control mentions a non standard + field. Though allowed, this may indicate an error, as the whole + paragraph will be ignored. +Ref: http://anonscm.debian.org/gitweb/?p=autopkgtest/autopkgtest.git;a=blob_plain;f=doc/README.package-tests;hb=HEAD + +Tag: unknown-runtime-tests-restriction +Severity: pedantic +Certainty: wild-guess +Info: A paragraph in debian/tests/control mentions a non standard + value for the Restrictions field. Though allowed, this may indicate an + error, as the whole paragraph will be ignored. +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 diff --git a/t/tests/testsuite-control-syntax/debian/debian/control.in b/t/tests/testsuite-control-syntax/debian/debian/control.in new file mode 100644 index 0000000..a7b9673 --- /dev/null +++ b/t/tests/testsuite-control-syntax/debian/debian/control.in @@ -0,0 +1,16 @@ +Source: {$srcpkg} +Priority: extra +Section: {$section} +Maintainer: {$author} +Standards-Version: {$standards_version} +Build-Depends: debhelper (>= 9) +XS-Testsuite: autopkgtest + +Package: {$srcpkg} +Architecture: {$architecture} +Depends: $\{shlibs:Depends\}, $\{misc:Depends\} +Description: {$description} + This is a test package designed to exercise some feature or tag of + Lintian. It is part of the Lintian test suite and may do very odd + things. It should not be installed like a regular package. It may + be an empty package. diff --git a/t/tests/testsuite-control-syntax/debian/debian/tests/control b/t/tests/testsuite-control-syntax/debian/debian/tests/control new file mode 100644 index 0000000..e2f8d8b --- /dev/null +++ b/t/tests/testsuite-control-syntax/debian/debian/tests/control @@ -0,0 +1,5 @@ +This file does not look like a Debian control file. + + at + + all diff --git a/t/tests/testsuite-control-syntax/desc b/t/tests/testsuite-control-syntax/desc new file mode 100644 index 0000000..443331d --- /dev/null +++ b/t/tests/testsuite-control-syntax/desc @@ -0,0 +1,5 @@ +Testname: testsuite-control-syntax +Sequence: 6000 +Version: 1.0 +Description: Detection of syntax errors in autopkgtest control file +Test-For: syntax-error-in-debian-tests-control diff --git a/t/tests/testsuite-control-syntax/tags b/t/tests/testsuite-control-syntax/tags new file mode 100644 index 0000000..0423fc0 --- /dev/null +++ b/t/tests/testsuite-control-syntax/tags @@ -0,0 +1 @@ +W: testsuite-control-syntax source: syntax-error-in-debian-tests-control line 1: Cannot parse line "This file does not look like a Debian control file." diff --git a/t/tests/testsuite-general/debian/debian/tests/control b/t/tests/testsuite-general/debian/debian/tests/control index a44615a..17e57cd 100644 --- a/t/tests/testsuite-general/debian/debian/tests/control +++ b/t/tests/testsuite-general/debian/debian/tests/control @@ -1,2 +1,18 @@ Tests: test-1 Comment: Test-1 is öh so good. + Last paragraph misses a Tests field. + +Tests: fifo missing-test under_score + +Tests: test-in-subdir +Restrictions: + rw-build-tree + breaks-testbed + needs-root + build-needed +Depends: @ +Features: +Tests-Directory: subdir + +Features: unknownfeature +Restrictions: unknownrestriction diff --git a/t/tests/testsuite-general/debian/debian/tests/under_score b/t/tests/testsuite-general/debian/debian/tests/under_score new file mode 100644 index 0000000..039e4d0 --- /dev/null +++ b/t/tests/testsuite-general/debian/debian/tests/under_score @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 diff --git a/t/tests/testsuite-general/debian/subdir/test-in-subdir b/t/tests/testsuite-general/debian/subdir/test-in-subdir new file mode 100644 index 0000000..039e4d0 --- /dev/null +++ b/t/tests/testsuite-general/debian/subdir/test-in-subdir @@ -0,0 +1,2 @@ +#!/bin/sh +exit 0 diff --git a/t/tests/testsuite-general/desc b/t/tests/testsuite-general/desc index 2dceaf6..31f80b7 100644 --- a/t/tests/testsuite-general/desc +++ b/t/tests/testsuite-general/desc @@ -4,4 +4,11 @@ Version: 1.0 Description: General tests of the autopkgtest control file Test-For: debian-tests-control-uses-national-encoding + illegal-runtime-test-name inconsistent-testsuite-field + missing-runtime-test-file + missing-runtime-tests-field + runtime-test-file-is-not-a-regular-file + unknown-runtime-tests-feature + unknown-runtime-tests-field + unknown-runtime-tests-restriction diff --git a/t/tests/testsuite-general/pre_build b/t/tests/testsuite-general/pre_build new file mode 100644 index 0000000..9302e88 --- /dev/null +++ b/t/tests/testsuite-general/pre_build @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e + +DIR="$1" +mkfifo "$DIR/debian/tests/fifo" diff --git a/t/tests/testsuite-general/tags b/t/tests/testsuite-general/tags index 3ac42a4..77186ed 100644 --- a/t/tests/testsuite-general/tags +++ b/t/tests/testsuite-general/tags @@ -1,2 +1,9 @@ I: testsuite-general source: inconsistent-testsuite-field W: testsuite-general source: debian-tests-control-uses-national-encoding at line 2 +P: testsuite-general source: unknown-runtime-tests-field comment +I: testsuite-general source: runtime-test-file-is-not-a-regular-file debian/tests/fifo +W: testsuite-general source: missing-runtime-test-file debian/tests/missing-test +W: testsuite-general source: illegal-runtime-test-name under_score +W: testsuite-general source: missing-runtime-tests-field tests +P: testsuite-general source: unknown-runtime-tests-feature unknownfeature +P: testsuite-general source: unknown-runtime-tests-restriction unknownrestriction
$ DEB_BUILD_OPTIONS=parallel=8 debian/rules TEST_WORK_DIR=/tmp/lintian-tests runtests onlyrun=testsuite
.... running tests ....
rm -rf "/tmp/lintian-tests"
mkdir "/tmp/lintian-tests"
private/runtests -j 8 testsuite
Using C.UTF-8 locale from /usr/lib/locale
Package tests (tests):
Running testsuite-control-syntax 1.0... building... testing... ok.                                                                                                
Running testsuite-unknown-suite 1.0... building... testing... ok.
Running testsuite-general 1.0... building... testing... FAILED
--- t/tests/testsuite-general/tags      2013-02-08 11:06:59.223137462 +0000
+++ /tmp/lintian-tests/testsuite-general/tags.testsuite-general 2013-02-08 11:15:09.690435979 +0000
@@ -1,9 +1,6 @@
 I: testsuite-general source: inconsistent-testsuite-field
 W: testsuite-general source: debian-tests-control-uses-national-encoding at line 2
-P: testsuite-general source: unknown-runtime-tests-field comment
-I: testsuite-general source: runtime-test-file-is-not-a-regular-file debian/tests/fifo
-W: testsuite-general source: missing-runtime-test-file debian/tests/missing-test
 W: testsuite-general source: illegal-runtime-test-name under_score
+W: testsuite-general source: missing-runtime-test-file debian/tests/fifo
+W: testsuite-general source: missing-runtime-test-file debian/tests/missing-test
 W: testsuite-general source: missing-runtime-tests-field tests
-P: testsuite-general source: unknown-runtime-tests-feature unknownfeature
-P: testsuite-general source: unknown-runtime-tests-restriction unknownrestriction
Running testsuite-control-not-file 1.0... building... testing... ok.
make: *** [runtests] Error 1

Reply to: