From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.5 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9B80E1F4C0 for ; Sat, 2 Nov 2019 02:03:31 +0000 (UTC) From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 1/7] allow using "-d:Mwrap" from the command-line Date: Sat, 2 Nov 2019 02:03:25 +0000 Message-Id: <20191102020331.28050-2-e@80x24.org> In-Reply-To: <20191102020331.28050-1-e@80x24.org> References: <20191102020331.28050-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Maybe other debug options can be supported, too --- lib/Devel/Mwrap.pm | 6 ++++++ t/mwrap.t | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Devel/Mwrap.pm b/lib/Devel/Mwrap.pm index f74f7d1..d8dee58 100644 --- a/lib/Devel/Mwrap.pm +++ b/lib/Devel/Mwrap.pm @@ -6,6 +6,12 @@ our $VERSION = '0.0.0'; use XSLoader; XSLoader::load(__PACKAGE__, $VERSION); +# allow using via the "-d:Mwrap" switch on the command-line: +package # hide the package from the PAUSE indexer + DB; + +sub DB {} # noop, just keeps "-d:Mwrap" happy + 1; __END__ =pod diff --git a/t/mwrap.t b/t/mwrap.t index 5bcc285..eabc68a 100644 --- a/t/mwrap.t +++ b/t/mwrap.t @@ -57,6 +57,8 @@ E1 { my $env = { MWRAP => "dump_path:$dump" }; mwrap_run('source location', $env, 't/source_location.perl'); + mwrap_run('source location via -d:', $env, + '-d:Mwrap', 't/source_location.perl'); } done_testing(); @@ -69,6 +71,9 @@ sub slurp { sub mwrap_run { my ($msg, $env, @args) = @_; + unless (grep(/\A-.+\bMwrap\b/, @args)) { + unshift @args, '-MDevel::Mwrap'; + } my $pid = fork; if ($pid == 0) { while (my ($k, $v) = each %$env) { @@ -76,10 +81,11 @@ sub mwrap_run { } open STDERR, '>', $err or die "open: $!"; open STDOUT, '>', $out or die "open: $!"; - @ARGV = ($^X, '-MDevel::Mwrap', @args); + @ARGV = ($^X, @args); eval $src; die "fail: $! ($@)"; } waitpid($pid, 0); is($?, 0, $msg); + diag "err: ".slurp($err) if $?; }