summaryrefslogtreecommitdiffstats
path: root/t/scripts/harness
diff options
context:
space:
mode:
Diffstat (limited to 't/scripts/harness')
-rw-r--r--t/scripts/harness/calibrated.t54
-rw-r--r--t/scripts/harness/check-result.t117
-rw-r--r--t/scripts/harness/desc-fields.t172
-rw-r--r--t/scripts/harness/diagnostic-value.t102
-rw-r--r--t/scripts/harness/get-tagnames.t63
-rw-r--r--t/scripts/harness/hintdiff.t207
-rw-r--r--t/scripts/harness/hintextract.t98
-rw-r--r--t/scripts/harness/match-glob.t67
-rw-r--r--t/scripts/harness/no-watch-file-in-native.t70
-rw-r--r--t/scripts/harness/prepare.t159
-rw-r--r--t/scripts/harness/sort-order.t89
-rw-r--r--t/scripts/harness/tag-coverage.t171
-rw-r--r--t/scripts/harness/watch-file-in-non-native.t70
13 files changed, 1439 insertions, 0 deletions
diff --git a/t/scripts/harness/calibrated.t b/t/scripts/harness/calibrated.t
new file mode 100644
index 0000000..73c6f13
--- /dev/null
+++ b/t/scripts/harness/calibrated.t
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2019 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The harness for Lintian's test suite. For detailed information on
+# the test suite layout and naming conventions, see t/tests/README.
+# For more information about running tests, see
+# doc/tutorial/Lintian/Tutorial/TestSuite.pod
+#
+
+use strict;
+use warnings;
+use v5.10;
+
+use File::Find::Rule;
+use Path::Tiny;
+use Test::More;
+
+my @descpaths = File::Find::Rule->file->name('desc')->in('t/recipes');
+
+# set the testing plan
+plan tests => scalar @descpaths;
+
+for my $descpath (@descpaths) {
+
+ my $testpath = path($descpath)->parent->parent->stringify;
+ my $hintspath = "$testpath/eval/hints";
+ my $literalpath = "$testpath/eval/literal";
+
+ ok(-r $hintspath || -r $literalpath,
+ "Calibrated hints or literal output is readable in $testpath");
+}
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/check-result.t b/t/scripts/harness/check-result.t
new file mode 100644
index 0000000..33fb1ec
--- /dev/null
+++ b/t/scripts/harness/check-result.t
@@ -0,0 +1,117 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2018 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA
+
+use strict;
+use warnings;
+
+BEGIN {
+ $ENV{'LINTIAN_BASE'} //= q{.};
+}
+
+use File::Basename qw(basename);
+use File::stat;
+use File::Temp;
+use Path::Tiny;
+use Test::More;
+
+use lib "$ENV{'LINTIAN_BASE'}/lib";
+use Test::Lintian::Run qw(check_result);
+use Test::Lintian::ConfigFile qw(read_config);
+use Test::Lintian::Templates;
+
+# dummy test name; used in desc and directory name
+my $TESTNAME = 'distribution-multiple-bad';
+
+# temporary work directory
+my $tempdir = Path::Tiny->tempdir();
+my $testpath = $tempdir->child($TESTNAME);
+$testpath->mkpath;
+
+# test description
+my $desctext =<<"EOSTR";
+Testname: $TESTNAME
+Sequence: 2500
+Version: 1.0
+Description: Multiple distributions with at least one bad one
+Check:
+ changes-file
+References: Debian Bug #514853
+EOSTR
+
+my $descpath = $testpath->child('desc');
+$descpath->spew($desctext);
+
+# expected hints
+my $expectedtext =<<'EOSTR';
+distribution-multiple-bad (changes): multiple-distributions-in-changes-file stable foo-backportss bar foo
+distribution-multiple-bad (changes): bad-distribution-in-changes-file foo-backportss
+distribution-multiple-bad (changes): bad-distribution-in-changes-file foo
+distribution-multiple-bad (changes): bad-distribution-in-changes-file bar
+distribution-multiple-bad (changes): backports-upload-has-incorrect-version-number 1.0
+distribution-multiple-bad (changes): backports-changes-missing
+EOSTR
+
+my $expected = $testpath->child('hints');
+$expected->spew($expectedtext);
+
+# actual hints with one line missing
+my $nomatchtext =<<'EOSTR';
+distribution-multiple-bad (changes): multiple-distributions-in-changes-file stable foo-backportss bar foo
+distribution-multiple-bad (changes): bad-distribution-in-changes-file foo-backportss
+distribution-multiple-bad (changes): bad-distribution-in-changes-file bar
+distribution-multiple-bad (changes): backports-upload-has-incorrect-version-number 1.0
+distribution-multiple-bad (changes): backports-changes-missing
+EOSTR
+
+my $nomatch = $testpath->child('hints.nomatch');
+$nomatch->spew($nomatchtext);
+
+# copy of the expected hints
+my $match = $testpath->child('hints.match');
+$match->spew($expected->slurp);
+
+# read test case
+my $testcase = read_config($descpath);
+
+# read test defaults
+my $defaultspath = 't/defaults/desc';
+my $defaults = read_config($defaultspath);
+
+for my $name ($defaults->names) {
+ $testcase->store($name, $defaults->value($name))
+ unless $testcase->declares($name);
+}
+
+# test plan
+plan tests => 2;
+
+# check when hints match
+ok(!scalar check_result($testcase, $testpath, $expected, $match),
+ 'Same hints match');
+
+# check hints do not match
+ok(scalar check_result($testcase, $testpath, $expected, $nomatch),
+ 'Different hints do not match');
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/desc-fields.t b/t/scripts/harness/desc-fields.t
new file mode 100644
index 0000000..12207f1
--- /dev/null
+++ b/t/scripts/harness/desc-fields.t
@@ -0,0 +1,172 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2020 Felix Lechner
+# Copyright (C) 2023 Axel Beckert
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The harness for Lintian's test suite. For detailed information on
+# the test suite layout and naming conventions, see t/tests/README.
+# For more information about running tests, see
+# doc/tutorial/Lintian/Tutorial/TestSuite.pod
+#
+
+use strict;
+use warnings;
+use v5.10;
+
+use Const::Fast;
+use File::Find::Rule;
+use List::SomeUtils qw(uniq);
+use List::Util qw(all any);
+use Path::Tiny;
+use Test::More;
+
+BEGIN { $ENV{'LINTIAN_BASE'} //= q{.}; }
+use lib "$ENV{'LINTIAN_BASE'}/lib";
+
+use Lintian::Profile;
+use Test::Lintian::ConfigFile qw(read_config);
+
+const my $FIXED_TESTS_PER_FILE => 7;
+
+my @descpaths = File::Find::Rule->file()->name('desc')->in('t/recipes');
+
+# mandatory fields
+my @mandatory = qw(Testname);
+
+# all known fields
+my @known = qw(
+ Check
+ Default-Lintian-Options
+ Exit-Status
+ Lintian-Command-Line
+ Match-Strategy
+ Options
+ Output-Format
+ Profile
+ See-Also
+ Test-Against
+ Test-Architectures
+ Test-Conflicts
+ Test-Depends
+ Testname
+ Todo
+);
+
+# disallowed fields
+my @disallowed = qw(Test-For Checks References Reference Ref);
+
+# tests per desc
+my $perfile = $FIXED_TESTS_PER_FILE + scalar @mandatory + scalar @disallowed;
+
+# set the testing plan
+my $known_tests = $perfile * scalar @descpaths;
+
+my $profile = Lintian::Profile->new;
+$profile->load(undef, undef, 0);
+
+for my $descpath (@descpaths) {
+
+ # test for duplicate fields
+ my %count;
+ my @lines = path($descpath)->lines_utf8;
+ for my $line (@lines) {
+ my ($field) = $line =~ qr/^(\S+):/;
+ $count{$field} += 1
+ if defined $field;
+ }
+ ok(
+ (all { $count{$_} == 1 } keys %count),
+ "No duplicate fields in $descpath"
+ );
+
+ ok(
+ (
+ all {
+ my $key = $_;
+ any { $key eq $_ } @known;
+ } keys %count
+ ),
+ "No unknown field names are present in $descpath"
+ );
+
+ my $testcase = read_config($descpath);
+
+ # get test path
+ my $testpath = path($descpath)->parent->parent->stringify;
+
+ # get name from encapsulating directory
+ my $name = path($testpath)->basename;
+
+ # name equals encapsulating directory
+ is($testcase->unfolded_value('Testname'),
+ $name, "Test name matches encapsulating directory in $testpath");
+
+ # mandatory fields
+ ok($testcase->declares($_), "Field $_ exists in $name") for @mandatory;
+
+ # disallowed fields
+ ok(!$testcase->declares($_), "Field $_ does not exist in $name")
+ for @disallowed;
+
+ # no test-against without check
+ ok(!$testcase->declares('Test-Against') || $testcase->declares('Check'),
+ "No Test-Against without Check in $name");
+
+ # get checks
+ my @check_names = $testcase->trimmed_list('Check');
+
+ # no duplicates in checks
+ is(
+ (scalar @check_names),
+ (scalar uniq @check_names),
+ "No duplicates in Check in $name"
+ );
+
+ # listed checks exist
+ ok((all { length $profile->check_module_by_name->{$_} } @check_names),
+ "All checks mentioned in $testpath exist");
+
+ # no duplicates in tags against
+ my @against = $testcase->trimmed_list('Test-Against');
+ is(
+ (scalar @against),
+ (scalar uniq @against),
+ "No duplicates in Test-Against in $name"
+ );
+
+ # listed test-against belong to listed checks
+ $known_tests += scalar @against;
+ my @tags = map { @{$profile->tag_names_for_check->{$_} // []} }
+ (@check_names, 'lintian');
+ my %relatedtags = map { $_ => 1 } @tags;
+ for my $tag (@against) {
+ ok(
+ exists $relatedtags{$tag},
+ "Tags $tag in Test-Against belongs to checks listed in $testpath"
+ );
+ }
+}
+
+done_testing($known_tests);
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/diagnostic-value.t b/t/scripts/harness/diagnostic-value.t
new file mode 100644
index 0000000..f95357c
--- /dev/null
+++ b/t/scripts/harness/diagnostic-value.t
@@ -0,0 +1,102 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2020 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The harness for Lintian's test suite. For detailed information on
+# the test suite layout and naming conventions, see t/tests/README.
+# For more information about running tests, see
+# doc/tutorial/Lintian/Tutorial/TestSuite.pod
+#
+
+use strict;
+use warnings;
+use v5.10;
+
+use File::Find::Rule;
+use List::Compare;
+use List::SomeUtils qw(uniq);
+use Path::Tiny;
+use Test::More;
+
+use Test::Lintian::ConfigFile qw(read_config);
+use Test::Lintian::Output::Universal qw(tag_name);
+
+my @known_undeclared = qw(
+);
+
+my @descpaths = File::Find::Rule->file()->name('desc')->in('t/recipes/checks');
+
+my @testpaths;
+for my $descpath (@descpaths) {
+
+ my $testpath = path($descpath)->parent->parent->stringify;
+ my $hintspath = "$testpath/eval/hints";
+
+ push(@testpaths, $testpath)
+ if -r $hintspath;
+}
+
+# set the testing plan
+plan tests => scalar @testpaths + 2;
+
+my @undeclared;
+for my $testpath (@testpaths) {
+
+ my $descpath = "$testpath/eval/desc";
+ my $hintspath = "$testpath/eval/hints";
+
+ my $testcase = read_config($descpath);
+ my @testagainst = uniq $testcase->trimmed_list('Test-Against');
+
+ my @lines = path($hintspath)->lines_utf8({ chomp => 1 });
+ my @testfor = uniq map { tag_name($_) } @lines;
+
+ my @combined = (@testfor, @testagainst);
+
+ push(@undeclared, $testpath) unless scalar @combined;
+
+ TODO: {
+ local $TODO = "Recipe does not test for or against tags in $testpath"
+ unless scalar @combined;
+
+ ok(scalar @combined, "Recipe tests for or against tags in $testpath");
+ }
+}
+
+my $missing = scalar @undeclared;
+my $total = scalar @testpaths;
+diag "$missing tests out of $total have no declared diagnostic value.";
+
+diag "Test with unknown purpose: $_" for @undeclared;
+
+my $exceptions = List::Compare->new(\@undeclared, \@known_undeclared);
+my @unknown = $exceptions->get_Lonly;
+my @solved = $exceptions->get_Ronly;
+
+is(scalar @unknown, 0, 'All tests without a declared purpose are known');
+diag "New test without a declared purpose: $_" for @unknown;
+
+is(scalar @solved,0,'Solved test should be removed from known undeclared set');
+diag "Solved test: $_" for @solved;
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/get-tagnames.t b/t/scripts/harness/get-tagnames.t
new file mode 100644
index 0000000..bed1966
--- /dev/null
+++ b/t/scripts/harness/get-tagnames.t
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2019 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA
+
+use strict;
+use warnings;
+
+BEGIN { $ENV{'LINTIAN_BASE'} //= q{.}; }
+
+use List::SomeUtils qw(uniq);
+use Path::Tiny;
+use Test::More;
+
+use lib "$ENV{'LINTIAN_BASE'}/lib";
+use Test::Lintian::Output::Universal qw(get_tag_names);
+
+# dummy hints
+my $hintstext =<<'EOSTR';
+distribution-multiple-bad (changes): bad-distribution-in-changes-file foo-backportss
+distribution-multiple-bad (changes): bad-distribution-in-changes-file foo
+distribution-multiple-bad (changes): bad-distribution-in-changes-file bar
+distribution-multiple-bad (changes): backports-upload-has-incorrect-version-number 1.0
+distribution-multiple-bad (changes): backports-changes-missing
+EOSTR
+my $hintspath = Path::Tiny->tempfile;
+$hintspath->spew($hintstext);
+
+# read tag names from file
+my @actual = sort +uniq +get_tag_names($hintspath->stringify);
+
+my @expected = qw(
+ backports-changes-missing
+ backports-upload-has-incorrect-version-number
+ bad-distribution-in-changes-file
+);
+
+# test plan
+plan tests => 1;
+
+# check when hints match
+is_deeply(\@actual, \@expected, 'Tags read via get_tag_names match');
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/hintdiff.t b/t/scripts/harness/hintdiff.t
new file mode 100644
index 0000000..ed59f38
--- /dev/null
+++ b/t/scripts/harness/hintdiff.t
@@ -0,0 +1,207 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2019 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA
+
+use strict;
+use warnings;
+
+use Capture::Tiny qw(capture_merged);
+use Const::Fast;
+use List::Util qw(none);
+use Path::Tiny;
+use Test::More;
+
+const my $EMPTY => q{};
+const my $SPACE => q{ };
+const my $LINESEP => qr/^/;
+const my $WAIT_STATUS_SHIFT => 8;
+
+# the files below were generated from changelog-file-general on Feb 1, 2019
+
+# original file
+my $original =<<'EOSTR';
+changelog-file-general (source): latest-debian-changelog-entry-without-new-date
+changelog-file-general (binary): possible-missing-colon-in-closes Closes #555555
+changelog-file-general (binary): misspelled-closes-bug #666666
+changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+changelog-file-general (binary): latest-changelog-entry-without-new-date
+changelog-file-general (binary): improbable-bug-number-in-closes 1234
+changelog-file-general (binary): epoch-changed-but-upstream-version-did-not-go-backwards 1.0 >= 1.0
+changelog-file-general (binary): debian-changelog-line-too-long line 8
+changelog-file-general (binary): debian-changelog-line-too-long line 15
+changelog-file-general (binary): debian-changelog-file-contains-obsolete-user-emacs-settings
+changelog-file-general (binary): debian-changelog-file-contains-invalid-email-address unknown@unknown
+changelog-file-general (binary): changelog-references-temp-security-identifier TEMP-1234567-abcdef
+changelog-file-general (binary): changelog-not-compressed-with-max-compression changelog.Debian.gz
+changelog-file-general (binary): bad-intended-distribution intended to experimental but uploaded to unstable
+EOSTR
+
+# test plan
+plan tests => 8;
+
+# different order
+my $reordered =<<'EOSTR';
+changelog-file-general (binary): changelog-references-temp-security-identifier TEMP-1234567-abcdef
+changelog-file-general (binary): changelog-not-compressed-with-max-compression changelog.Debian.gz
+changelog-file-general (binary): debian-changelog-line-too-long line 15
+changelog-file-general (binary): debian-changelog-file-contains-obsolete-user-emacs-settings
+changelog-file-general (binary): debian-changelog-file-contains-invalid-email-address unknown@unknown
+changelog-file-general (binary): bad-intended-distribution intended to experimental but uploaded to unstable
+changelog-file-general (binary): possible-missing-colon-in-closes Closes #555555
+changelog-file-general (binary): misspelled-closes-bug #666666
+changelog-file-general (binary): improbable-bug-number-in-closes 1234
+changelog-file-general (binary): epoch-changed-but-upstream-version-did-not-go-backwards 1.0 >= 1.0
+changelog-file-general (binary): debian-changelog-line-too-long line 8
+changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+changelog-file-general (binary): latest-changelog-entry-without-new-date
+changelog-file-general (source): latest-debian-changelog-entry-without-new-date
+EOSTR
+
+ok(hintdiff($original, $reordered) eq $EMPTY, 'Reordered hints on the right');
+ok(hintdiff($reordered, $original) eq $EMPTY, 'Reordered hints on the left');
+
+# lines missing
+my $missing =<<'EOSTR';
+changelog-file-general (source): latest-debian-changelog-entry-without-new-date
+changelog-file-general (binary): possible-missing-colon-in-closes Closes #555555
+changelog-file-general (binary): latest-changelog-entry-without-new-date
+changelog-file-general (binary): improbable-bug-number-in-closes 1234
+changelog-file-general (binary): epoch-changed-but-upstream-version-did-not-go-backwards 1.0 >= 1.0
+changelog-file-general (binary): debian-changelog-line-too-long line 15
+changelog-file-general (binary): debian-changelog-file-contains-obsolete-user-emacs-settings
+changelog-file-general (binary): debian-changelog-file-contains-invalid-email-address unknown@unknown
+changelog-file-general (binary): changelog-references-temp-security-identifier TEMP-1234567-abcdef
+changelog-file-general (binary): bad-intended-distribution intended to experimental but uploaded to unstable
+EOSTR
+
+my $missingright =<<'EOSTR';
+-changelog-file-general (binary): misspelled-closes-bug #666666
+-changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+-changelog-file-general (binary): debian-changelog-line-too-long line 8
+-changelog-file-general (binary): changelog-not-compressed-with-max-compression changelog.Debian.gz
+EOSTR
+
+ok(hintdiff($original, $missing) eq $missingright,
+ 'Missing hints on the right');
+ok(hintdiff($missing, $original) eq complement($missingright),
+ 'Missing hints on the left');
+
+# lines extra
+my $extra =<<'EOSTR';
+changelog-file-general (source): latest-debian-changelog-entry-without-new-date
+changelog-file-general (binary): possible-missing-colon-in-closes Closes #555555
+changelog-file-general (binary): misspelled-closes-bug #666666
+changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+changelog-file-general (binary): latest-changelog-entry-without-new-date
+changelog-file-general (binary): improbable-bug-number-in-closes 1234
+changelog-file-general (binary): epoch-changed-but-upstream-version-did-not-go-backwards 1.0 >= 1.0
+changelog-file-general (binary): debian-changelog-line-too-long line 8
+changelog-file-general (binary): debian-changelog-line-too-long line 15
+changelog-file-general (binary): misspelled-closes-bug #666666
+changelog-file-general (binary): debian-changelog-file-contains-obsolete-user-emacs-settings
+changelog-file-general (source): completely-new never seen before
+changelog-file-general (binary): debian-changelog-file-contains-invalid-email-address unknown@unknown
+changelog-file-general (binary): changelog-references-temp-security-identifier TEMP-1234567-abcdef
+changelog-file-general (binary): changelog-not-compressed-with-max-compression changelog.Debian.gz
+changelog-file-general (binary): bad-intended-distribution intended to experimental but uploaded to unstable
+EOSTR
+
+my $extraright =<<'EOSTR';
++changelog-file-general (source): completely-new never seen before
++changelog-file-general (binary): misspelled-closes-bug #666666
++changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+EOSTR
+
+ok(hintdiff($original, $extra) eq $extraright, 'Extra hints on the right');
+ok(hintdiff($extra, $original) eq complement($extraright),
+ 'Extra hints on the left');
+
+# lines different
+my $different =<<'EOSTR';
+changelog-file-general (source): latest-debian-changelog-entry-without-new-date
+changelog-file-general (binary): possible-missing-semicolon-in-closes Closes #555555
+changelog-file-general (binary): misspelled-closes-bug #666666
+changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+changelog-file-general (binary): latest-changelog-entry-without-new-date
+changelog-file-general (binary): improbable-bug-number-in-closes 1234
+changelog-file-general (binary): epoch-changed-but-upstream-version-did-not-go-backwards 1.0 >= 1.0
+changelog-file-general (binary): debian-changelog-line-too-long line 9
+changelog-file-general (binary): debian-changelog-line-too-long line 15
+changelog-file-general (source): debian-changelog-file-contains-obsolete-user-emacs-settings
+changelog-file-general (binary): debian-changelog-file-contains-invalid-irc-address unknown@unknown
+changelog-file-general (binary): changelog-references-temp-security-identifier TEMP-1234567-abcdef
+changelog-file-general (binary): changelog-not-compressed-with-max-compression changelog.Debian.gz
+changelog-file-general (binary): bad-intended-distribution intended to experimental but uploaded to unstable
+EOSTR
+
+my $differentright =<<'EOSTR';
+-changelog-file-general (binary): possible-missing-colon-in-closes Closes #555555
+-changelog-file-general (binary): debian-changelog-line-too-long line 8
+-changelog-file-general (binary): debian-changelog-file-contains-obsolete-user-emacs-settings
+-changelog-file-general (binary): debian-changelog-file-contains-invalid-email-address unknown@unknown
++changelog-file-general (source): debian-changelog-file-contains-obsolete-user-emacs-settings
++changelog-file-general (binary): possible-missing-semicolon-in-closes Closes #555555
++changelog-file-general (binary): debian-changelog-line-too-long line 9
++changelog-file-general (binary): debian-changelog-file-contains-invalid-irc-address unknown@unknown
+EOSTR
+
+ok(hintdiff($original, $different) eq $differentright,
+ 'Different hints on the right');
+ok(hintdiff($different, $original) eq complement($differentright),
+ 'Different hints on the left');
+
+exit;
+
+sub complement {
+ my ($diff) = @_;
+
+ return $EMPTY
+ unless length $diff;
+
+ my @lines = split($LINESEP, $diff);
+ $_ = -$_ for @lines;
+
+ return join($EMPTY, reverse sort @lines);
+}
+
+sub hintdiff {
+ my ($left_contents, $right_contents) = @_;
+
+ my $left_tiny = Path::Tiny->tempfile;
+ my $right_tiny = Path::Tiny->tempfile;
+
+ $left_tiny->spew($left_contents);
+ $right_tiny->spew($right_contents);
+
+ my @command = ('hintdiff', $left_tiny->stringify, $right_tiny->stringify);
+ my ($diff, $status) = capture_merged { system(@command); };
+ $status >>= $WAIT_STATUS_SHIFT;
+
+ die 'Error executing: ' . join($SPACE, @command) . ": $!"
+ if none { $_ eq $status } (0, 1);
+
+ return $diff;
+}
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/hintextract.t b/t/scripts/harness/hintextract.t
new file mode 100644
index 0000000..c2f8cb9
--- /dev/null
+++ b/t/scripts/harness/hintextract.t
@@ -0,0 +1,98 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2019 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA
+
+use strict;
+use warnings;
+
+use Path::Tiny;
+use Test::More;
+
+# the text below was generated from changelog-file-general on Feb 1, 2019
+
+# expected output
+my $expected =<<'EOSTR';
+changelog-file-general (source): latest-debian-changelog-entry-without-new-date
+changelog-file-general (binary): possible-missing-colon-in-closes Closes #555555
+changelog-file-general (binary): misspelled-closes-bug #666666
+changelog-file-general (binary): latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+changelog-file-general (binary): latest-changelog-entry-without-new-date
+changelog-file-general (binary): improbable-bug-number-in-closes 1234
+changelog-file-general (binary): epoch-changed-but-upstream-version-did-not-go-backwards 1.0 >= 1.0
+changelog-file-general (binary): debian-changelog-line-too-long line 8
+changelog-file-general (binary): debian-changelog-line-too-long line 15
+changelog-file-general (binary): debian-changelog-file-contains-obsolete-user-emacs-settings
+changelog-file-general (binary): debian-changelog-file-contains-invalid-email-address unknown@unknown
+changelog-file-general (binary): changelog-references-temp-security-identifier TEMP-1234567-abcdef
+changelog-file-general (binary): changelog-not-compressed-with-max-compression changelog.Debian.gz
+changelog-file-general (binary): bad-intended-distribution intended to experimental but uploaded to unstable
+EOSTR
+
+# test plan
+plan tests => 1;
+
+# EWI input
+my $ewi =<<'EOSTR';
+E: changelog-file-general source: latest-debian-changelog-entry-without-new-date
+W: changelog-file-general: changelog-not-compressed-with-max-compression changelog.Debian.gz
+W: changelog-file-general: debian-changelog-file-contains-obsolete-user-emacs-settings
+E: changelog-file-general: debian-changelog-file-contains-invalid-email-address unknown@unknown
+E: changelog-file-general: latest-changelog-entry-without-new-date
+W: changelog-file-general: latest-debian-changelog-entry-reuses-existing-version 1:1.0-1 == 1.0-1 (last used: Fri, 01 Feb 2019 12:27:45 -0800)
+E: changelog-file-general: epoch-changed-but-upstream-version-did-not-go-backwards 1.0 >= 1.0
+E: changelog-file-general: possible-missing-colon-in-closes Closes #555555
+W: changelog-file-general: changelog-references-temp-security-identifier TEMP-1234567-abcdef
+X: changelog-file-general: bad-intended-distribution intended to experimental but uploaded to unstable
+W: changelog-file-general: misspelled-closes-bug #666666
+W: changelog-file-general: improbable-bug-number-in-closes 1234
+W: changelog-file-general: debian-changelog-line-too-long line 8
+W: changelog-file-general: debian-changelog-line-too-long line 15
+EOSTR
+
+ok(
+ hintextract('EWI', $ewi) eq $expected,
+ 'Hints extracted from EWI format matched.'
+);
+
+exit;
+
+sub hintextract {
+ my ($format, $text) = @_;
+
+ my $outpath = Path::Tiny->tempfile;
+
+ my $inpath = Path::Tiny->tempfile;
+ $inpath->spew($text);
+
+ die "Cannot run hintextract: $!"
+ if (
+ system(
+ 'hintextract', '-f',$format,
+ $inpath->stringify,$outpath->stringify
+ )
+ );
+
+ return $outpath->slurp;
+}
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/match-glob.t b/t/scripts/harness/match-glob.t
new file mode 100644
index 0000000..1838537
--- /dev/null
+++ b/t/scripts/harness/match-glob.t
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2022 Axel Beckert
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The harness for Lintian's test suite. For detailed information on
+# the test suite layout and naming conventions, see t/tests/README.
+# For more information about running tests, see
+# doc/tutorial/Lintian/Tutorial/TestSuite.pod
+#
+
+use strict;
+use warnings;
+use v5.10;
+
+use Test::More;
+use Lintian::Util qw(match_glob);
+
+is_deeply([match_glob('foo*bar', qw(foo bar foobar foobazbar xfoobazbary))],
+ [qw(foobar foobazbar)],'match_glob() with simple * wildcard');
+
+is_deeply([match_glob('fo?bar', qw(foo bar foobar foobazbar xfoobarbaz))],
+ [qw(foobar)],'match_glob() with simple ? wildcard');
+
+is_deeply(
+ [match_glob('foo*[baz]', qw(foo foo[baz] foobar[baz]))],
+ [qw(foo[baz] foobar[baz])],
+ 'match_glob() with * wildcard and literal brackets'
+);
+
+is_deeply(
+ [match_glob('foo*{baz}', qw(foo foo{baz} foobar{baz} xfoobar{baz}y))],
+ [qw(foo{baz} foobar{baz})],
+ 'match_glob() with * wildcard and literal curly braces'
+);
+
+is_deeply(
+ [match_glob('foo*(baz)', qw[foo foo(baz) foobar(baz) xfoobar(baz)y])],
+ [qw[foo(baz) foobar(baz)]],
+ 'match_glob() with * wildcard and literal parentheses'
+);
+
+is_deeply([match_glob('foo.bar', qw(foo.bar foo|bar foo&bar xfoo.bary))],
+ [qw(foo.bar)],'match_glob() with no wildcard but a literal dot');
+
+done_testing();
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/no-watch-file-in-native.t b/t/scripts/harness/no-watch-file-in-native.t
new file mode 100644
index 0000000..9df968b
--- /dev/null
+++ b/t/scripts/harness/no-watch-file-in-native.t
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2018 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA
+
+use strict;
+use warnings;
+
+BEGIN { $ENV{'LINTIAN_BASE'} //= q{.}; }
+
+use File::Basename qw(basename);
+use File::Temp;
+use File::stat;
+use List::Util qw(max);
+use Test::More;
+
+use lib "$ENV{'LINTIAN_BASE'}/lib";
+use Test::Lintian::Prepare qw(prepare);
+
+# dummy test name; used in desc and directory name
+my $TESTNAME = 'test-of-templates-for-native-package';
+
+# temporary work directory
+my $tempdir = Path::Tiny->tempdir();
+
+# specification path
+my $specpath = $tempdir->child('spec')->child($TESTNAME);
+$specpath->mkpath;
+
+# test description
+my $desctext =<<"EOSTR";
+Testname: $TESTNAME
+Version: 1
+Skeleton: upload-native
+EOSTR
+
+my $descpath = $specpath->child('fill-values');
+$descpath->spew($desctext);
+
+my $runpath = $tempdir->child('run')->child($TESTNAME);
+$runpath->mkpath;
+
+prepare($specpath->stringify, $runpath->stringify, 't');
+
+# test plan
+plan tests => 1;
+
+ok(!-e $runpath->child('debian')->child('watch')->stringify,
+ 'No watch file present');
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/prepare.t b/t/scripts/harness/prepare.t
new file mode 100644
index 0000000..90fcb39
--- /dev/null
+++ b/t/scripts/harness/prepare.t
@@ -0,0 +1,159 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2018 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA
+
+use strict;
+use warnings;
+
+BEGIN { $ENV{'LINTIAN_BASE'} //= q{.}; }
+
+use File::Basename qw(basename);
+use File::Temp;
+use File::stat;
+use IPC::Run3;
+use List::Util qw(max);
+use Test::More;
+
+use lib "$ENV{'LINTIAN_BASE'}/lib";
+use Test::Lintian::Prepare qw(prepare);
+use Test::Lintian::ConfigFile qw(read_config);
+use Test::Lintian::Helper qw(rfc822date);
+
+# dummy test name; used in desc and directory name
+my $TESTNAME = 'shared-libs-non-pic-i386';
+
+# temporary work directory
+my $tempdir = Path::Tiny->tempdir();
+
+# specification path
+my $specpath = $tempdir->child('spec')->child($TESTNAME);
+$specpath->mkpath;
+
+# test description
+my $desctext =<<"EOSTR";
+Testname: $TESTNAME
+Version: 1.0-2
+Skeleton: upload-native
+Test-Architectures: any-amd64 any-i386
+Package-Architecture: any
+Test-Depends: debhelper (>= 9.20151004~)
+Description: Test checks related to non-pic code
+Test-For: shlib-with-non-pic-code
+Check: shared-libs
+EOSTR
+
+my $descpath = $specpath->child('fill-values');
+$descpath->spew($desctext);
+
+my $runpath = $tempdir->child('run')->child($TESTNAME);
+$runpath->mkpath;
+
+prepare($specpath->stringify, $runpath->stringify, 't');
+
+# read resulting test description
+my $testcase = read_config($runpath->child('fill-values')->stringify);
+
+my @testarches = $testcase->trimmed_list('Test-Architectures');
+
+# test plan
+plan tests => 20 + scalar @testarches;
+
+is($testcase->unfolded_value('Testname'), $TESTNAME, 'Correct name');
+
+is($testcase->unfolded_value('Version'), '1.0-2', 'Correct version');
+is($testcase->unfolded_value('Upstream-Version'),
+ '1.0', 'Correct upstream version');
+
+is(
+ $testcase->unfolded_value('Test-Architectures'),
+ 'any-amd64 any-i386',
+ 'Correct test architectures'
+);
+isnt($testcase->unfolded_value('Test-Architectures'),
+ 'any', 'Correct test architectures');
+for my $testarch (@testarches) {
+ my @command
+ = (qw{dpkg-architecture --list-known --match-wildcard}, $testarch);
+ my $output;
+
+ run3(\@command, \undef, \$output);
+ my @known = grep { length } split(/\n/, $output);
+
+ cmp_ok(scalar @known, '>', 1, "Known test architecture $testarch");
+}
+
+is($testcase->unfolded_value('Host-Architecture'),
+ $ENV{'DEB_HOST_ARCH'}, 'Correct host architecture');
+isnt(
+ $testcase->unfolded_value('Host-Architecture'),
+ $testcase->unfolded_value('Test-Architectures'),
+ 'Test and host architectures are different'
+);
+
+is($testcase->unfolded_value('Package-Architecture'),
+ 'any', 'Changed package architecture');
+isnt($testcase->unfolded_value('Package-Architecture'),
+ 'all', 'Not the default package architecture');
+
+is($testcase->unfolded_value('Skeleton'), 'upload-native', 'Correct skeleton');
+
+is(
+ $testcase->unfolded_value('Test-Depends'),
+ 'debhelper (>= 9.20151004~)',
+ 'Correct test dependencies'
+);
+
+is($testcase->unfolded_value('Test-For'),
+ 'shlib-with-non-pic-code','Correct Test-For');
+ok(!$testcase->declares('Test-Against'), 'Correct Test-Against');
+
+is($testcase->unfolded_value('Standards-Version'),
+ $ENV{'POLICY_VERSION'}, 'Correct policy version');
+
+is($testcase->unfolded_value('Type'), 'native', 'Test is native');
+isnt($testcase->unfolded_value('Type'), 'yes', 'Native type not yes.');
+
+is(
+ $testcase->unfolded_value('Dh-Compat-Level'),
+ $ENV{'DEFAULT_DEBHELPER_COMPAT'},
+ 'Default debhelper compat level'
+);
+
+is(
+ $testcase->unfolded_value('Description'),
+ 'Test checks related to non-pic code',
+ 'Correct description'
+);
+isnt(
+ $testcase->unfolded_value('Description'),
+ 'No Description Available',
+ 'Not default description'
+);
+
+is(
+ $testcase->unfolded_value('Author'),
+ 'Debian Lintian Maintainers <lintian-maint@debian.org>',
+ 'Default author'
+);
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/sort-order.t b/t/scripts/harness/sort-order.t
new file mode 100644
index 0000000..a74375f
--- /dev/null
+++ b/t/scripts/harness/sort-order.t
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2020 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The harness for Lintian's test suite. For detailed information on
+# the test suite layout and naming conventions, see t/tests/README.
+# For more information about running tests, see
+# doc/tutorial/Lintian/Tutorial/TestSuite.pod
+#
+
+use strict;
+use warnings;
+use v5.10;
+
+use File::Basename;
+use File::Find::Rule;
+use Path::Tiny;
+use Test::More;
+
+BEGIN { $ENV{'LINTIAN_BASE'} //= q{.}; }
+use lib "$ENV{'LINTIAN_BASE'}/lib";
+
+use Lintian::Profile;
+use Test::Lintian::ConfigFile qw(read_config);
+
+my $checkpath = 't/recipes/checks';
+
+# find all test specifications related to only one check
+my @descpaths = sort File::Find::Rule->file()->name('desc')->in($checkpath);
+
+# set the testing plan
+plan tests => 3 * scalar @descpaths;
+
+my $profile = Lintian::Profile->new;
+$profile->load(undef, undef, 0);
+
+foreach my $descpath (@descpaths) {
+
+ my $testcase = read_config($descpath);
+ my $name = $testcase->unfolded_value('Testname');
+
+ # get test path
+ my $testpath = path($descpath)->parent->stringify;
+
+ ok($testcase->declares('Check'),
+ "Test specification for $name defines a field Check");
+
+ next
+ unless $testcase->declares('Check');
+
+ my @checks = $testcase->trimmed_list('Check');
+
+ # test is only about one check
+ is(scalar @checks, 1,"Test in $testpath is associate only with one check");
+
+ next unless scalar @checks == 1;
+ my $check = $checks[0];
+
+ # get the relative location of folder containing test
+ my $parent = path($testpath)->parent->parent;
+ my $relative = $parent->relative($checkpath)->stringify;
+
+ # relative location should match check
+ is($relative, $check,
+ "Test in $testpath is located in correct folder ($relative != $check)"
+ );
+}
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/tag-coverage.t b/t/scripts/harness/tag-coverage.t
new file mode 100644
index 0000000..366789a
--- /dev/null
+++ b/t/scripts/harness/tag-coverage.t
@@ -0,0 +1,171 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2019 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# The harness for Lintian's test suite. For detailed information on
+# the test suite layout and naming conventions, see t/tests/README.
+# For more information about running tests, see
+# doc/tutorial/Lintian/Tutorial/TestSuite.pod
+#
+
+use strict;
+use warnings;
+use v5.10;
+
+use Const::Fast;
+use File::Basename;
+use File::Find::Rule;
+use List::Compare;
+use List::SomeUtils qw(uniq);
+use Path::Tiny;
+use Test::More;
+
+use lib ($ENV{'LINTIAN_BASE'} // q{.}) . '/lib';
+
+use Lintian::Profile;
+use Test::Lintian::ConfigFile qw(read_config);
+use Test::Lintian::Output::EWI qw(to_universal);
+use Test::Lintian::Output::Universal qw(tag_name);
+
+const my $SPACE => q{ };
+const my $NEWLINE => qq{\n};
+
+my @known_missing = (
+ qw(
+ changed-by-invalid-for-derivative
+ debian-files-list-in-source
+ debian-rules-missing-recommended-target
+ debian-rules-not-executable
+ elf-warning
+ embedded-pear-module
+ invalid-field-for-derivative
+ invalid-version-number-for-derivative
+ manual-page-in-udeb
+ no-tests
+ old-python-version-field
+ old-source-override-location
+ patch-modifying-debian-files
+ patch-system-but-direct-changes-in-diff
+ quilt-series-references-non-existent-patch
+ source-contains-quilt-control-dir
+ sphinxdoc-but-no-sphinxdoc-depends
+ unpack-message-for-deb-control
+ unpack-message-for-orig
+ uses-deprecated-adttmp
+ ),
+
+# the following tags are not testable due to restrictions in reprotest
+# building the tests causes regressions due to an unknown problem, maybe in docker
+# possibly related to https://github.com/yarnpkg/yarn/pull/1837
+# their functionality is probably better tested in piuparts
+ qw(
+ wrong-file-owner-uid-or-gid
+ bad-owner-for-doc-file
+ non-standard-game-executable-perm
+ rules-silently-require-root
+ )
+);
+
+my $profile = Lintian::Profile->new;
+$profile->load(undef, undef, 0);
+
+# find known checks
+my @known = uniq $profile->known_checks;
+
+my %checktags;
+$checktags{$_} = $profile->tag_names_for_check->{$_}for @known;
+
+my %seen;
+
+# require tags tested in their check; otherwise path could be t/recipes
+my @descpaths = File::Find::Rule->file()->name('desc')->in('t/recipes/checks');
+for my $descpath (@descpaths) {
+
+ my $testcase = read_config($descpath);
+
+ my $testpath = dirname($descpath);
+ my $hintspath = "$testpath/hints";
+
+ next unless -r $hintspath;
+
+ my $universal = path($hintspath)->slurp_utf8;
+
+ print "testcase->{testname}\n";
+ my @lines = split(/$NEWLINE/, $universal);
+ my @testfor = uniq map { tag_name($_) } @lines;
+
+ # diag "Test-For: " . join($SPACE, @testfor);
+
+ if (exists $testcase->{check}) {
+ my @checks = split($SPACE, $testcase->{check});
+ # diag "Checks: " . join($SPACE, @checks);
+ my @related;
+ push(@related, @{$checktags{$_} // []})for @checks;
+ my $lc = List::Compare->new(\@testfor, \@related);
+ @testfor = $lc->get_intersection;
+ }
+
+ $seen{$_} = 1 for @testfor;
+}
+
+# find known tags
+my @wanted = uniq $profile->known_tags;
+my $total = scalar @wanted;
+
+# set the testing plan
+plan tests => scalar @wanted + 2;
+
+for my $name (@wanted) {
+ TODO: {
+ local $TODO = "Tag $name is currently untested"
+ unless exists $seen{$name};
+
+ ok(exists $seen{$name}, "Tag $name appears in tests");
+ }
+}
+
+my @tested = keys %seen;
+
+my $comp = List::Compare->new(\@wanted, \@tested);
+my @missing = $comp->get_Lonly;
+my @extra = $comp->get_Ronly;
+
+my $found = scalar @tested;
+diag 'Missing '
+ . scalar @missing
+ . " out of $total tags for complete test coverage.";
+
+diag "Untested tag: $_" for @missing;
+#diag "Extra: $_" for @extra;
+
+my $exceptions = List::Compare->new(\@missing, \@known_missing);
+my @unknown = $exceptions->get_Lonly;
+my @solved = $exceptions->get_Ronly;
+
+is(scalar @unknown, 0, 'All tags are covered in the testsuite');
+diag "Unknown/missing tag: $_" for @unknown;
+
+is(scalar @solved, 0, 'Solved tags should be removed from known missing set');
+diag "Solved tag: $_" for @solved;
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/t/scripts/harness/watch-file-in-non-native.t b/t/scripts/harness/watch-file-in-non-native.t
new file mode 100644
index 0000000..5bea873
--- /dev/null
+++ b/t/scripts/harness/watch-file-in-non-native.t
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+
+# Copyright (C) 2018 Felix Lechner
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program. If not, you can find it on the World Wide
+# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA
+
+use strict;
+use warnings;
+
+BEGIN { $ENV{'LINTIAN_BASE'} //= q{.}; }
+
+use File::Basename qw(basename);
+use File::Temp;
+use File::stat;
+use List::Util qw(max);
+use Test::More;
+
+use lib "$ENV{'LINTIAN_BASE'}/lib";
+use Test::Lintian::Prepare qw(prepare);
+
+# dummy test name; used in desc and directory name
+my $TESTNAME = 'test-of-templates-for-native-package';
+
+# temporary work directory
+my $tempdir = Path::Tiny->tempdir();
+
+# specification path
+my $specpath = $tempdir->child('spec')->child($TESTNAME);
+$specpath->mkpath;
+
+# test description
+my $desctext =<<"EOSTR";
+Testname: $TESTNAME
+Version: 1-1
+Skeleton: upload-non-native
+EOSTR
+
+my $descpath = $specpath->child('fill-values');
+$descpath->spew($desctext);
+
+my $runpath = $tempdir->child('run')->child($TESTNAME);
+$runpath->mkpath;
+
+prepare($specpath->stringify, $runpath->stringify, 't');
+
+# test plan
+plan tests => 1;
+
+ok(-e $runpath->child('debian')->child('watch')->stringify,
+ 'Watch file present');
+
+# Local Variables:
+# indent-tabs-mode: nil
+# cperl-indent-level: 4
+# End:
+# vim: syntax=perl sw=4 sts=4 sr et