dpkg-realpath: Rewrite in C
[dpkg/guillem.git] / t / shellcheck.t
blob046bbb3eb3857aa208a51dcfcb1ee3f3112ad0d0
1 #!/usr/bin/perl
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 use strict;
17 use warnings;
19 use Test::More;
20 use Test::Dpkg qw(:needs);
22 test_needs_author();
23 test_needs_command('shellcheck');
24 test_needs_srcdir_switch();
26 my @todofiles = qw(
27 dselect/methods/disk/install.sh
28 dselect/methods/disk/setup.sh
29 dselect/methods/disk/update.sh
30 dselect/methods/media/install.sh
31 dselect/methods/media/setup.sh
32 dselect/methods/media/update.sh
34 my @files = qw(
35 autogen
36 build-aux/gen-release
37 build-aux/get-vcs-id
38 build-aux/get-version
39 build-aux/run-script
40 debian/dpkg.cron.daily
41 debian/dpkg.postrm
42 src/dpkg-db-backup.sh
43 src/dpkg-db-keeper.sh
44 src/dpkg-maintscript-helper.sh
46 my @shellcheck_opts = (
47 '--external-sources', # Allow checking external source files.
48 '--exclude=SC1090', # Allow non-constant source.
49 '--exclude=SC2039', # Allow local keyword.
50 '--exclude=SC2166', # Allow -a and -o.
51 '--exclude=SC2034', # Allow unused variables for colors.
52 '--exclude=SC3043', # Allow local keyword.
55 plan tests => scalar @files;
57 sub shell_syntax_ok
59 my $file = shift;
61 my $tags = qx(shellcheck @shellcheck_opts $file 2>&1);
63 # Fixup the output:
64 chomp $tags;
66 my $ok = length $tags == 0;
68 ok($ok, 'shellcheck');
69 if (not $ok) {
70 diag($tags);
74 foreach my $file (@files) {
75 shell_syntax_ok($file);