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