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.
26 use Test
::More tests
=> 3;
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:
49 # make[2]: Entering directory '/path/to/stow/src/stow-2.3.0/_build/sub'
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";
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");