[SCM] Debian package checker branch, master, updated. 1.24.2-95-g5995de2
The following commit has been merged in the master branch:
commit 0267797cebf72a3bcd21559fce6df6aa2a09b882
Author: Frank Lichtenheld <djpig@debian.org>
Date: Sun Aug 3 18:59:12 2008 +0200
Begin work on a new test suite for lintian
The old test suite has some disadvantages:
* It mixes several tests in one test package,
making it ever more likely that the tests
are affected by each other.
* This also makes it ever more difficult to find
out which parts of a test package were created
for which tag to test.
* It does not denote whether a tag is only issued
as a side effect or it was caused deliberatly
* It does not allow to specify whether a test package is
specifically designed to *not* issue a tag, making it
possible that this intent gets lost in time.
* The tests include some code duplication.
* Many test packages issue many tags only as side effect
since they are very basic.
* .orig.tar.gz files have to be included in the VCS.
The new test suite tries to address these issues:
* It creates the test packages on-the-fly, making
it possible to create many test packages with
a smaller scope with very little duplication.
* It uses a debhelper 7 based default skeleton,
which makes the skeleton very flexible and achieves
a good standards compatibility (i.e. low overhead of
unneccessary tags).
* It includes a control file for each test which can be
be used to include meta data about the intentions of
the test.
* It supports building .orig.tar.gz files on-the-fly,
making it easier to create non-native test packages.
Status of this code:
* It builds a list of test, creates the packages for them,
builds them and runs lintian.
* It also support the literal comparison method (i.e. cmp -s)
between two tag files as done by the old test suite.
* It does not yet use the description files to refine this
comparison.
diff --git a/.gitignore b/.gitignore
index 1d3d3b9..428ea69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
debian/tests
runtests
!testset/runtests
+!t/runtests
diff --git a/debian/changelog b/debian/changelog
index 3a3a629..2b0b214 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -160,6 +160,9 @@ lintian (1.24.3) unstable; urgency=low
* reporting/templates/index.tmpl:
+ [RA] Add a link to lintian.log. Suggested by Stefano Zacchiroli.
+ * t/:
+ + [FL] Begin work on a new testsuite.
+
* testset/fields:
+ [ADB] New testset from Tobias Quathamer (including some tags which
previously weren't tested)
diff --git a/debian/rules b/debian/rules
index ae67ee5..65e9bae 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,14 +6,16 @@ usl := $(tmp)/usr/share/lintian
neededfiles := debian/rules frontend/lintian
allchecks := $(wildcard checks/*)
allcollect := $(wildcard collection/*)
-tagfiles := $(wildcard testset/tags.*)
+tagfiles := $(wildcard testset/tags.* t/*/tags)
+testfiles := $(wildcard t/tests/*.desc)
onlyrun =
-runtests: $(neededfiles) $(allchecks) $(allcollect) $(tagfiles)
+runtests: $(neededfiles) $(allchecks) $(allcollect) $(tagfiles) $(testfiles)
@echo .... running tests ....
[ -d debian/tests ] || mkdir debian/tests
LINTIAN_ROOT="" /usr/bin/perl testset/runtests -k testset debian/tests $(onlyrun)
- touch $@
+ LINTIAN_ROOT="" /usr/bin/perl t/runtests -k t debian/tests $(onlyrun)
+ if [ "$(onlyrun)" != "" ]; then touch $@; fi
build: $(neededfiles)
@echo .... running build ....
diff --git a/testset/runtests b/t/runtests
similarity index 66%
copy from testset/runtests
copy to t/runtests
index 0cd13de..1ac48c9 100755
--- a/testset/runtests
+++ b/t/runtests
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
-# Copyright (C) 1998 Richard Braakman
+# Copyright © 1998 Richard Braakman
+# Copyright © 2008 Frank Lichtenheld
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,6 +20,7 @@
# MA 02110-1301, USA.
use strict;
+use warnings;
sub usage {
print <<END;
@@ -41,18 +43,7 @@ END
my $debug = 0;
# Tests layout:
-# Every test package is in a directory pkgname-version in the testset
-# directory. The lintian output that is expected for each package is
-# in a file tags.pkgname in the testset directory.
-
-# Running the tests:
-# Each test package is copied to a subdirectory of the testing-directory,
-# and built there. Then lintian is run over the resulting .changes file,
-# with its output redirected to tags.pkgname in the testing-directory.
-
-# If the tags output is not identical to the tags.pkgname file in the
-# testset-directory, then runtests will output the diff and exit with
-# a failure code.
+# XXX FIXME XXX
# The build output is directed to build.pkgname in the testing-directory.
@@ -225,72 +216,90 @@ if ($testok) {
# in temporary labs
my @tests;
if ($singletest) {
- @tests = ( $singletest );
+ @tests = map { s/\.desc$// } ( $singletest );
} else {
- opendir(TESTDIR, $testset)
- or fail("cannot open $testset: $!\n");
+ -d $testset
+ or fail("cannot find $testset: $!\n");
- @tests = sort(readdir(TESTDIR));
-
- closedir(TESTDIR);
+ @tests = map { s#^\Q$testset/tests/\E## ;s/\.desc$//; $_ } sort(<$testset/tests/*.desc>);
}
+print "found the following tests: @tests\n" if $debug;
for (@tests) {
- next if $_ eq '.' or $_ eq '..' or $_ eq 'CVS' or $_ eq '.svn';
- next unless -d "$testset/$_";
-
- my $pkgdir = $_;
-
- open(CHANGELOG, "$testset/$pkgdir/debian/changelog") or
- die("Could not open $testset/$pkgdir/debian/changelog");
- my $line = <CHANGELOG>;
- chomp($line);
- close(CHANGELOG);
- $line =~ s/^.*\(//;
- $line =~ s/\).*$//;
-
- my ($pkg, $ver) = ($pkgdir, $line);
- print "Running test on $pkg $ver: copying... ";
-
- print "Cleaning up and repopulating $rundir/$pkgdir...\n" if $debug;
- runsystem_ok("rm -rf $rundir/$pkgdir");
- runsystem("cp -rp $testset/$pkgdir $rundir");
- opendir D, "$testset" or die;
- foreach (readdir D) {
- next unless /^\Q${pkg}\E_.*\.orig\.tar\.gz$/;
- print "Symlinking $_ in $rundir...\n" if $debug;
- symlink $ENV{'PWD'}."/$testset/$_", "$rundir/$_";
+ my $testdesc = "$testset/tests/$_.desc";
+
+ print "process $testdesc...\n" if $debug;
+ my $testdata = (read_dpkg_control($testdesc))[0];
+
+ check_test_is_sane($testset, $testdata);
+ print "Running test $testdata->{testname} $testdata->{version}... ";
+
+ my $pkg = $testdata->{srcpkg};
+ my $pkgdir = "$pkg-$testdata->{version}";
+ my $origdir = "$testset/tests/$testdata->{testname}";
+ my $targetdir = "$rundir/$pkgdir";
+ my $tmpldir = "$testset/templates";
+
+ my $is_native = ($testdata->{type} eq 'native');
+
+ print "Cleaning up and repopulating $targetdir...\n" if $debug;
+ runsystem_ok("rm", "-rf", $targetdir);
+ if ($is_native) {
+ runsystem("cp", "-rp", "$tmpldir/skel", $targetdir);
+ runsystem("rm", "-f", "$targetdir/debian/changelog");
+ runsystem("rsync", "-rp", "$origdir/debian/", "$targetdir/")
+ if -d "$origdir/debian/";
+ } else {
+ runsystem("cp", "-rp", "$tmpldir/skel.upstream", $targetdir);
+ runsystem("rm", "-f", "$targetdir/.dummy");
+ runsystem("rsync", "-rp", "$origdir/upstream/", "$targetdir/");
+ runsystem("cd $rundir && ".
+ "tar czf ${pkg}_$testdata->{version}.orig.tar.gz $pkgdir");
+ runsystem("rsync", "-rp", "--exclude=debian/changelog",
+ "$tmpldir/skel/", "$targetdir/");
+ runsystem("rsync", "-rp", "$origdir/debian/", "$targetdir/")
+ if -d "$origdir/debian/";
+ }
+
+ unless (-e "$targetdir/debian/changelog") {
+ fill_in_tmpl("$targetdir/debian/changelog", $testdata);
+ }
+ unless (-e "$targetdir/debian/control") {
+ fill_in_tmpl("$targetdir/debian/control", $testdata);
+ }
+ unless ($is_native || -e "$targetdir/debian/watch") {
+ runsystem("echo >$targetdir/debian/watch");
+ }
+ if (-x "$origdir/pre_build") {
+ print "running pre_build hook...\n";
+ runsystem("$origdir/pre_build", $targetdir);
}
- closedir D;
- runsystem("find $rundir -name CVS -o -name .svn -print0 | xargs -0r rm -R");
print "building... ";
- print "Running dpkg-buildpackage $dpkg_buildpackage_options in $rundir/$pkgdir...\n" if $debug;
runsystem("cd $rundir/$pkgdir && dpkg-buildpackage $dpkg_buildpackage_options >../build.$pkg 2>&1");
- print "testing... ";
- print "Running lintian $lintian_options on $rundir/$pkg\_$ver*.changes...\n" if $debug;
- runsystem_ok("$lintian_path $lintian_options $rundir/$pkg\_$ver*.changes".
- " 2>&1 | sort > $rundir/tags.$pkg");
+ print "testing... ";
+ runsystem_ok("$lintian_path $lintian_options $rundir/$pkg\_$testdata->{version}*.changes".
+ " 2>&1 | sort > $rundir/tags.$pkg");
# Run a sed-script if it exists, for tests that have slightly variable
# output
- runsystem_ok("sed -i -f $testset/tags.$pkg.sed $rundir/tags.$pkg")
- if -e "$testset/tags.$pkg.sed";
+ runsystem_ok("sed -i -f $origdir/post_test $rundir/tags.$pkg")
+ if -e "$origdir/post_test";
- $testok = runsystem_ok("cmp -s $rundir/tags.$pkg $testset/tags.$pkg");
+ $testok = runsystem_ok("cmp", "-s", "$rundir/tags.$pkg", "$origdir/tags");
if ($testok) {
print "done.\n";
} else {
print "FAILED:\n";
- runsystem_ok("diff -u $testset/tags.$pkg $rundir/tags.$pkg");
+ runsystem_ok("diff", "-u", "$origdir/tags", "$rundir/tags.$pkg");
exit 1 unless $run_all_tests;
next;
}
open TAGS, "$rundir/tags.$pkg" or fail("Cannot open $rundir/tags.$pkg");
while (<TAGS>) {
- next if /^N: /;
+ next if m/^N: /;
if (not /^(.): (\S+)(?: (?:source|udeb))?: (\S+)/) {
print "E: Invalid line:\n$_";
next;
@@ -298,7 +307,7 @@ for (@tests) {
$tags{$3}{'tested_type'} = $types{$1};
$tags{$3}{'tested_package'} = $2;
}
- close TAGS;
+ close TAGS;
}
print "Checking whether all tags are tested and tags have description ... \n";
@@ -327,17 +336,58 @@ if ($testok) {
# --------------
sub runsystem {
+ print "runsystem(@_)\n" if $debug;
system(@_) == 0
or fail("failed: @_\n");
}
sub runsystem_ok {
+ print "runsystem_ok(@_)\n" if $debug;
my $errcode = system(@_);
$errcode == 0 or $errcode == (1 << 8)
or fail("failed: @_\n");
return $errcode == 0;
}
+use Text::Template;
+sub fill_in_tmpl {
+ my ($file, $data) = @_;
+ my $tmpl = "$file.in";
+
+ my $template = Text::Template->new(TYPE => 'FILE', SOURCE => $tmpl);
+ open my $out, '>', $file
+ or fail("cannot open $file: $!");
+
+ unless ($template->fill_in(OUTPUT => $out, HASH => $data)) {
+ fail("cannout create $file");
+ }
+ close $out;
+}
+
+use Data::Dumper;
+sub check_test_is_sane {
+ my ($dir, $data) = @_;
+
+ if ($debug) {
+ print "check_test_is_sane <= ".Dumper($data);
+ }
+
+ unless ($data->{testname} && $data->{version}) {
+ fail("Name or Version missing");
+ }
+
+ $data->{srcpkg} ||= $data->{testname};
+ $data->{type} ||= 'native';
+ $data->{date} ||= `date -R`; chomp $data->{date};
+ $data->{description} ||= 'No Description Available';
+ $data->{author} ||= 'Debian Lintian Maintainers <lintian-maint@debian.org>';
+ $data->{architecture} ||= 'all';
+
+ if ($debug) {
+ print "check_test_is_sane => ".Dumper($data);
+ }
+}
+
# Local Variables:
# indent-tabs-mode: t
# cperl-indent-level: 4
diff --git a/reporting/lintian-dummy.cfg b/t/templates/skel.upstream/.dummy
similarity index 100%
copy from reporting/lintian-dummy.cfg
copy to t/templates/skel.upstream/.dummy
diff --git a/t/templates/skel/debian/changelog b/t/templates/skel/debian/changelog
new file mode 100644
index 0000000..66eca6b
--- /dev/null
+++ b/t/templates/skel/debian/changelog
@@ -0,0 +1,9 @@
+skel (1.0) unstable; urgency=low
+
+ * Initial design.
+ Please see changelog.in for the actual changelog
+ that will be used unless it is overwritten in the
+ individual test.
+
+ -- Frank Lichtenheld <djpig@debian.org> Sun, 03 Aug 2008 16:46:13 +0200
+
diff --git a/t/templates/skel/debian/changelog.in b/t/templates/skel/debian/changelog.in
new file mode 100644
index 0000000..240c83a
--- /dev/null
+++ b/t/templates/skel/debian/changelog.in
@@ -0,0 +1,6 @@
+{$srcpkg} ({$version}) unstable; urgency=low
+
+ * Lintian Test Suite.
+ * Test: {$testname}
+
+ -- {$author} {$date}
diff --git a/testset/dh7-minimal/debian/compat b/t/templates/skel/debian/compat
similarity index 100%
copy from testset/dh7-minimal/debian/compat
copy to t/templates/skel/debian/compat
diff --git a/t/templates/skel/debian/control.in b/t/templates/skel/debian/control.in
new file mode 100644
index 0000000..bc8f6c0
--- /dev/null
+++ b/t/templates/skel/debian/control.in
@@ -0,0 +1,13 @@
+Source: {$srcpkg}
+Priority: extra
+Section: devel
+Maintainer: {$author}
+Standards-Version: 3.8.0
+Build-Depends: debhelper (>= 7)
+
+Package: {$srcpkg}
+Architecture: {$architecture}
+Depends: $\{shlib:Depends\}, $\{misc:Depends\}
+Description: {$description}
+ .
+ Part of the lintian test suite.
diff --git a/t/templates/skel/debian/copyright b/t/templates/skel/debian/copyright
new file mode 100644
index 0000000..b780d82
--- /dev/null
+++ b/t/templates/skel/debian/copyright
@@ -0,0 +1,21 @@
+This is part of the testsuite of lintian. See the file debian/copyright
+in the lintian source directory for more details.
+
+So far as it is copyrightable at all, this template is
+ Copyright © 2008 Frank Lichtenheld <djpig@debian.org>
+
+This program is free software; you may redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This 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.
+
+A copy of the GNU General Public License version 2 is available as
+/usr/share/common-licenses/GPL-2 in the Debian GNU/Linux distribution
+or at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+You can also obtain it by writing to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/testset/dh7-minimal/debian/rules b/t/templates/skel/debian/rules
similarity index 100%
copy from testset/dh7-minimal/debian/rules
copy to t/templates/skel/debian/rules
diff --git a/t/tests/0000_basic.desc b/t/tests/0000_basic.desc
new file mode 100644
index 0000000..96d9f45
--- /dev/null
+++ b/t/tests/0000_basic.desc
@@ -0,0 +1,2 @@
+Testname: basic
+Version: 1.0
diff --git a/t/tests/0001_basic-non-native.desc b/t/tests/0001_basic-non-native.desc
new file mode 100644
index 0000000..e17a229
--- /dev/null
+++ b/t/tests/0001_basic-non-native.desc
@@ -0,0 +1,3 @@
+Testname: basic-non-native
+Type: non-native
+Version: 1.0
diff --git a/reporting/lintian-dummy.cfg b/t/tests/basic-non-native/tags
similarity index 100%
copy from reporting/lintian-dummy.cfg
copy to t/tests/basic-non-native/tags
diff --git a/t/tests/basic-non-native/upstream/README b/t/tests/basic-non-native/upstream/README
new file mode 100644
index 0000000..e845566
--- /dev/null
+++ b/t/tests/basic-non-native/upstream/README
@@ -0,0 +1 @@
+README
diff --git a/t/tests/basic/debian/README b/t/tests/basic/debian/README
new file mode 100644
index 0000000..e845566
--- /dev/null
+++ b/t/tests/basic/debian/README
@@ -0,0 +1 @@
+README
diff --git a/reporting/lintian-dummy.cfg b/t/tests/basic/tags
similarity index 100%
copy from reporting/lintian-dummy.cfg
copy to t/tests/basic/tags
--
Debian package checker
Reply to: