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

[SCM] Debian package checker branch, master, updated. 2.1.3-15-g27fda1f



The following commit has been merged in the master branch:
commit 27fda1f685621768c5c88f0c8a3f0e31b70d9d02
Author: Russ Allbery <rra@debian.org>
Date:   Mon Dec 29 12:37:17 2008 -0800

    Add a way to run only tests affecting a particular tag
    
    * debian/rules:
      + [RA] New check-tag target which runs all test cases in the new test
        suite that check for or against a particular tag.
    * t/runtests:
      + [RA] Support finding and running all tests for or against a
        particular tag.

diff --git a/debian/changelog b/debian/changelog
index 36d331a..55ab596 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,10 @@ lintian (2.1.4) UNRELEASED; urgency=low
       - unusual-control-interpreter is certain, not possible.
       - Suppress some cases of multiple tags about the same basic problem.
 
+  * debian/rules:
+    + [RA] New check-tag target which runs all test cases in the new test
+      suite that check for or against a particular tag.
+
   * private/update-never-seen:
     + [RA] Merge data from both test suites and use the tag files for the
       old test suite rather than relying on runtests -v.
@@ -39,6 +43,8 @@ lintian (2.1.4) UNRELEASED; urgency=low
   * t/runtests:
     + [RA] Check that a test produces all tags listed in Test-For and
       doesn't produce any tages listed in Test-Against.
+    + [RA] Support finding and running all tests for or against a
+      particular tag.
 
  -- Russ Allbery <rra@debian.org>  Sun, 28 Dec 2008 13:02:03 -0800
 
diff --git a/debian/rules b/debian/rules
index 945d329..57f6102 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,6 +12,7 @@ tagfiles := $(wildcard testset/tags.* t/*/tags)
 testfiles := $(wildcard t/tests/*.desc)
 perlprovides := data/fields/perl-provides
 onlyrun =
+tag =
 
 runtests: $(neededfiles) $(allchecks) $(allcollect) $(tagfiles) $(testfiles)
 	@echo .... running tests ....
@@ -20,6 +21,14 @@ runtests: $(neededfiles) $(allchecks) $(allcollect) $(tagfiles) $(testfiles)
 	LINTIAN_ROOT="" $(PERL) t/runtests -k t debian/tests $(onlyrun)
 	if [ "$(onlyrun)" = "" ]; then touch $@; fi
 
+# Like runtests but only runs tests affecting a particular tag.  That tag
+# should be specified by setting the tag makefile variable.
+check-tag:
+	@if [ "$(tag)" = "" ]; then \
+		echo 'Specify tag to test with tag=<tag>'; exit 1; \
+	fi
+	LINTIAN_ROOT="" $(PERL) t/runtests -k -t $(tag) t debian/tests
+
 # this target is only run manually
 refresh-perl-provides:
 	perl private/refresh-perl-provides > $(perlprovides)
diff --git a/t/runtests b/t/runtests
index dd2602b..6bd74b2 100755
--- a/t/runtests
+++ b/t/runtests
@@ -28,7 +28,8 @@ use Text::Template;
 
 sub usage {
     print <<END;
-Usage: $0 [-k] [-v] [-d] testset-directory testing-directory [test]
+Usage: $0 [-dkv] testset-directory testing-directory [test]
+       $0 [-dkv] [-t tag] testset-directory testing-directory
 
 The -k option means do not stop after one failed test, but try
 them all and report all errors.
@@ -38,6 +39,8 @@ not tested in any testset-package.
 
 The -d option will display debugging information.
 
+The -t tag option will only run tests that test for or against that tag.
+
 The optional 3rd parameter causes runtests to only run that particular test.
 END
     exit 2;
@@ -58,16 +61,21 @@ my $debug = 0;
 
 my $run_all_tests = 0;
 my $verbose = 0;
+my $tag;
 
 # --- Parse options and arguments
 Getopt::Long::Configure('bundling');
 GetOptions('d|debug'      => \$debug,
 	   'k|keep-going' => \$run_all_tests,
+	   't|tag=s'      => \$tag,
 	   'v|verbose'    => \$verbose) or usage;
 if ($#ARGV < 1 || $#ARGV > 2) {
     usage;
 }
 my ($testset, $rundir, $singletest) = @ARGV;
+if ($tag and $singletest) {
+    usage;
+}
 
 # --- Set and unset environment variables that lintian is sensitive to
 BEGIN {
@@ -111,6 +119,8 @@ $| = 1;
 my @tests;
 if ($singletest) {
     @tests = map { s/\.desc$//; $_ } ( $singletest );
+} elsif ($tag) {
+    @tests = find_tests_for_tag($tag);
 } else {
     -d $testset
 	or fail("cannot find $testset: $!\n");
@@ -222,6 +232,8 @@ for (@tests) {
 if (!$tests_run) {
     if ($singletest) {
 	print "W: No tests run, did you specify a valid test name?\n";
+    } elsif ($tag) {
+	print "I: No tests found for that tag.\n";
     } else {
 	print "E: No tests run, did you specify a valid testset directory?\n";
     }
@@ -283,6 +295,32 @@ sub check_test_is_sane {
     }
 }
 
+# Find all tests that check a particular tag, either for its presence or
+# absence.  Returns a list of names of the *.desc files, without the *.desc at
+# the end.
+sub find_tests_for_tag {
+    my ($tag) = @_;
+    my @tests;
+    for my $test (<$testset/tests/*.desc>) {
+	my ($testname) = ($test =~ m,.*/([^/]+)\.desc$,);
+	my ($data) = read_dpkg_control($test);
+	if ($data->{'test-for'}) {
+	    my %for = map { $_ => 1 } split(' ', $data->{'test-for'});
+	    if ($for{$tag}) {
+		push (@tests, $testname);
+		next;
+	    }
+	}
+	if ($data->{'test-against'}) {
+	    my %against = map { $_ => 1 } split(' ', $data->{'test-against'});
+	    if ($against{$tag}) {
+		push (@tests, $testname);
+	    }
+	}
+    }
+    return @tests;
+}
+
 # Local Variables:
 # indent-tabs-mode: t
 # cperl-indent-level: 4

-- 
Debian package checker


Reply to: