Skip Menu |

This queue is for tickets about the Test-Harness CPAN distribution.

Report information
The Basics
Id: 58229
Status: rejected
Priority: 0/
Queue: Test-Harness

People
Owner: andy [...] hexten.net
Requestors: CALDRIN [...] cpan.org
Cc: ether [...] cpan.org
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Test::Harness always set -w and thus makes test with 'no warnings' impossible
Test::Harness always sets the -w switch for perl unconditionally. Since Test::Harness is used by ExtUtils::MakeMaker and in turn by Module::Install for make test. Both will output bogus warnings in testing because the programmer can not overwrite this warning decision. This is especially annoying for "uninitialized" warnings. Thus, I suggest removing the "-w" switch from Test::Harness and let the developer decide whether warnings are wanted or not.
Subject: Re: [rt.cpan.org #58229] Test::Harness always set -w and thus makes test with 'no warnings' impossible
Date: Tue, 08 Jun 2010 15:32:10 -0700
To: bug-Test-Harness [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2010.6.8 1:15 AM, Maik Hentsche via RT wrote: Show quoted text
> Test::Harness always sets the -w switch for perl unconditionally. Since > Test::Harness is used by ExtUtils::MakeMaker and in turn by > Module::Install for make test. Both will output bogus warnings in > testing because the programmer can not overwrite this warning decision. > This is especially annoying for "uninitialized" warnings. > > Thus, I suggest removing the "-w" switch from Test::Harness and let the > developer decide whether warnings are wanted or not.
Thank you for sending in this suggestion. -w has been the default for Test::Harness since it was introduced 16 years ago. It would break a lot of tests which check for the existence or non-existence of warnings. Its also a good default (see argument below), especially for tests, and worth having to quiet the occasional overzealous warning. It ain't likely to change, sorry. A simple work around is this: BEGIN { $^W = 0 } or if the "bogus" warnings are in your test script: no warnings 'uninitialized'; If you want to nuke all warnings, overriding even "use warnings" you can put -X in the #! line and Test::Harness will honor it. Finally, Test::Harness has the $switches global (and the undocumented HARNESS_PERL_SWITCHES) and TAP::Harness has the "switches" option to alter the default switches. So you have options. I would strongly recommend rather than suppress these warnings during testing to actually fix them. First, while uninitialized warnings may be annoying, you can't tell an expected uninitialized value from an unexpected one. If you ignore uninitialized warnings it becomes very difficult to know when your program has a subtle data error. Second is the "one broken window" psychological problem. Once one warning is acceptable, two is very easy. And then three and four and soon nobody is paying attention to the warnings any more. This is both because of a deadening effect, warnings become "normal", and because there's so many "expected" warnings to track that it becomes hard to see the unexpected ones. This is particularly distressing to new users and programmers coming into the project as they must learn, usually ad hoc, which warnings are "ok". It is a less severe, but more insidious, version of the "expected failure" as in "oh, these tests always fail, don't worry about it". Finally, code, especially libraries, which habitually spit out warnings are impolite. If I have warning-free code, with warnings turned on, and use a function with "expected warnings" it clutters up my code and my logs. I inherit the warnings and must deal with them by locally turning off warnings. Get enough 3rd party functions that habitually throw warnings and you wind up turning warnings off entirely. -- The mind is a terrible thing, and it must be stopped.
This was rejected, but now seems to have been implemented in 3.24... http://search.cpan.org/diff?from=Test-Harness-3.23&to=Test-Harness-3.24#t/ nowarn.t That's great - the warnings tend to annoy me. But this is a fairly big change, so it would be nice if it were at least mentioned in the change log.
On Sat Jun 30 21:05:27 2012, TOBYINK wrote: Show quoted text
> This was rejected, but now seems to have been implemented in 3.24...
Here's the change. https://github.com/Perl-Toolchain-Gang/Test-Harness/commit/18794a8565633ae08f048b9cf6c25b03be6e1020 AFAIK this change was not discussed, it is not in the change log, it has huge backwards compat consequences, and we rejected the idea of changing it last year. Andy, what's the story?
I reverted the change which removed -w as a default.
https://github.com/Perl-Toolchain-Gang/Test-Harness/commit/99159fc214a874be1929b500af33538aeae36c10

I've also added a pull request to document HARNESS_PERL_SWITCHES which got lost somewhere along the way.

I definitely agree the default behavior needs a good way to be turned off.  Perhaps a prove switch which acts like HARNESS_PERL_SWITCHES but overrides the default.
On Tue Jun 08 04:15:25 2010, CALDRIN wrote: Show quoted text
> Test::Harness always sets the -w switch for perl unconditionally. Since > Test::Harness is used by ExtUtils::MakeMaker and in turn by > Module::Install for make test. Both will output bogus warnings in > testing because the programmer can not overwrite this warning decision. > This is especially annoying for "uninitialized" warnings. > > Thus, I suggest removing the "-w" switch from Test::Harness and let the > developer decide whether warnings are wanted or not.
The final decision on the mailinglist was that Test::Harness should be the backwards compatibility layer, and even though the new behavior is desirable, end-users (ExtUtils::MakeMaker and Module::Build) should explicitly empty the default switches, or just use TAP::Harness directly. Accordingly, I'm marking this as rejected.