From 6891cb74684f2776cab22300360a1fab62fd2100 Mon Sep 17 00:00:00 2001 From: Michael Samoglyadov Date: Mon, 18 Jun 2018 10:09:42 +0300 Subject: [PATCH] use abs path for $0 (fix tests with Pod::Usage) --- Makefile.PL | 1 + lib/App/NDTools/Test.pm | 7 +++++++ t/lib/NDTools-NDTool.t | 2 -- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 791cc36..441bfbb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -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, diff --git a/lib/App/NDTools/Test.pm b/lib/App/NDTools/Test.pm index b261790..83955c3 100644 --- a/lib/App/NDTools/Test.pm +++ b/lib/App/NDTools/Test.pm @@ -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 diff --git a/t/lib/NDTools-NDTool.t b/t/lib/NDTools-NDTool.t index cf6928d..98c1339 100644 --- a/t/lib/NDTools-NDTool.t +++ b/t/lib/NDTools-NDTool.t @@ -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");