po: Update German scripts translation
[dpkg.git] / t / shellcheck.t
blob6429cb26e02a7f1580ef1f099a0183e55b7bc6d6
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/get-version
37 build-aux/run-script
38 debian/dpkg.cron.daily
39 debian/dpkg.postrm
40 src/dpkg-db-backup.sh
41 src/dpkg-db-keeper.sh
42 src/dpkg-maintscript-helper.sh
43 src/dpkg-realpath.sh
45 my @shellcheck_opts = (
46 '--external-sources', # Allow checking external source files.
47 '--exclude=SC1090', # Allow non-constant source.
48 '--exclude=SC2039', # Allow local keyword.
49 '--exclude=SC2166', # Allow -a and -o.
50 '--exclude=SC2034', # Allow unused variables for colors.
51 '--exclude=SC3043', # Allow local keyword.
54 plan tests => scalar @files;
56 sub shell_syntax_ok
58 my $file = shift;
60 my $tags = qx(shellcheck @shellcheck_opts $file 2>&1);
62 # Fixup the output:
63 chomp $tags;
65 my $ok = length $tags == 0;
67 ok($ok, 'shellcheck');
68 if (not $ok) {
69 diag($tags);
73 foreach my $file (@files) {
74 shell_syntax_ok($file);