cord() sub below. This may be a
# scalar, a hash, an array, etc. It will be serialized to JSON before
# record() sees it.
$state->{record} = $id;
# Pass the resource i
te change for resource classes. Can be a scalar,
hashref, arrayref, etc. It will be serialized to JSON to be passed between
processes.
=back
=head2 RECORD A RESOURCE
Once a resource is assigned, a
te of your resource
instance in the C<< $state->{record} >> hash key. It B<WILL> be serialized to
JSON before being used as an argument to C<record()>.
$state->{record} = $id;
If you do not set
:speedtag;
use strict;
use warnings;
our $VERSION = '1.000161';
use Test2::Harness::Util::File::JSONL;
use App::Yath::Options;
use Cwd qw/getcwd/;
use parent 'App::Yath::Command';
use Test2::Harn
a duration json file, if no path is provided 'duration.json' will be used. The .json extension is added automatically if omitted.",
long_examples => ['', '=/path/to/durations.json'],
ation_action,
);
option pretty => (
description => "Generate a pretty 'durations.json' file when combined with --generate-durations-file. (sorted and multilines)",
default
p::Yath::Util qw/find_pfile/;
use Test2::Harness::Runner::State;
use Test2::Harness::Util::File::JSON();
use Test2::Harness::Util::Queue();
use Test2::Harness::Util qw/open_file/;
use parent 'App::
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
ream = *set_use_stream;
*test_args = *args;
*set_test_args = *set_args;
}
sub TO_JSON { +{%{$_[0]}, class => blessed($_[0])} }
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Test2:
00161';
use Test2::Harness::Util qw/clean_path mod2file/;
use Test2::Harness::Util::JSON qw/decode_json encode_json/;
use List::Util qw/first/;
use Cwd qw/getcwd/;
use Carp qw/croak/;
use Time::HiRes
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) {
cludes chmod_tmp write_file/;
use Test2::Harness::Util::Queue();
use Test2::Harness::Util::JSON(qw/encode_json/);
use Test2::Harness::Runner::Constants;
use Test2::Harness::Runner::Run();
use Test2:
y $depmap = $dtrace->dep_map) {
my $file = "depmap-$stage.json";
write_file($file, encode_json($depmap));
}
}
}
$self->watch($_) for @procs
pawn($job);
$pid = $job->pid;
}
my $json_data = $job->TO_JSON();
$json_data->{stamp} = $spawn_time;
$run->jobs->write($json_data);
return $pid;
}
sub end_test_loop {
ft;
my ($workdir) = @_;
return File::Spec->catfile($workdir, $self->{+RUN_ID});
}
sub TO_JSON { +{ %{$_[0]} } }
sub queue_item {
my $self = shift;
my ($plugins) = @_;
croak "a p
sh;
if (@_ == 1) {
require Test2::Harness::Util::File::JSON;
my $settings_file = Test2::Harness::Util::File::JSON->new(name => $_[0]);
$hash = $settings_file->read;
}
Carp::croak("Too many arguments for $prefix()") if @_;
$this->prefix($prefix);
}
sub TO_JSON {
my $self = shift;
return {%$$self};
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
guments can be provided in
C<@args>.
=item $hashref = $settings->TO_JSON()
This method allows settings to be serialized into JSON.
=back
=head1 SOURCE
The source code repository for Test2-Harness
e::HiRes qw/time/;
use Test2::Harness::Util::UUID qw/gen_uuid/;
use Test2::Harness::Util::JSON qw/decode_json/;
use Test2::Harness::Event;
use Test2::Harness::Auditor::Watcher;
use Test2::Harness::
sub process {
my $self = shift;
while (my $line = <STDIN>) {
my $data = decode_json($line);
last unless defined $data;
my $e = Test2::Harness::Event->new($data);
gzip, or
compressed in bzip2.
=head1 FORMAT
The log file is in jsonl format. Each line of the log can be indepentantly
parsed as json. Each line represents a single event Test2::Harness processed
du
different
processes. A complete log will be terminated by the string C<null>, which is
also valid json. If a log is missing this terminator it is considered an
incomplete log.
=head2 EVENTS
B<Please
st::Util qw/first/;
use Test2::Harness::Util::UUID qw/gen_uuid/;
use Test2::Harness::Util::JSON qw/JSON JSON_IS_XS/;
use Test2::Harness::Util qw/hub_truth apply_encoding/;
use Test2::Util qw/get_tid
my $J = JSON->new;
$J->indent(0);
$J->convert_blessed(1);
$J->allow_blessed(1);
$J->utf8(1);
require constant;
constant->import(ENCODER => $J);
if (JSON_IS_XS) {
require JSON::PP;
my $JPP = JSON::PP->new;
$JPP->indent(0);
$JPP->convert_blessed(1);
$JPP->allow_blessed(1);
$JPP->utf8(1);
constant->import(ENCO
claim_file {}
sub munge_files {}
sub inject_run_data {}
sub setup {}
sub teardown {}
sub TO_JSON { ref($_[0]) || "$_[0]" }
sub redirect_io {
my $this = shift;
my ($settings, $name) = @_
enames, and will be used as
the output tag (best to limit it to 8 characters).
=item $plugin->TO_JSON
This is here as a bare minimum serialization method. It returns the plugin
class name.
=back
=
t2::V0;
use Test2::Plugin::UTF8;
use Test2::API qw/test2_stack/;
use Test2::Harness::Util::JSON qw/decode_json/;
use Test2::Util qw/get_tid ipc_separator/;
# HARNESS-DURATION-SHORT
test2_stack()->top
охи");
my $file = File::Spec->catfile($fmt->dir, join(ipc_separator() => 'events', $$, 0) . ".jsonl");
open(my $fh, '<:utf8', $file) or die "Could not open events file: $!";
my @lines = <$fh>;
l
::More;
use Test2::Plugin::UTF8;
use Test2::API qw/test2_stack/;
use Test2::Harness::Util::JSON qw/decode_json/;
use Test2::Tools::Basic qw/skip_all/;
use File::Spec;
use Test2::Util qw/get_tid ipc_se
ākaha");
my $file = File::Spec->catfile($fmt->dir, join(ipc_separator() => 'events', $$, 0) . ".jsonl");
open(my $events_fh, '<:utf8', $file) or die "Could not open events file: $!";
open(my $stdout
2_JOB_DIR}, 'stdout')) or die "Could not open STDOUT for reading: $!";
my @events = map { decode_json($_) } grep m/(NOTE|DIAG|ASSERT): /, <$events_fh>;
my ($stdout) = grep m/STDOUT: /, <$stdout_fh>;
::Util::HashBase qw/-settings -args/;
use App::Yath::Options();
use Test2::Harness::Util::File::JSON();
sub internal_only { 0 }
sub always_keep_dir { 0 }
sub summary { "No Summary" }
sub
s $file;
my $settings = $self->settings;
my $settings_file = Test2::Harness::Util::File::JSON->new(name => File::Spec->catfile($dir, $file));
$settings_file->write($settings);
return
A helper method to write the settings to a specified directory and filename.
File is written as JSON.
If you are subclassing another command such as L<App::Yath::Command::test> you
may want to over
:Hostname qw/hostname/;
use Test2::Harness::Util qw/clean_path/;
use Test2::Harness::Util::File::JSON;
use Cwd qw/realpath/;
use Importer Importer => 'import';
use Config qw/%Config/;
use Carp qw/cr
return; # Specified, but not found and no vivify
}
my $basename = "yath-persist.json";
my $user = $ENV{USER};
my $hostname = hostname();
my $project = $yath->project
$params{no_checks};
return $pfile if $SEEN_ERROR;
my $data = Test2::Harness::Util::File::JSON->new(name => $pfile)->read();
$data->{version} //= '';
$data->{hostname} //= '';
$d
ut a summary json file, if no path is provided 'summary.json' will be used. The .json extension is added automatically if omitted.",
long_examples => ['', '=/path/to/summary.json'],
return if $$slot;
# Set the default value of 'summary.json'
return $$slot = 'summary.json';
},
);
};
=item D multi-def multiple-default list-default arr
N = '1.000161';
use Carp qw/confess/;
use Time::HiRes qw/time/;
use Test2::Harness::Util::JSON qw/encode_json/;
use Importer 'Test2::Util::Facets2Legacy' => ':ALL';
BEGIN {
require Test2::Event
<facet_data
<stream_id
<event_id
<run_id
<job_id
<job_try
<stamp
+json
processed
};
sub trace { $_[0]->{+FACET_DATA}->{trace} }
sub set_trace { confess "'trace
}) {
$self->{+FACET_DATA}->{trace} //= $trace;
}
}
sub as_json { $_[0]->{+JSON} //= encode_json($_[0]) }
sub TO_JSON {
my $out = {%{$_[0]}};
$out->{+FACET_DATA} = { %{$out->{+FA
use Test2::Harness::Util qw/read_file mod2file looks_like_uuid/;
use Test2::Harness::Util::JSON qw/decode_json/;
use App::Yath::Options;
use parent 'App::Yath::Plugin';
sub can_log {
my ($option
rab_rerun {
my $this = shift;
my ($rerun, %params) = @_;
return (0) if $rerun =~ m/\.jsonl(\.gz|\.bz2)?/;
my $settings = $params{settings};
my $mode_hash = $params{mode_hash};
}
$path = "rerun/$path";
my ($ok, $res, $data) = $this->_request($settings, $path, {json => 1});
if (!$ok) {
print "Error getting a re-run data from yathui: $data...\n";
tions;
use Test2::Harness::Run;
use Test2::Harness::Util::Queue;
use Test2::Harness::Util::File::JSON;
use Test2::Harness::IPC;
use App::Yath::Util qw/find_pfile/;
use Test2::Harness::Util qw/open_f
= $self->pfile_data;
my $runner_settings = Test2::Harness::Util::File::JSON->new(name => $pdata->{dir} . '/settings.json')->read();
for my $prefix (sort keys %{$runner_settings}) {
n
$self->{+PFILE_DATA};
my $pfile = $self->pfile;
my $data = Test2::Harness::Util::File::JSON->new(name => $pfile)->read();
$data->{pfile_path} //= $pfile;
print "\nFound: $data->{pf