<commit_before>use v6;

use Test;

plan 3;

my $filename = "$?FILE.trace";
my $stderr   = "$filename.stderr";

spurt( $filename, q:to/CODE/ );
my $a = 42;
if $a {
    use trace;
    $a++;
    no trace;
    $a--;
}
$a += 1;
use trace;
$a -= 1;
no trace;
say $a;
CODE

my $p = pipe( "$*EXECUTABLE $filename 2>$stderr" );
ok $p,                            "did we get a handle?";
is $p.lines.join, "42",           "is the program output ok?";
is $stderr.IO.lines.join("\n"), qq:to/STDERR/.chomp, "is the trace ok?";
4 ($filename:4)
\$a++
10 ($filename:10)
\$a -= 1
STDERR

unlink $filename, $stderr;<commit_msg>use run() instead of pipe() to capture stdout+err<commit_after>use v6;

use Test;

plan 3;

my $filename = "$?FILE.trace";

spurt( $filename, q:to/CODE/ );
my $a = 42;
if $a {
    use trace;
    $a++;
    no trace;
    $a--;
}
$a += 1;
use trace;
$a -= 1;
no trace;
say $a;
CODE

my $p = run($*EXECUTABLE, $filename, :out, :err);
ok $p ~~ Proc,                    "did we get a Proc?";
is $p.out.lines.join, "42",       "is the program output ok?";
is $p.err.lines.join("\n"), qq:to/STDERR/, "is the trace ok?";
4 ($filename:4)
\$a++
10 ($filename:10)
\$a -= 1
STDERR

unlink $filename;
{'fraction_non_alphanumeric': 0.20854271356783918, 'fraction_numerical': 0.025963149078726967, 'mean_word_length': 2.722741433021807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3681949', 'n_tokens_mistral': 520, 'n_tokens_neox': 488, 'n_words': 155}