summaryrefslogtreecommitdiffstats
path: root/t/scripts/01-critic
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:42:30 +0000
commit75808db17caf8b960b351e3408e74142f4c85aac (patch)
tree7989e9c09a4240248bf4658a22208a0a52d991c4 /t/scripts/01-critic
parentInitial commit. (diff)
downloadlintian-75808db17caf8b960b351e3408e74142f4c85aac.tar.xz
lintian-75808db17caf8b960b351e3408e74142f4c85aac.zip
Adding upstream version 2.117.0.upstream/2.117.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/scripts/01-critic')
l---------t/scripts/01-critic/bin.t1
l---------t/scripts/01-critic/lib.t1
l---------t/scripts/01-critic/private.t1
-rwxr-xr-xt/scripts/01-critic/runner.pl83
l---------t/scripts/01-critic/test-scripts.t1
5 files changed, 87 insertions, 0 deletions
diff --git a/t/scripts/01-critic/bin.t b/t/scripts/01-critic/bin.t
new file mode 120000
index 0000000..c316f2d
--- /dev/null
+++ b/t/scripts/01-critic/bin.t
@@ -0,0 +1 @@
+runner.pl \ No newline at end of file
diff --git a/t/scripts/01-critic/lib.t b/t/scripts/01-critic/lib.t
new file mode 120000
index 0000000..c316f2d
--- /dev/null
+++ b/t/scripts/01-critic/lib.t
@@ -0,0 +1 @@
+runner.pl \ No newline at end of file
diff --git a/t/scripts/01-critic/private.t b/t/scripts/01-critic/private.t
new file mode 120000
index 0000000..c316f2d
--- /dev/null
+++ b/t/scripts/01-critic/private.t
@@ -0,0 +1 @@
+runner.pl \ No newline at end of file
diff --git a/t/scripts/01-critic/runner.pl b/t/scripts/01-critic/runner.pl
new file mode 100755
index 0000000..27f7b83
--- /dev/null
+++ b/t/scripts/01-critic/runner.pl
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+
+# Simple critic test runner that guesses it task from $0.
+# NB: If you change anything in this script, consider if
+# others.t need an update as well.
+
+use strict;
+use warnings;
+
+use Const::Fast;
+use IPC::Run3;
+use POSIX qw(ENOENT);
+
+use
+ if $ENV{'LINTIAN_COVERAGE'}, 'Test::More',
+ 'skip_all' => 'Not needed for coverage of Lintian';
+
+use Test::Lintian;
+use Test::More;
+
+plan skip_all => 'Only UNRELEASED versions are criticised'
+ if should_skip();
+
+eval 'use Test::Perl::Critic 1.00';
+plan skip_all => 'Test::Perl::Critic 1.00 required to run this test' if $@;
+
+eval 'use Perl::Tidy 20181120';
+# Actually we could just disable the perltidy check, but I am not
+# sure how to do that without making it ignore our perlcriticrc file.
+plan skip_all => 'Perl::Tidy 20180220 required to run this test' if $@;
+
+eval 'use PPIx::Regexp';
+diag('libppix-regexp-perl is needed to enable some checks') if $@;
+
+const my $DOT => q{.};
+
+my @test_paths = program_name_to_perl_paths($0);
+$ENV{'LINTIAN_BASE'} //= $DOT;
+my $critic_profile = "$ENV{'LINTIAN_BASE'}/.perlcriticrc";
+Test::Perl::Critic->import(-profile => $critic_profile);
+
+run_critic(@test_paths);
+
+exit(0);
+
+sub run_critic {
+ my (@args) = @_;
+
+ all_critic_ok(@args);
+
+ # For some reason, perltidy has started to leave behind a
+ # "perltidy.LOG" which is rather annoying. Lets have the tests
+ # unconditionally kill those.
+ my $err = unlink('perltidy.LOG');
+ if ($err) {
+ # Since this test is run in parallel, there is an
+ # race-condition between checking for the file and actually
+ # deleting. So just remove the file and ignore ENOENT
+ # problems.
+ die($err) if $err->errno != ENOENT;
+ }
+ return 1;
+}
+
+sub should_skip {
+ my $skip = 1;
+
+ my @command = qw{dpkg-parsechangelog -c0};
+ my $output;
+
+ run3(\@command, \undef, \$output);
+
+ $skip = 0
+ if $output =~ /^Distribution: UNRELEASED$/m;
+
+ return $skip;
+}
+
+# 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/01-critic/test-scripts.t b/t/scripts/01-critic/test-scripts.t
new file mode 120000
index 0000000..c316f2d
--- /dev/null
+++ b/t/scripts/01-critic/test-scripts.t
@@ -0,0 +1 @@
+runner.pl \ No newline at end of file