3 use Capture::Tiny 'capture';
4 use File::Spec::Functions 'catfile';
7 my $HAVE_SIMPLECONFIG = eval {
8 require MooseX::SimpleConfig;
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");
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);
24 if ($test eq 'version_with_simpleconfig.pl' && !$HAVE_SIMPLECONFIG) {
25 skip('MooseX::SimpleConfig unavailable', 3);
28 my ($v, undef) = capture { system $^X, $script, '-v' };
29 like($v, qr/^SUCCESS/, "Option -v is correct");
31 my ($version, undef) = capture { system $^X, $script, '--version' };
32 like($version, qr/^SUCCESS/, "Option --version is correct");
34 my (undef, $V) = capture { system $^X, $script, '-V' };
35 like($V, qr/^Unknown option/, "Option -V is unknown");