Commit | Line | Data |
da43301a |
1 | use strict; |
2 | use warnings; |
da43301a |
3 | use File::Spec::Functions 'catfile'; |
4 | use Test::More; |
5 | |
6ec744a2 |
6 | BEGIN { |
7 | eval "use Capture::Tiny 'capture'"; |
8 | plan skip_all => "Capture::Tiny unavailable" if $@; |
9 | } |
10 | |
da43301a |
11 | my $HAVE_SIMPLECONFIG = eval { |
12 | require MooseX::SimpleConfig; |
13 | return 1; |
14 | }; |
15 | |
16 | # none of the options should be known |
17 | for my $opt (qw(-v --version -V)) { |
18 | my $script = catfile('t', 'version_no_options.pl'); |
19 | my (undef, $stderr) = capture { system $^X, $script, $opt }; |
20 | like($stderr, qr/^Unknown option/, "Option $opt is unknown"); |
21 | } |
22 | |
23 | # only -V should be unknown, the other two should return our custom string |
24 | for my $test (qw(version_with_options.pl version_with_simpleconfig.pl)) { |
25 | my $script = catfile('t', $test); |
26 | |
c68764d4 |
27 | SKIP: { |
28 | if ($test eq 'version_with_simpleconfig.pl' && !$HAVE_SIMPLECONFIG) { |
29 | skip('MooseX::SimpleConfig unavailable', 3); |
30 | } |
da43301a |
31 | |
c68764d4 |
32 | my ($v, undef) = capture { system $^X, $script, '-v' }; |
33 | like($v, qr/^SUCCESS/, "Option -v is correct"); |
da43301a |
34 | |
c68764d4 |
35 | my ($version, undef) = capture { system $^X, $script, '--version' }; |
36 | like($version, qr/^SUCCESS/, "Option --version is correct"); |
da43301a |
37 | |
c68764d4 |
38 | my (undef, $V) = capture { system $^X, $script, '-V' }; |
39 | like($V, qr/^Unknown option/, "Option -V is unknown"); |
40 | } |
da43301a |
41 | } |
42 | |
43 | done_testing(); |