ile/;
use App::Yath::Options;
use Test2::Harness::Runner::State;
use Test2::Harness::Util::File::JSON();
use Test2::Harness::Util::Queue();
use parent 'App::Yath::Command';
use Test2::Harness::Util:
ent dir: $!";
for my $file (readdir($dh)) {
next unless $file =~ m{^\.test_info\.\S+\.json$};
$info_file = newest($info_file, "./$file");
}
my $pfile = find_pfile($self->s
nfo_file, $pfile)) {
if ($info_file) {
my $data = Test2::Harness::Util::File::JSON->new(name => $info_file)->read;
return $self->{+STATE} = Test2::Harness::Runner::Stat
arnings;
our $VERSION = '1.000161';
use Time::HiRes qw/sleep/;
use Test2::Harness::Util::File::JSON;
use App::Yath::Util qw/find_pfile/;
use Test2::Harness::Util qw/open_file/;
use parent 'App::Y
the current path.\n";
print "\nFound: $pfile\n";
my $data = Test2::Harness::Util::File::JSON->new(name => $pfile)->read();
print " PID: $data->{pid}\n";
print " Dir: $data->{dir}\n
ject-yath-persist.json. If no project is specified then it will fall back to the current directory. If the current directory is not writable it will default to /tmp/yath-persist.json which limits you
ject-yath-persist.json. If no project is specified then it will fall back to the current directory. If the current directory is not writable it will default to /tmp/yath-persist.json which limits you
o/log.jsonl
=item --cover-from http://example.com/coverage
=item --cover-from path/to/coverage.jsonl
=item --no-cover-from
This can be a test log, a coverage dump (old style json or new jsonl form
json
=item --cover-from-type jsonl
=item --cover-from-type log
=item --no-cover-from-type
File type for coverage source. Usually it can be detected, but when it cannot be you should specify. "json
ict;
use warnings;
our $VERSION = '1.000161';
use File::Spec();
use Test2::Harness::Util::File::JSON;
use App::Yath::Util qw/find_pfile/;
use Test2::Harness::Util qw/open_file/;
use parent 'App::Y
or die "Could not find a persistent yath running.\n";
my $data = Test2::Harness::Util::File::JSON->new(name => $pfile)->read();
my $blacklist = File::Spec->catfile($data->{dir}, 'BLACKLIST')
ject-yath-persist.json. If no project is specified then it will fall back to the current directory. If the current directory is not writable it will default to /tmp/yath-persist.json which limits you
s;
our $VERSION = '1.000161';
use Test2::Util::Table qw/table/;
use Test2::Harness::Util::File::JSONL;
use parent 'App::Yath::Command';
use Test2::Harness::Util::HashBase qw{<log_file};
use App::Y
"Show the failed tests from an event log" }
sub group { 'log' }
sub cli_args { "[--] event_log.jsonl[.gz|.bz2] [job1, job2, ...]" }
sub description {
return <<" EOT";
This yath command will
does not look like a log file" unless $self->{+LOG_FILE} =~ m/\.jsonl(\.(gz|bz2))?$/;
my $stream = Test2::Harness::Util::File::JSONL->new(name => $self->{+LOG_FILE});
my %failed;
while(
RSION = '1.000161';
use Test2::Util::Times qw/render_duration/;
use Test2::Harness::Util::File::JSONL;
use App::Yath::Options;
use parent 'App::Yath::Command';
use Test2::Harness::Util::HashBase q
sub summary { "Get times from a test log" }
sub group { 'log' }
sub cli_args { "[--] event_log.jsonl[.gz|.bz2] [Field1] [Field2]" }
sub description {
return <<" EOT";
This command will cons
E};
die "'$self->{+LOG_FILE}' does not look like a log file" unless $self->{+LOG_FILE} =~ m/\.jsonl(\.(gz|bz2))?$/;
my %seen;
my @fields;
for my $field (@$args, @FIELDS) {
$fi
e;
use Test2::Harness::Util::File::JSON;
use Test2::Harness::IPC;
use Test2::Harness::Runner::State;
use Test2::Harness::Util::JSON qw/encode_json decode_json JSON/;
use Test2::Harness::Util qw/mod2
S_NO_WRITE_TEST_INFO};
my $info_file = "./.test_info.$$.json";
my $workdir = $self->workdir;
Test2::Harness::Util::File::JSON->new(name => $info_file)->write({
workdir => $self
} => sub {
return unless -e $info_file;
return unless Test2::Harness::Util::File::JSON->new(name => $info_file)->read->{workdir} eq $workdir;
unlink($info_file) or die "Could n
til qw/blessed/;
use App::Yath::Util qw/isolate_stdout/;
use Test2::Harness::Util::JSON qw/decode_json encode_json/;
use Test2::Harness::Util qw/mod2file/;
use Test2::Harness::Run;
use parent 'App
$run_id,
action => sub { print $fh defined($_[0]) ? blessed($_[0]) ? $_[0]->as_json . "\n" : encode_json($_[0]) . "\n" : "null\n" },
);
local $SIG{PIPE} = 'IGNORE';
my $ok = eval
ject-yath-persist.json. If no project is specified then it will fall back to the current directory. If the current directory is not writable it will default to /tmp/yath-persist.json which limits you
/parse_exit mod2file/;
use Test2::Util::UUID qw/gen_uuid/;
use Test2::Harness::Util::JSON qw/encode_json decode_json/;
use Plack::Runner;
use DBIx::QuickDB;
use App::Yath::Server::Plack;
use App::Ya
ncode_json({
schema_config => $self->{+SCHEMA_CONFIG},
launcher_options => \@options,
}),
);
}
sub _do_server_post_exec {
my $class = shift;
my ($json) = @
_;
$0 = "yath-web-server";
my $data = decode_json($json);
my $r = Plack::Runner->new;
$r->parse_options(@{$data->{launcher_options}});
my $app = App::Yath::Server::Plack->new(
JSON qw/decode_json encode_json/;
use List::Util qw/first/;
use Cwd qw/getcwd/;
use Carp qw/croak/;
use Time::HiRes qw/time/;
use Text::ParseWords qw/quotewords/;
use Test2::Harness::Util::File::JSON
my @args = (
name => 'durations',
is_json => 1,
http_args => [{headers => {'Content-Type' => 'application/json'}}],
);
if ($primary) {
local $@;
my $is_json = $params{is_json};
if (my $type = ref($in)) {
return $in if $is_json && ($type eq 'HASH' || $type eq 'ARRAY');
}
elsif (-f $in) {
if ($is_json) {
l qw/start_collected_process ipc_connect set_procname/;
use Test2::Harness::Util::JSON qw/decode_json_file encode_json_file/;
use Test2::Util::UUID qw/gen_uuid/;
use Test2::Harness::Util::HashBase qw
_subprocess_run(\$ARGV[0]))", # Run it.
encode_json_file({parent_pid => $$, $self->subprocess_args}), # json data
);
}
sub spawn_process {
my $self = shift;
my %pa
rocess_run {
my $class = shift;
my ($json_file) = @_;
STDOUT->autoflush(1);
STDERR->autoflush(1);
my $params = decode_json_file($json_file);
set_procname(set => ['resource',
ge Test2::Harness::Util::File::JSONL;
use strict;
use warnings;
our $VERSION = '1.000161';
use Carp qw/croak/;
use Test2::Harness::Util::JSON qw/encode_json decode_json/;
use parent 'Test2::Harness
{ shift; decode_json($_[0]) }
sub encode { shift; encode_json(@_) . "\n" }
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Test2::Harness::Util::File::JSONL - Utility class for a JSONL file (stream)
les
encoding/decoding JSONL data.
=head1 SYNOPSIS
use Test2::Harness::Util::File::JSONL;
my $jsonl = Test2::Harness::Util::File::JSONL->new(name => '/path/to/file.jsonl');
while (1) {
est2::Harness::Util qw/clean_path file2mod open_file/;
use Test2::Harness::Util::JSON qw/encode_json encode_pretty_json/;
our $VERSION = '2.000006'; # TRIAL
BEGIN {
local $@;
my $inotify = e
return (0, reason => $err) unless $ok;
return (0, reason => "Got warnings: " . encode_pretty_json(\@warnings)) if @warnings;
return (1);
}
sub find_churn {
my $self = shift;
my ($fil
ts::State;
use strict;
use warnings;
our $VERSION = '1.000161';
use Test2::Harness::Util::File::JSON;
use Scalar::Util qw/weaken/;
use Time::HiRes qw/time/;
use List::Util qw/first min sum0 max/;
us
urn $self->init_state unless -e $self->{+STATE_FILE};
my $file = Test2::Harness::Util::File::JSON->new(name => $self->{+STATE_FILE});
my ($ok, $err);
for (1 .. 5) {
my $state;
umask($self->{+STATE_UMASK});
my $ok = eval {
my $file = Test2::Harness::Util::File::JSON->new(name => $self->{+STATE_FILE});
$file->rewrite($state_copy);
1;
};
my
;
return @{$self->{+SWITCHES_FROM_ENV} = [split /\s+/, $ENV{HARNESS_PERL_SWITCHES}]};
}
my %JSON_SKIP = (
SETTINGS() => 1,
TASK() => 1,
RUNNER() => 1,
> 1,
);
sub TO_JSON {
my $self = shift;
my $out = { %{$self->{+TASK}} };
for my $attr (Test2::Harness::Util::HashBase::attr_list(blessed($self))) {
next if $JSON_SKIP{$attr};
ject-yath-persist.json. If no project is specified then it will fall back to the current directory. If the current directory is not writable it will default to /tmp/yath-persist.json which limits you
o/log.jsonl
=item --cover-from http://example.com/coverage
=item --cover-from path/to/coverage.jsonl
=item --no-cover-from
This can be a test log, a coverage dump (old style json or new jsonl form
json
=item --cover-from-type jsonl
=item --cover-from-type log
=item --no-cover-from-type
File type for coverage source. Usually it can be detected, but when it cannot be you should specify. "json
le qw/dclone/;
use Test2::Harness::Util qw/fqmod mod2file/;
use Test2::Harness::Util::JSON qw/encode_pretty_json/;
BEGIN { require Test2::Harness::Renderer; our @ISA = ('Test2::Harness::Renderer') }
sh @{$f->{info}} => {
tag => 'RUN INFO',
details => encode_pretty_json($run),
};
}
if ($f->{harness_job_launch}) {
my $job = $f->{harness_job};
{$f->{info}} => {
tag => 'JOB INFO',
details => encode_pretty_json($job),
};
}
}
if ($f->{harness_job_end}) {
my $job = $f->{h
arp::croak("Too many arguments for $field()") if @_ > 1;
$this->field($field, @_);
}
sub TO_JSON {
my $self = shift;
return {%$$self};
}
sub build {
my $self = shift;
my ($class
arguments can be provided in C<@args>.
=item $hashref = $prefix->TO_JSON()
This method allows settings to be serialized into JSON.
=back
=head1 SOURCE
The source code repository for Test2-Harness
:JSON qw/decode_json/;
use Test2::Harness::Util qw/maybe_read_file open_file apply_encoding/;
use Test2::Harness::Event;
use Test2::Harness::Util::File::Stream;
use Test2::Harness::Util::File::JSONL
} or next;
while(my $e = shift @$buffer) {
$e = ref($e) ? $e : decode_json($e);
push @{$self->{+_READY_BUFFER}} => $self->_process_events_line($e);
{$pid}->{$tid}} or return;
$seen->{$tid}->{$pid}->{$sid} = 1;
$e = ref($e) ? $e : decode_json($e);
die "Stream error: Events skipped or recieved out of order ($e->{stream_id} != $sid)"
FILE} = Test2::Harness::Util::Queue->new(file => File::Spec->catfile($self->{+WORKDIR}, 'dispatch.jsonl'));
$self->{+RELOAD_STATE} //= {};
$self->poll;
}
sub settings {
my $self = shift
f->{+SETTINGS} //= Test2::Harness::Settings->new(File::Spec->catfile($self->{+WORKDIR}, 'settings.json'));
}
sub run {
my $self = shift;
return $self->{+RUN} if $self->{+RUN};
$self->poll
le = File::Spec->catfile($dir, 'jobs.jsonl');
if (-f $file) {
my $queue = Test2::Harness::Util::Queue->new(file => File::Spec->catfile($dir, 'jobs.jsonl'));
$queue->end;
}
}