Subject: | feature request |
I have a feature request. When I'm writing tests I've begun using diag() to help me along the way. It works great, but when I'm done writing the test I don't want the diagnostic info any more. Attached is a patch to implement this feature. To use it, just add "no_diag" to the import arguments when "use"ing the module.
use Test::More tests=>1, qw(no_diag);
diag("This is a diagnostic message");
ok(1, 'dummy test');
--- /usr/lib/perl5/site_perl/5.005/Test/More.pm Wed Mar 6 15:23:31 2002
+++ More.pm Mon Jun 17 11:47:32 2002
@@ -15,7 +15,6 @@
}
-
require Exporter;
use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO);
$VERSION = '0.42';
@@ -33,7 +32,7 @@
);
my $Test = Test::Builder->new;
-
+my $use_diag = 1;
# 5.004's Exporter doesn't have export_to_level.
sub _export_to_level
@@ -172,12 +171,15 @@
sub plan {
my(@plan) = @_;
-
my $caller = caller;
$Test->exported_to($caller);
$Test->plan(@plan);
+ if (grep(/no_diag/, @plan)) {
+ $use_diag = 0;
+ }
+
my @imports = ();
foreach my $idx (0..$#plan) {
if( $plan[$idx] eq 'import' ) {
@@ -625,6 +627,7 @@
=cut
sub diag {
+ return unless $use_diag;
$Test->diag(@_);
}