Control: tags -1 patch
On 2013-05-26 22:39, Ansgar Burchardt wrote:
> Package: lintian
> Version: 2.5.10.5
> Severity: wishlist
>
> It would be nice if lintian had an option to exit with a status != 0
> only if there are internal errors.
>
> Currently it exits with "1" if policy violations of major errors are
> detected. sudo does the same (exit status 1) when running a command is
> not allowed which makes catching unexpected errors harder.
>
> Ansgar
>
>
Hi,
I have made a patch for this, which introduces --[no-]fail-on-errors and
--no-fail-on-warnings. My only concern is that I don't like the name of
the option (because "error" can be read as "error (E) tag" or "run-time
error" or even both).
So I am wondering if we should rename these options to
"fail-on-X-tags" (e.g. "fail-on-error-tags").
Alternatively, we can also go for a "--[no-]fail-on-tag-code=X[,Y,...]"
(with --fail-on-warnings => --fail-on-tag-code="W").
~Niels
>From 95d873dfe0f3af226b427be1874d81c3b9d91959 Mon Sep 17 00:00:00 2001
From: Niels Thykier
Date: Sun, 23 Jun 2013 09:58:14 +0200
Subject: [PATCH] lintian: Add --[no-]fail-on-errors and --no-fail-on-warnings
Add 3 new command line options. The --no-fail-on-errors can be used
used to disable the "exit 1 with error tags". The other 2 are mostly
useful as a means to override options set in a config file.
Signed-off-by: Niels Thykier
---
debian/changelog | 6 ++++++
frontend/lintian | 15 ++++++++++++---
man/lintian.pod.in | 18 ++++++++++++++++--
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index b020d77..53184e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -42,6 +42,12 @@ lintian (2.5.14) UNRELEASED; urgency=low
+ [NT] Add plackup (libplack-perl) as a known interpreter. Thanks
to Robert James Clay for the report. (Closes: #712405)
+ * frontend/lintian:
+ + [NT] Add --[no-]fail-on-errors and --no-fail-on-warnings options.
+ Using these, it is possible to disable the "exit 1" for error
+ tags. Thanks to Ansgar Burchardt for the suggestion.
+ (Closes: #709932)
+
* lib/Lintian/CheckScript.pm:
+ [NT] Prefer loading checks with ".pm", but fall back to loading
checks without the extension (with a deprecation warning).
diff --git a/frontend/lintian b/frontend/lintian
index 26053e3..3466e7c 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -182,7 +182,8 @@ Behaviour options:
--display-source X restrict displayed tags by source
-E, --display-experimental display "X:" tags (normally suppressed)
--no-display-experimental suppress "X:" tags
- --fail-on-warnings return a non-zero exit status if warnings found
+ --[no-]fail-on-errors return a non-zero exit status if errors (E) found
+ --[no-]fail-on-warnings return a non-zero exit status if warnings (W) found
-i, --info give detailed info about tags
-I, --display-info display "I:" tags (normally suppressed)
--keep-lab keep lab after run, even if temporary
@@ -493,7 +494,8 @@ my %opthash = ( # ------------------ actions
'color=s' => \$opt{'color'},
'unpack-info|U=s' => \@unpack_info,
'allow-root' => \$allow_root,
- 'fail-on-warnings' => \$opt{'fail-on-warnings'},
+ 'fail-on-errors!' => \$opt{'fail-on-errors'},
+ 'fail-on-warnings!' => \$opt{'fail-on-warnings'},
'keep-lab' => \$keep_lab,
# ------------------ configuration options
@@ -525,6 +527,7 @@ my %cfghash = (
'display-experimental' => \$opt{'display-experimental'},
'display-info' => \&cfg_display_level,
'display-level' => \&cfg_display_level,
+ 'fail-on-errors' => \$opt{'fail-on-errors'},
'fail-on-warnings' => \$opt{'fail-on-warnings'},
'info' => \$opt{'info'},
'jobs' => \$opt{'jobs'},
@@ -771,6 +774,9 @@ if ($opt{'LINTIAN_CFG'}) {
close($fd);
}
+# Default is fail-on-errors
+$opt{'fail-on-errors'} = 1 unless defined($opt{'fail-on-errors'});
+
# check permitted values for --color / color
# - We set the default to 'never' here; because we cannot do
# it before the config check.
@@ -1382,7 +1388,7 @@ sub process_group {
unless ($exit_code) {
my $stats = $TAGS->statistics ($lpkg);
- if ($stats->{types}{E}) {
+ if ($opt{'fail-on-errors'} && $stats->{types}{E}) {
$exit_code = 1;
} elsif ($opt{'fail-on-warnings'} && $stats->{types}{W}) {
$exit_code = 1;
@@ -1717,6 +1723,9 @@ sub END {
if ($? != 1 || $exit_code != 1) {
$? = 2;
}
+ # It is definitely an "exit 2" error if --no-fail-on-errors
+ # and --no-fail-on-warnings are both in effect.
+ $? = 2 if not $opt{'fail-on-errors'} and not $opt{'fail-on-warnings'};
}
if (1) {
diff --git a/man/lintian.pod.in b/man/lintian.pod.in
index 2eaeae6..92abf96 100644
--- a/man/lintian.pod.in
+++ b/man/lintian.pod.in
@@ -237,7 +237,20 @@ bug reports are always welcomed (particularly if they include fixes).
These options overrides the B variable in the
configuration file.
-=item B<--fail-on-warnings>
+=item B<--fail-on-errors>, B<--no-fail-on-errors>
+
+By default, B exits with 1 if any error tag (E) is emitted.
+With B<--no-fail-on-errors> in effect, error tags will no longer cause
+an exit of 1.
+
+Note that is option only applies to "error" (E) tags and not run-time
+errors in B itself. The latter is not affected by these
+options and will have Lintian exit 2.
+
+This option overrides the B variable in the
+configuration file.
+
+=item B<--fail-on-warnings>, B<--no-fail-on-warnings>
By default, B exits with 0 status if only warnings were
found. If this flag is given, exit with a status of 1 if either
@@ -702,7 +715,8 @@ No policy violations or major errors detected.
=item B<1>
-Policy violations or major errors detected.
+Policy violations or major errors detected. Can be disabled with
+B<--no-fail-on-errors> (and B<--no-fail-on-warnings>).
=item B<2>
--
1.7.10.4