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

[SCM] Debian package checker branch, master, updated. 2.5.1-196-g7c622ef



The following commit has been merged in the master branch:
commit 7c622ef9b86cce0456679134e571045bceae880a
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Aug 7 00:51:19 2011 +0200

    t/runtests: upgraded changes test suite
    
    The changes test-suite now uses desc files like t/tests and allows
    for "test-for" and "test-against".

diff --git a/t/changes/changed-by-localhost.changes b/t/changes/changed-by-localhost.changes
deleted file mode 100644
index 51d9619..0000000
--- a/t/changes/changed-by-localhost.changes
+++ /dev/null
@@ -1,12 +0,0 @@
-Format: 1.8
-Date: Sat, 10 Jan 2009 10:50:38 -0800
-Source: changed-by-malformed
-Binary: changed-by-malformed
-Architecture: source all
-Version: 1.0
-Distribution: unstable
-Urgency: low
-Maintainer: Debian Lintian Maintainers <lintian-maint@debian.org>
-Changed-By: Someone <someone@localhost.localdomain>
-Description:
- changed-by-malformed - Test Changed-By field with localhost address
diff --git a/t/changes/changed-by-localhost.changes.in b/t/changes/changed-by-localhost.changes.in
new file mode 100644
index 0000000..5d5b5a6
--- /dev/null
+++ b/t/changes/changed-by-localhost.changes.in
@@ -0,0 +1,12 @@
+Format: 1.8
+Date: {$date}
+Source: {$srcpkg}
+Binary: {$srcpkg}
+Architecture: source all
+Version: {$version}
+Distribution: unstable
+Urgency: low
+Maintainer: {$author}
+Changed-By: Someone <someone@localhost.localdomain>
+Description:
+ {$srcpkg} - {$description}
diff --git a/t/changes/changed-by-localhost.desc b/t/changes/changed-by-localhost.desc
new file mode 100644
index 0000000..7904283
--- /dev/null
+++ b/t/changes/changed-by-localhost.desc
@@ -0,0 +1,5 @@
+Testname: changed-by-localhost
+Sequence: 6000
+Version: 1.0
+Description: Test Changed-By field with localhost address
+Test-For: changed-by-address-is-on-localhost
diff --git a/t/changes/changed-by-malformed.changes b/t/changes/changed-by-malformed.changes
deleted file mode 100644
index b6e8ec7..0000000
--- a/t/changes/changed-by-malformed.changes
+++ /dev/null
@@ -1,12 +0,0 @@
-Format: 1.8
-Date: Sat, 10 Jan 2009 10:50:38 -0800
-Source: changed-by-malformed
-Binary: changed-by-malformed
-Architecture: source all
-Version: 1.0
-Distribution: unstable
-Urgency: low
-Maintainer: Debian Lintian Maintainers <lintian-maint@debian.org>
-Changed-By: Foo<bar> Baz
-Description:
- changed-by-malformed - Test malformed Changed-By field
diff --git a/t/changes/changed-by-malformed.changes.in b/t/changes/changed-by-malformed.changes.in
new file mode 100644
index 0000000..3922427
--- /dev/null
+++ b/t/changes/changed-by-malformed.changes.in
@@ -0,0 +1,12 @@
+Format: 1.8
+Date: {$date}
+Source: {$srcpkg}
+Binary: {$srcpkg}
+Architecture: source all
+Version: {$version}
+Distribution: unstable
+Urgency: low
+Maintainer: {$author}
+Changed-By: Foo<bar> Baz
+Description:
+ {$srcpkg} - {$description}
diff --git a/t/changes/changed-by-malformed.desc b/t/changes/changed-by-malformed.desc
new file mode 100644
index 0000000..8cdddc6
--- /dev/null
+++ b/t/changes/changed-by-malformed.desc
@@ -0,0 +1,7 @@
+Testname: changed-by-malformed
+Sequence: 6000
+Version: 1.0
+Description: Test malformed Changed-By field
+Test-For:
+ changed-by-address-malformed
+ changed-by-address-looks-weird
diff --git a/t/changes/changed-by-no-name.changes b/t/changes/changed-by-no-name.changes
index 1053dd3..bbedd49 100644
--- a/t/changes/changed-by-no-name.changes
+++ b/t/changes/changed-by-no-name.changes
@@ -1,12 +1,12 @@
 Format: 1.8
-Date: Sat, 10 Jan 2009 10:50:38 -0800
-Source: changed-by-malformed
-Binary: changed-by-malformed
+Date: {$date}
+Source: {$srcpkg}
+Binary: {$srcpkg}
 Architecture: source all
-Version: 1.0
+Version: {$version}
 Distribution: unstable
 Urgency: low
-Maintainer: Debian Lintian Maintainers <lintian-maint@debian.org>
+Maintainer: {$author}
 Changed-By: someone@example.com
 Description:
- changed-by-malformed - Test Changed-By field with localhost address
+ {$srcpkg} - {$description}
diff --git a/t/changes/changed-by-no-name.desc b/t/changes/changed-by-no-name.desc
new file mode 100644
index 0000000..48cde76
--- /dev/null
+++ b/t/changes/changed-by-no-name.desc
@@ -0,0 +1,6 @@
+Testname: changed-by-no-name
+Sequence: 6000
+Version: 1.0
+Description: Test Changed-By field with missing name
+Test-For:
+ changed-by-name-missing
diff --git a/t/changes/changes-bad-ubuntu-distribution.changes b/t/changes/changes-bad-ubuntu-distribution.changes
deleted file mode 100644
index b2194cb..0000000
--- a/t/changes/changes-bad-ubuntu-distribution.changes
+++ /dev/null
@@ -1,12 +0,0 @@
-Format: 1.8
-Date: Sat,  3 Apr 2010 18:21:15 +0100
-Source: changes-bad-ubuntu-distribution
-Binary: changes-bad-ubuntu-distribution
-Architecture: source all
-Version: 1.0+ubuntu2
-Distribution: wispy
-Urgency: low
-Maintainer: Debian Lintian Maintainers <lintian-maint@debian.org>
-Changed-By: Debian Lintian Maintainers <lintian-maint@debian.org>
-Description:
- changes-bad-ubuntu-distribution - Test for valid Ubuntu distribution
diff --git a/t/changes/changes-bad-ubuntu-distribution.changes.in b/t/changes/changes-bad-ubuntu-distribution.changes.in
new file mode 100644
index 0000000..7d78256
--- /dev/null
+++ b/t/changes/changes-bad-ubuntu-distribution.changes.in
@@ -0,0 +1,12 @@
+Format: 1.8
+Date: {$date}
+Source: {$srcpkg}
+Binary: {$srcpkg}
+Architecture: source all
+Version: {$version}
+Distribution: wispy
+Urgency: low
+Maintainer: {$author}
+Changed-By: {$author}
+Description:
+ {$srcpkg} - {$description}
diff --git a/t/changes/changes-bad-ubuntu-distribution.desc b/t/changes/changes-bad-ubuntu-distribution.desc
new file mode 100644
index 0000000..e9d19c4
--- /dev/null
+++ b/t/changes/changes-bad-ubuntu-distribution.desc
@@ -0,0 +1,6 @@
+Testname: changes-bad-ubuntu-distribution
+Sequence: 6000
+Version: 1.0+ubuntu2
+Description: Test for invalid Ubuntu distribution
+Test-For:
+ bad-ubuntu-distribution-in-changes-file
diff --git a/t/changes/changes-directory-traversal.changes b/t/changes/changes-directory-traversal.changes
deleted file mode 100644
index caa36cd..0000000
--- a/t/changes/changes-directory-traversal.changes
+++ /dev/null
@@ -1,14 +0,0 @@
-Format: 1.8
-Date: Sat, 10 Jan 2009 10:50:38 -0800
-Source: changes-directory-traversal
-Binary: changes-directory-traversal
-Architecture: source all
-Version: 1.0
-Distribution: unstable
-Urgency: low
-Maintainer: Debian Lintian Maintainers <lintian-maint@debian.org>
-Changed-By: Debian Lintian Maintainers <lintian-maint@debian.org>
-Description:
- changes-directory-traversal - Test directory traversal when processing Files
-Files:
- 12345678901234567890123456789012 123 admin optional ../foo-bar-moo
diff --git a/t/changes/changes-directory-traversal.changes.in b/t/changes/changes-directory-traversal.changes.in
new file mode 100644
index 0000000..9b70bcc
--- /dev/null
+++ b/t/changes/changes-directory-traversal.changes.in
@@ -0,0 +1,14 @@
+Format: 1.8
+Date: {$date}
+Source: {$srcpkg}
+Binary: {$srcpkg}
+Architecture: source all
+Version: {$version}
+Distribution: unstable
+Urgency: low
+Maintainer: {$author}
+Changed-By: {$author}
+Description:
+ {$srcpkg} - {$description}
+Files:
+ 12345678901234567890123456789012 123 admin optional ../foo-bar-moo
diff --git a/t/changes/changes-directory-traversal.desc b/t/changes/changes-directory-traversal.desc
new file mode 100644
index 0000000..12fd7c7
--- /dev/null
+++ b/t/changes/changes-directory-traversal.desc
@@ -0,0 +1,4 @@
+Testname: changes-directory-traversal
+Sequence: 6000
+Version: 1.0
+Description: Test directory traversal when processing Files
diff --git a/t/changes/changes-double-signed.desc b/t/changes/changes-double-signed.desc
new file mode 100644
index 0000000..e81b18f
--- /dev/null
+++ b/t/changes/changes-double-signed.desc
@@ -0,0 +1,5 @@
+Testname: changes-double-signed
+Sequence: 6000
+Version: 1.0
+Description: Test double-signed changes file
+Test-For: malformed-changes-file
diff --git a/t/changes/changes-missing-fields.changes b/t/changes/changes-missing-fields.changes
deleted file mode 100644
index 1fce7a3..0000000
--- a/t/changes/changes-missing-fields.changes
+++ /dev/null
@@ -1,9 +0,0 @@
-Format: 1.8
-Date: Sat,  3 Apr 2010 18:21:15 +0100
-Source: changes-missing-fields
-Binary: changes-missing-fields
-Architecture: source all
-Version: 1.0
-Distribution: unstable
-Maintainer: Debian Lintian Maintainers <lintian-maint@debian.org>
-Changed-By: Debian Lintian Maintainers <lintian-maint@debian.org>
diff --git a/t/changes/changes-missing-fields.changes.in b/t/changes/changes-missing-fields.changes.in
new file mode 100644
index 0000000..5b90281
--- /dev/null
+++ b/t/changes/changes-missing-fields.changes.in
@@ -0,0 +1,9 @@
+Format: 1.8
+Date: {$date}
+Source: {$srcpkg}
+Binary: {$srcpkg}
+Architecture: source all
+Version: {$version}
+Distribution: unstable
+Maintainer: {$author}
+Changed-By: {$author}
diff --git a/t/changes/changes-missing-fields.desc b/t/changes/changes-missing-fields.desc
new file mode 100644
index 0000000..123c36f
--- /dev/null
+++ b/t/changes/changes-missing-fields.desc
@@ -0,0 +1,7 @@
+Testname: changes-missing-fields
+Sequence: 6000
+Version: 1.0
+Description: Test for changes missing fields
+Test-For:
+ no-description-in-changes-file
+ no-urgency-in-changes-file
diff --git a/t/runtests b/t/runtests
index 6a2c7fa..cf65355 100755
--- a/t/runtests
+++ b/t/runtests
@@ -71,6 +71,8 @@ chomp $ARCHITECTURE;
 my %TEMPLATES = (
     'tests' => ['debian/changelog', 'debian/control'],
 );
+my $DATE = `date -R`;
+chomp $DATE;
 
 # --- Usage information
 
@@ -209,22 +211,19 @@ if (@tests) {
 $prev = scalar(@tests);
 @tests = ();
 if ($singletest) {
-    my $test = $singletest;
-    $test =~ s/\.changes$//;
-    if (-f "$TESTSET/changes/$test.changes") {
-	@tests = ($test);
+    my $desc = "$TESTSET/changes/$singletest";
+    $desc =~ s/\.changes$//;
+    $desc = "$desc.desc";
+    if (-f $desc) {
+	@tests = read_dpkg_control($desc);
     }
 } elsif ($tag) {
-    @tests = generic_find_test_for_tag($tag, "$TESTSET/changes/*.tags");
+    @tests = find_tests_for_tag($tag, "$TESTSET/changes/*.desc");
 } else {
     unless (-d "$TESTSET/changes") {
 	fail("cannot find $TESTSET/changes: $!");
     }
-    @tests = map {
-	s,^\Q$TESTSET/changes/\E,,;
-	s/\.changes$//;
-	$_;
-    } sort(<$TESTSET/changes/*.changes>);
+    @tests = map { read_dpkg_control($_) } sort(<$TESTSET/changes/*.desc>);
 }
 print "Found the following changes tests: @tests\n" if $DEBUG;
 print "Changes tests:\n" if @tests;
@@ -317,7 +316,7 @@ if ($singletest) {
 	@tests = map { read_dpkg_control($_) } <$TESTSET/tests/$singletest-*/desc>;
     }
 } elsif ($tag) {
-    @tests = find_tests_for_tag($tag);
+    @tests = find_tests_for_tag($tag, "$TESTSET/tests/*/desc");
 } else {
     unless (-d "$TESTSET/tests/") {
 	fail("cannot find $TESTSET/tests: $!");
@@ -360,8 +359,8 @@ exit $status;
 # absence.  Returns a list of names of the *.desc files, without the *.desc at
 # the end.
 sub find_tests_for_tag {
-    my ($tag) = @_;
-    return generic_find_test_for_tag($tag, "$TESTSET/tests/*/desc", sub {
+    my ($tag, $glob) = @_;
+    return generic_find_test_for_tag($tag, $glob, sub {
 	my ($tag, $desc) = @_;
 	my ($data) = read_dpkg_control($desc);
 	my $tagnames = $data->{'test-for'}//'';
@@ -447,20 +446,40 @@ sub test_package {
 	runsystem("$origdir/pre_build", $targetdir);
     }
 
+    my $file = _builder_tests($testdata, "$rundir/$pkgdir", "$rundir/build.$pkg");
+
+    run_lintian($testdata, $file, "$rundir/tags.$pkg");
+
+    # Run a sed-script if it exists, for tests that have slightly variable
+    # output
+    runsystem_ok("sed -ri -f $origdir/post_test $rundir/tags.$pkg")
+	if -e "$origdir/post_test";
+
+    return _check_result($testdata, "$origdir/tags", "$rundir/tags.$pkg");
+}
+
+sub _builder_tests {
+    my ($testdata, $testdir, $log) = @_;
+    my $pkg = $testdata->{srcpkg};
     msg_print 'building... ';
-    my $res = system("cd $rundir/$pkgdir && $DPKG_BUILDPACKAGE >../build.$pkg 2>&1");
+    my $res = system("cd $testdir && $DPKG_BUILDPACKAGE >$log 2>&1");
     if ($res){
-	dump_log($pkg, "$rundir/build.$pkg") if $DUMP_LOGS;
-	fail("cd $rundir/$pkgdir && $DPKG_BUILDPACKAGE >../build.$pkg 2>&1");
+	dump_log($pkg, $log) if $DUMP_LOGS;
+	fail("cd $testdir && $DPKG_BUILDPACKAGE >$log 2>&1");
     }
-
     my $version = $testdata->{version};
     $version =~ s/^(\d+)://;
-    my @options = split(' ', $testdata->{options});
-    my ($file) = glob("$rundir/$pkg\_$version*.changes");
+
+    my ($file) = glob("$testdir/../$pkg\_$version*.changes");
+    return $file;
+}
+
+sub run_lintian {
+    my ($testdata, $file, $out) = @_;
     msg_print 'testing... ';
-    my $opts = { err => "$rundir/tags.$pkg", fail => 'never' };
+    my $opts = { err => "$out", fail => 'never' };
     my $status;
+    my @options = split(' ', $testdata->{options}//'');
     unshift(@options, '--allow-root', '--no-cfg');
     unshift(@options, '--profile', $testdata->{profile}) if $testdata->{profile};
     if ($testdata->{sort}) {
@@ -472,17 +491,11 @@ sub test_package {
 	msg_print "FAILED:\n";
 	fail("$LINTIAN @options $file exited with status $status\n");
     }
-    open(OUT, '>>', "$rundir/tags.$pkg")
-	or fail("cannot append to $rundir/tags.$pkg: $!");
-    print OUT ${ $opts->{out} };
-    close OUT;
-
-    # Run a sed-script if it exists, for tests that have slightly variable
-    # output
-    runsystem_ok("sed -ri -f $origdir/post_test $rundir/tags.$pkg")
-	if -e "$origdir/post_test";
-
-    return _check_result($testdata, "$origdir/tags", "$rundir/tags.$pkg");
+    open(my $fd, '>>', "$out")
+	or fail("cannot append to $out: $!");
+    print $fd ${ $opts->{out} };
+    close $fd or fail "closing $out: $!";
+    return 1;
 }
 
 # --- Changes file testing
@@ -491,16 +504,28 @@ sub test_package {
 # other errors detected.  Takes the test name.  Returns true if the test
 # passes and false if it fails.
 sub test_changes {
-    my ($test) = @_;
-    msg_print "Running $test... ";
+    my ($testdata) = @_;
 
+    if (!check_test_is_sane($TESTSET, $testdata)) {
+	msg_print "Skipping test $testdata->{testname} $testdata->{version}... architecture mismatch\n";
+	return 1;
+    }
+
+    msg_print "Running $testdata->{testname} $testdata->{version}... ";
+
+    my $test = $testdata->{srcpkg};
     my $testdir = "$TESTSET/changes";
+    my $file = "$testdir/$test.changes";
+    if ( ! -e $file && -e "$file.in" ) {
+	msg_print "building... ";
+	runsystem('cp', '-f', "${file}.in", "$RUNDIR/${test}.changes.in");
+	$file = "$RUNDIR/${test}.changes";
+	fill_in_tmpl($file, $testdata);
+    }
 
-    msg_print 'testing... ';
-    runsystem_ok("$LINTIAN --allow-root --no-cfg -I -E $testdir/$test.changes 2>&1"
-		 . " | sort > $RUNDIR/tags.changes-$test");
+    run_lintian($testdata, $file, "$RUNDIR/tags.changes-$test");
 
-    return _check_result(undef, "$testdir/$test.tags", "$RUNDIR/tags.changes-$test");
+    return _check_result($testdata, "$testdir/$test.tags", "$RUNDIR/tags.changes-$test");
 }
 
 # --------------
@@ -765,7 +790,7 @@ sub check_test_is_sane {
 
     $data->{srcpkg} ||= $data->{testname};
     $data->{type} ||= 'native';
-    $data->{date} ||= `date -R`; chomp $data->{date};
+    $data->{date} ||= $DATE;
     $data->{description} ||= 'No Description Available';
     $data->{author} ||= 'Debian Lintian Maintainers <lintian-maint@debian.org>';
     $data->{architecture} ||= 'all';

-- 
Debian package checker


Reply to: