Skip to content

Commit

Permalink
use abs path for $0 (fix tests with Pod::Usage)
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-mixas committed Jun 18, 2018
1 parent 4e9dc14 commit 6891cb7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -17,6 +17,7 @@ WriteMakefile(
},
BUILD_REQUIRES => {
'Capture::Tiny' => 0,
'Cwd' => 0,
'Data::Dumper' => 0,
'JSON::PP' => 0, # required by YAML::XS
'Test::File::Contents' => 0.23,
Expand Down
7 changes: 7 additions & 0 deletions lib/App/NDTools/Test.pm
Expand Up @@ -5,10 +5,17 @@ use warnings FATAL => 'all';
use parent qw(Exporter);

use Capture::Tiny qw(capture);
use Cwd qw(abs_path);
use Data::Dumper;
use Scalar::Util qw(blessed);
use Test::More;

BEGIN {
# relative path will be incorrect when `cd t_dir` used
# required by Pod::Usage
$0 = abs_path($0);
}

our @EXPORT = qw(
run_ok
t_ab_cmp
Expand Down
2 changes: 0 additions & 2 deletions t/lib/NDTools-NDTool.t
Expand Up @@ -57,8 +57,6 @@ like($err, qr/Usage/, "STDERR should contain usage");
is($out, '', "STDOUT for usage method must be empty");
file_contents_eq_or_diff('usage.exp', $err, "Usage text should go to STDERR");

diag ">>>> $0";

($out, $err) = capture { eval { App::NDTools::NDTool->new('--version') }};
like($out, qr/\d+\.\d+/, "STDOUT for usage method must be empty");
is($err, '', "STDERR for version should be empty");
Expand Down

0 comments on commit 6891cb7

Please sign in to comment.