Skip to content

Instantly share code, notes, and snippets.

@exodist
Created September 2, 2024 04:04
Show Gist options
  • Save exodist/65194d0da50d5360678b7a07215b1dca to your computer and use it in GitHub Desktop.
Save exodist/65194d0da50d5360678b7a07215b1dca to your computer and use it in GitHub Desktop.
no-dep using test2 to catch warnings and make them fatal
use strict;
use warnings;
use Test2::V0;
ok(1);
$SIG{__WARN__} = sub {
my ($warn) = @_;
my $ctx = context;
$ctx->send_ev2(errors => [{tag => 'WARNING', details => "Got warning: $warn", fail => 1}]);
$ctx->release;
CORE::warn($warn);
};
warn "foo";
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment