<commit_before>use strict;
use warnings;
use v5.18.1;
use feature qw(say);

use Test::Most;
use Data::Dumper;
use IO::Async::Timer::Periodic;
use IO::Async::Loop;
use Test::Output;


use_ok( 'DTrace::Consumer' );

my $dtc = DTrace::Consumer->new();

isa_ok( $dtc, 'DTrace::Consumer' );
can_ok( $dtc, qw( strcompile setopt go consume stop ) );

my $prog = q\
BEGIN {
  x = (int *)NULL;
  y = *x;
  trace(y);
  trace(strlen(0));
}

syscall:::entry
{
  @c[probefunc] = count();
}
\;

lives_ok(
  sub {
    $dtc->strcompile($prog);
  },
  'strcompile of erroring DTrace script'
);

lives_ok( sub { $dtc->go(); },
          'engage the DTrace probes that will generate an error');

sub test_error {
  # We need to fail in the consume, otherwise it'll never exit on its own
  $dtc->consume(
    sub {
      fail("Run long enough to generate an error"); 
    }
  );
}

#test_error();
stderr_like(\&test_error,
            qr/^error\s+on\s+enabled\s+probe\s+ID/smx,
            'errors produce messages on STDERR');

done_testing();
<commit_msg>diag WAKA<commit_after>use strict;
use warnings;
use v5.18.1;
use feature qw(say);

use Test::Most;
use Data::Dumper;
use IO::Async::Timer::Periodic;
use IO::Async::Loop;
use Test::Output;


use_ok( 'DTrace::Consumer' );

my $dtc = DTrace::Consumer->new();

isa_ok( $dtc, 'DTrace::Consumer' );
can_ok( $dtc, qw( strcompile setopt go consume stop ) );

my $prog = q\
BEGIN {
  x = (int *)NULL;
  y = *x;
  trace(y);
  trace(strlen(0));
}

syscall:::entry
{
  @c[probefunc] = count();
}
\;

lives_ok(
  sub {
    $dtc->strcompile($prog);
  },
  'strcompile of erroring DTrace script'
);

lives_ok( sub { $dtc->go(); },
          'engage the DTrace probes that will generate an error');

sub test_error {
  # We need to fail immediately in the consume, otherwise it'll never exit on its own
  $dtc->consume(
    sub {
      diag("WAKA WAKA");
      fail("Run long enough to generate an error"); 
    }
  );
}

stderr_like(\&test_error,
            qr/^error\s+on\s+enabled\s+probe\s+ID/smx,
            'errors produce messages on STDERR');

done_testing();

{'fraction_non_alphanumeric': 0.1658699808795411, 'fraction_numerical': 0.004780114722753346, 'mean_word_length': 3.453191489361702, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1953953', 'n_tokens_mistral': 821, 'n_tokens_neox': 797, 'n_words': 209}