lab-measurement / Lab-Measurement

Lab::Measurement allows to perform test and measurement tasks with Perl scripts.
https://www.labmeasurement.de/
Other
10 stars 11 forks source link

Tests fail (with newest Term::ReadKey?) #8

Closed eserte closed 7 years ago

eserte commented 8 years ago

My smoker machines started to generate test failures for Lab-Measurement 3.520:

Bad filehandle: STDOUT at /opt/perl-5.22.3-RC4/lib/site_perl/5.22.3/x86_64-linux/Term/ReadKey.pm line 377.
Compilation failed in require at /tmpfs/.cpan-build-cpansand/2016101415/Lab-Measurement-3.520-vjAdPJ/blib/lib/Lab/Generic.pm line 287.
BEGIN failed--compilation aborted at /tmpfs/.cpan-build-cpansand/2016101415/Lab-Measurement-3.520-vjAdPJ/blib/lib/Lab/Generic.pm line 287.
Compilation failed in require at /tmpfs/.cpan-build-cpansand/2016101415/Lab-Measurement-3.520-vjAdPJ/blib/lib/Lab/Bus.pm line 8.
BEGIN failed--compilation aborted at /tmpfs/.cpan-build-cpansand/2016101415/Lab-Measurement-3.520-vjAdPJ/blib/lib/Lab/Bus.pm line 8.
Compilation failed in require at t/00-load.t line 108.
# Looks like your test exited with 255 before it could output anything.
t/00-load.t ................... 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 107/107 subtests 

It seems that the failure is caused by newer Term::ReadKey versions (>= 2.34) (FYI: @jonathanstowe). Statistical analysis (negative theta is "bad"):

****************************************************************
Regression 'mod:Term::ReadKey'
****************************************************************
Name                   Theta          StdErr     T-stat
[0='const']           1.0000          0.0000    18674378810148100.00
[1='eq_2.33']         0.0000          0.0000       6.12
[2='eq_2.34']        -1.0000          0.0000    -15247566449435102.00
[3='eq_2.35']        -1.0000          0.0000    -15247566449435098.00
[4='eq_2.37']        -1.0000          0.0000    -17606373188136124.00

R^2= 1.000, N= 45, K= 5
****************************************************************
jonathanstowe commented 8 years ago

Is it possible that it's https://github.com/jonathanstowe/TermReadKey/commit/e515a4538249d7eba50a7cd4898ae50848eda29d ? That was fixing an actual bug BTW.

I think I'd need more context though.

eserte commented 8 years ago

It seems that the call GetTerminalSize(STDOUT); is failing now. With the following diff the tests work again:

diff --git a/lib/Lab/IO/Interface/Term.pm b/lib/Lab/IO/Interface/Term.pm
index 804298a..57b7a08 100644
--- a/lib/Lab/IO/Interface/Term.pm
+++ b/lib/Lab/IO/Interface/Term.pm
@@ -20,7 +20,7 @@ sub new {
     $|++;

     # Terminal size
-    my @size = GetTerminalSize(STDOUT);
+    my @size = GetTerminalSize(\*STDOUT);
     $self->{cols} = $size[0] - 1;
     $self->{rows} = $size[1];
jonathanstowe commented 8 years ago

Yeah, that would make sense as previously the argument to GetTerminalSize was being ignored (so it was always using STDOUT, and was thus presumably correct in most cases,) whereas using the bareword STDOUT there probably shouldn't work:

perl  -Mstrict -we 'sub foo { my ( $fh ) = @_; print $fh "hshshs"; };  foo(STDOUT)'
Bareword "STDOUT" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

Having looked at it, the normalizeHandle could actually handle this a bit better, but as long as the typeglob is passed then it'll be fine for the time being.

amba commented 8 years ago

Thanks for the report!

Problem is that Lab::Measurement currently replaces the default STDOUT handle with it's own degenerate handle. I will soon fix this, so that it just uses the unmodified STDOUT.

This has caused problems before, so unlikely that the problem is with Term::ReadKey.

Sorry for the buzz...

jonathanstowe commented 8 years ago

But do avoid passing a bareword handle to the sub routines in Term::ReadKey - either pass the typeglob as above or a "lexical" handle in a variable.

amba commented 7 years ago

Fixed in master (ccdc40a). Thanks.