1use utf8; 2use strict; 3use warnings; 4use Test::More; 5use Test2::Plugin::UTF8; 6use Test2::API qw/test2_stack/; 7use Test2::Harness::Util::JSON qw/decode_json/; 8use Test2::Tools::Basic qw/skip_all/; 9use File::Spec; 10use Test2::Util qw/get_tid ipc_separator/; 11# HARNESS-DURATION-SHORT 12# HARNESS-NO-IO-EVENTS 13 14test2_stack()->top; 15my ($hub) = test2_stack()->all(); 16my $fmt = $hub->format; 17skip_all "This test requires the stream formatter" 18 unless $fmt && $fmt->isa('Test2::Formatter::Stream'); 19 20print STDOUT "STDOUT: Mākaha\n"; 21note "NOTE: Mākaha"; 22ok(1, "ASSERT: Mākaha"); 23 24my $file = File::Spec->catfile($fmt->dir, join(ipc_separator() => 'events', $$, 0) . ".jsonl"); 25open(my $events_fh, '<:utf8', $file) or die "Could not open events file: $!"; 26open(my $stdout_fh, '<:utf8', File::Spec->catfile($ENV{TEST2_JOB_DIR}, 'stdout')) or die "Could not open STDOUT for reading: $!"; 27 28my @events = map { decode_json($_) } grep m/(NOTE|DIAG|ASSERT): /, <$events_fh>; 29my ($stdout) = grep m/STDOUT: /, <$stdout_fh>; 30 31is($stdout, "STDOUT: Mākaha\n", "Round trip STDOUT encoding/decoding"); 32 33is($events[0]->{facet_data}->{info}->[0]->{details}, "NOTE: Mākaha", "Round trip encoding/decoding a note"); 34is($events[1]->{facet_data}->{assert}->{details}, "ASSERT: Mākaha", "Round trip encoding/decoding an assert"); 35 36done_testing; 37