Bump version to 2.4.2 for development of next release
[gnu-stow.git] / t / cli.t
blob3bd31945382e150b85bdaca49e4db7b97028cbf5
1 #!/usr/bin/perl
3 # This file is part of GNU Stow.
5 # GNU Stow is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # GNU Stow is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see https://www.gnu.org/licenses/.
19 # Test processing of CLI options.
22 use strict;
23 use warnings;
25 use File::Basename;
26 use Test::More tests => 3;
28 use testutil;
30 #init_test_dirs();
32 # Since here we're doing black-box testing on the stow executable,
33 # this looks like it should be robust:
35 #my $STOW = dirname(__FILE__) . '/../bin/stow';
37 # but unfortunately it breaks things like "make distcheck", which
38 # builds the stow script into a separate path like
40 # stow-2.3.0/_build/sub/bin
42 # before cd'ing to something like
44 # stow-2.3.0/_build/sub
46 # and then running the tests via:
48 # make check-TESTS
49 # make[2]: Entering directory '/path/to/stow/src/stow-2.3.0/_build/sub'
50 # dir=../../t; \
51 # /usr/bin/perl -Ibin -Ilib -I../../t -MTest::Harness -e 'runtests(@ARGV)' "${dir#./}"/*.t
53 # So the simplest solution is to hardcode an assumption that we run
54 # tests either from somewhere like this during distcheck:
56 # stow-2.3.0/_build/sub
58 # or from the top of the source tree during development. This can be done
59 # via the following, which also follows the KISS principle:
60 my $STOW = "$^X bin/stow";
62 `$STOW --help`;
63 is($?, 0, "--help should return 0 exit code");
65 my $err = `$STOW --foo 2>&1`;
66 is($? >> 8, 1, "unrecognised option should return 1 exit code");
67 like($err, qr/^Unknown option: foo$/m, "unrecognised option should be listed");
69 # vim:ft=perl