our
$VERSION
=
'0.001063'
;
-run_id
-finite
-job_count
-switches
-libs -lib -blib -tlib
-preload
-load -load_import
-args
-input
-verbose
-dummy
-cover
-event_uuids
-mem_usage
-search
-unsafe_inc
-env_vars
-use_stream
-use_fork
-use_timeout
-times
-show_times
-exclude_files
-exclude_patterns
-no_long
-plugins
}
;
sub
init {
my
$self
=
shift
;
croak
"preload is not supported on windows"
if
IS_WIN32 &&
$self
->{+PRELOAD};
croak
"The 'run_id' attribute is required"
unless
$self
->{+RUN_ID};
$self
->{+SEARCH} ||= [
't'
];
$self
->{+PRELOAD} ||=
undef
;
$self
->{+SWITCHES} ||= [];
$self
->{+ARGS} ||= [];
$self
->{+LIBS} ||= [];
$self
->{+LIB} ||= 0;
$self
->{+BLIB} ||= 0;
$self
->{+JOB_COUNT} ||= 1;
$self
->{+INPUT} ||=
undef
;
$self
->{+UNSAFE_INC} = 1
unless
defined
$self
->{+UNSAFE_INC};
$self
->{+USE_STREAM} = 1
unless
defined
$self
->{+USE_STREAM};
$self
->{+USE_FORK} = (IS_WIN32 ? 0 : 1)
unless
defined
$self
->{+USE_FORK};
croak
"Preload requires forking"
if
$self
->{+PRELOAD} && !
$self
->{+USE_FORK};
my
$env
=
$self
->{+ENV_VARS} ||= {};
$env
->{PERL_USE_UNSAFE_INC} =
$self
->{+UNSAFE_INC}
unless
defined
$env
->{PERL_USE_UNSAFE_INC};
$env
->{HARNESS_ACTIVE} = 1;
$env
->{T2_HARNESS_ACTIVE} = 1;
$env
->{HARNESS_VERSION} =
"Test2-Harness-$VERSION"
;
$env
->{T2_HARNESS_VERSION} =
$VERSION
;
$env
->{T2_HARNESS_JOBS} =
$self
->{+JOB_COUNT};
$env
->{HARNESS_JOBS} =
$self
->{+JOB_COUNT};
$env
->{T2_HARNESS_RUN_ID} =
$self
->{+RUN_ID};
}
sub
all_libs {
my
$self
=
shift
;
my
$libs
=
$self
->{+LIBS} or
return
;
return
@$libs
;
}
sub
TO_JSON {
return
{ %{
$_
[0]} } }
sub
find_files {
my
$self
=
shift
;
my
$plugins
=
$self
->{+PLUGINS} || [];
my
$search
=
$self
->search;
my
(
@files
,
@dirs
);
for
my
$item
(
@$search
) {
my
$claimed
;
for
my
$plugin
(
@$plugins
) {
my
$file
=
$plugin
->claim_file(
$item
) or
next
;
push
@files
=>
$file
;
$claimed
= 1;
last
;
}
next
if
$claimed
;
push
@files
=> Test2::Harness::Util::TestFile->new(
file
=>
$item
) and
next
if
-f
$item
;
push
@dirs
=>
$item
and
next
if
-d
$item
;
die
"'$item' does not appear to be either a file or a directory.\n"
;
}
if
(
@dirs
) {
File::Find::find(
{
no_chdir
=> 1,
wanted
=>
sub
{
no
warnings
'once'
;
return
unless
-f
$_
&& m/\.t2?$/;
push
@files
=> Test2::Harness::Util::TestFile->new(
file
=>
$File::Find::name
,
);
},
},
@dirs
);
}
push
@files
=>
$_
->find_files(
$self
)
for
@$plugins
;
if
(
$self
->{+JOB_COUNT} > 1 || !
$self
->{+FINITE}) {
@files
=
sort
{
$a
->rank <=>
$b
->rank ||
$a
->file cmp
$b
->file }
@files
;
}
else
{
@files
=
sort
{
$a
->file cmp
$b
->file }
@files
;
}
@files
=
grep
{ !
$self
->{+EXCLUDE_FILES}->{
$_
->file} }
@files
if
keys
%{
$self
->{+EXCLUDE_FILES}};
@files
=
grep
{
my
$f
=
$_
->file; !first {
$f
=~ m/
$_
/ } @{
$self
->{+EXCLUDE_PATTERNS}} }
@files
if
@{
$self
->{+EXCLUDE_PATTERNS}};
@files
=
grep
{
$_
->check_category ne
'long'
}
@files
if
$self
->{+NO_LONG};
return
@files
;
}
1;