@@ -19,9 +19,10 @@ or to check whether specific tests can pass under Test2::Aggregate.
19
19
Options:
20
20
--out <s>, -o <s> : Specify the test file to be created (tmp file by default).
21
21
--lists, -l : Use files specified as lists.
22
- --prove, -p : Force prove (default is yath/Test2 if detected ).
22
+ --prove, -p : Force prove (default is yath/Test2 if installed ).
23
23
--verbose, -v : Verbose (passed to yath/prove)
24
- --absolute, -a : Use absolute paths in generated files.
24
+ --absolute, -a : Use absolute paths in generated files. Disabled with -r.
25
+ --root <s> -r <s> : Define a custom root dir (default is current dir).
25
26
--include <s>, -I <s> : Library paths to include.
26
27
--test_warnings, -w : Fail tests on warnings.
27
28
--test_bundle <s>, -t : Test bundle (def: Test2::V0 or Test::More if -p). Can be comma-separated list.
@@ -39,6 +40,7 @@ use warnings;
39
40
40
41
use lib 'lib';
41
42
43
+ use Carp;
42
44
use Cwd;
43
45
use File::Temp 'tempfile';
44
46
use Getopt::Long;
@@ -48,13 +50,15 @@ use Pod::Usage;
48
50
my %opt = (framework => 'Test2::V0');
49
51
GetOptions(
50
52
\%opt,
53
+ 'absolute|a',
51
54
'help|h',
52
55
'include|I=s',
53
- 'out|o=s',
54
56
'lists|l',
57
+ 'out|o=s',
55
58
'pass_output|po=s',
56
59
'prove|p',
57
60
'reverse',
61
+ 'root|r=s',
58
62
'shuffle',
59
63
'sort',
60
64
'stats_output|so=s',
@@ -69,6 +73,18 @@ pod2usage({-verbose => 1, -output => \*STDOUT, -noperldoc => 1})
69
73
$opt{test_bundle} ||= $opt{prove} ? 'Test::More' : 'Test2::V0';
70
74
$opt{stats_output} = $opt{pass_output} if $opt{pass_output};
71
75
76
+ if ($opt{root}) {
77
+ $opt{absolute} = undef;
78
+ croak "Specified --root does not exist" unless -e $opt{root};
79
+ my $slash = '';
80
+ $slash = '/' unless $opt{root} =~ m#/$#;
81
+ foreach (@ARGV) {
82
+ croak "$opt{root}$slash$_ doesn't exist" unless -e "$opt{root}$slash$_";
83
+ }
84
+ } elsif (!$opt{absolute}) {
85
+ $opt{root} = "./";
86
+ }
87
+
72
88
unless ($opt{prove}) {
73
89
eval "use Test2::Harness";
74
90
$opt{prove} = 1 if $@;
@@ -82,7 +98,7 @@ my $file = $opt{out} ? path($opt{out}) : Path::Tiny->tempfile(
82
98
83
99
print "Writing output to $file\n" if $opt{verbose};
84
100
85
- my $cwd = getcwd();
101
+ my $cwd = $opt{root} || getcwd();
86
102
my $code = test_bundle_use($opt{test_bundle});
87
103
88
104
$code .= "
0 commit comments