Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixing failing tests to work with DATAPRINTERRC #37

Merged
merged 1 commit into from

2 participants

@bessarabov

In my environment I have set up DATAPRINTERRC=
/home/bessarabov/felix/tilde/.dataprinter (you can see the content of this
file: https://gist.github.com/4216269)

With this ENV variable set I had some tests failing. Now I have managed to
find why it happens. The problem is with the BEGIN section in tests. If
use DDP is in the BEGIN section of the test file then the import() method
from file Data/Printer.pm is executed before the things written in the test
BEGIN section.

To prevent tests from failng I have moved use DDP out ouf BEGIN section. And
now all my tests pass.

I think if you accept this solution other test files also need to be fixed:
with my rc file they pass, but I think that the otther rc file can cause them
to fail.

@bessarabov bessarabov Fixing failing tests to work with DATAPRINTERRC
In my environment I have set up DATAPRINTERRC=
/home/bessarabov/felix/tilde/.dataprinter (you can see the content of this
file: https://gist.github.com/4216269)

With this ENV variable set I had some tests failing. Now I have managed to
find why it happens. The problem is with the BEGIN section in tests. If
`use DDP` is in the BEGIN section of the test file then the import() method
from file Data/Printer.pm is executed before the things written in the test
BEGIN section.

To prevent tests from failng I have moved `use DDP` out ouf BEGIN section. And
now all my tests pass.

I think if you accept this solution other test files also need to be fixed:
with my rc file they pass, but I think that the otther rc file can cause them
to fail.
b90c695
@garu
Owner

Hi Ivan!

first of all, sorry for such a late response. Apparently I missed a whole bunch of github reports, not entirely sure why, maybe something is dodgy with my email forwarding, it doesn't matter.

Anyway, while I have no problem with moving some of these lines around, I'd really rather do it more consciously. By that, I mean: could you help me reproduce the issue you were having? Maybe share a minimal piece of your .dataprinter that I can use to make at least one of the tests fail here? This will definitely help me better grasp the situation and maybe even write some more tests to make DDP even more reliable.

Thanks!

@bessarabov

Here is the value of $DATAPRINTERRC:

bessarabov@b-yanote:~/git/Data-Printer$ echo $DATAPRINTERRC
/home/bessarabov/felix/tilde/.dataprinter

Here is the content of that file:

bessarabov@b-yanote:~/git/Data-Printer$ cat /home/bessarabov/felix/tilde/.dataprinter
{
    use_prototypes => 0,
    hash_separator => ' => ',
    index          => 0,
    return_value   => 'void',
    end_separator  => 1,
}

And here is the test results with this setup (I'm running test on the current master, it is commit 6011eaf):

bessarabov@b-yanote:~/git/Data-Printer$ prove -Ilib
t/00-load.t ................. # Beginning Data::Printer tests in linux with Perl 5.010001, /usr/bin/perl
t/00-load.t ................. 1/1 # Testing Data::Printer 0.35
t/00-load.t ................. ok
t/01-p.t .................... ok
t/02-colors.t ............... ok
t/02.2-autocolor.t .......... skipped: IO::Pty::Easy required for auto-colored tests
t/03-conf.t ................. ok
t/03-conf_not_ref.t ......... ok
t/04-multiline.t ............ ok
t/05-obj.t .................. ok
t/06-obj2.t ................. ok
t/07-sort.t ................. ok
t/08-deparse.t .............. ok
t/09-alias.t ................ ok
t/10-filter.t ............... ok
t/11-aliased_with_filter.t .. ok
t/12-filter_class.t ......... ok
t/13-filter_datetime.t ...... ok
t/13.2-filter_db.t .......... ok
t/13.3-filter_digest.t ...... ok
t/14-local_conf.t ........... ok
t/15-rc_file.t .............. ok
t/16-rc_file2.t ............. ok
t/16.2-rc_overwrite.t ....... ok
t/16.3-rc_env.t ............. ok
t/16.4-rc_env2.t ............ ok
t/16.5-rc_env3.t ............ ok
t/17-parallel.t ............. ok
t/18-class_method.t ......... ok
t/19-tied.t ................. ok
t/20-handles.t .............. *main::$var  (write-only, layers: unix perlio)
Use of uninitialized value $this in pattern match (m//) at t/20-handles.t line 31.
t/20-handles.t .............. 1/?
#   Failed test 'layer unix present in info'
#   at t/20-handles.t line 31.
#                   undef
#     doesn't match '(?-xism:unix)'
Use of uninitialized value $this in pattern match (m//) at t/20-handles.t line 31.

#   Failed test 'layer perlio present in info'
#   at t/20-handles.t line 31.
#                   undef
#     doesn't match '(?-xism:perlio)'
*main::$var  (write-only, layers: unix perlio)
Use of uninitialized value $this in pattern match (m//) at t/20-handles.t line 48.

#   Failed test 'write-only handle'
#   at t/20-handles.t line 48.
#                   undef
#     doesn't match '(?-xism:write-only)'
*main::$var  (read/write, flags: append, layers: unix perlio)
Use of uninitialized value $this in pattern match (m//) at t/20-handles.t line 54.

#   Failed test 'read/write handle'
#   at t/20-handles.t line 54.
#                   undef
#     doesn't match '(?-xism:read/write)'
*main::$var  (read/write, flags: append, layers: unix perlio)
Use of uninitialized value $this in pattern match (m//) at t/20-handles.t line 55.

#   Failed test 'append flag'
#   at t/20-handles.t line 55.
#                   undef
#     doesn't match '(?-xism:flags:[^,]+append)'
*main::$var  (read-only, layers: unix perlio)
Use of uninitialized value $this in pattern match (m//) at t/20-handles.t line 62.

#   Failed test 'read-only handle'
#   at t/20-handles.t line 62.
#                   undef
#     doesn't match '(?-xism:read-only)'
# Looks like you failed 6 tests of 6.
t/20-handles.t .............. Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/6 subtests
t/21-ddp.t .................. ok
t/22-class_method.t ......... ok
t/23-caller_info.t .......... ok
t/24-no_prototypes.t ........ ok
t/25-weak.t ................. ok
t/26-tainted.t .............. ok
t/27-pass_through.t ......... skipped: Capture::Tiny not found
t/27.2-pass_through.t ....... skipped: Capture::Tiny not found
t/27.3-pass_through-DDP.t ... skipped: Capture::Tiny not found
t/27.4-pass_through-DDP.t ... skipped: Capture::Tiny not found
t/28-void_return.t .......... skipped: Capture::Tiny not found
t/29-output.t ............... skipped: Capture::Tiny not found
t/30-print_escapes.t ........ ok
t/31-bad_parameters.t ....... ok
t/32-quote_keys.t ........... ok
t/33-end_separator.t ........ ok
t/33-separator.t ............ ok
t/34-show_readonly.t ........ ok
t/35-vstrings.t ............. v1.2.3
t/35-vstrings.t ............. 1/?
#   Failed test 'VSTRINGs'
#   at t/35-vstrings.t line 17.
#          got: undef
#     expected: 'v1.2.3'
# Looks like you failed 1 test of 1.
t/35-vstrings.t ............. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
t/36-valign.t ............... {
    3         => 4,
    'foo bar' => 2,
}
t/36-valign.t ............... 1/1
#   Failed test 'colored alignment'
#   at t/36-valign.t line 16.
#          got: undef
#     expected: '\ {
#     3           4,
#     'foo bar'   2
# }'
# Looks like you failed 1 test of 1.
t/36-valign.t ............... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
t/37-format.t ............... FORMAT
t/37-format.t ............... 1/?
#   Failed test 'FORMAT refs'
#   at t/37-format.t line 20.
#          got: undef
#     expected: 'FORMAT'
# Looks like you failed 1 test of 1.
t/37-format.t ............... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
t/38-lvalue.t ............... "c" (LVALUE)
t/38-lvalue.t ............... 1/?
#   Failed test 'LVALUE refs'
#   at t/38-lvalue.t line 17.
#          got: undef
#     expected: '"c" (LVALUE)'
"c"

#   Failed test 'disabled LVALUE refs'
#   at t/38-lvalue.t line 18.
#          got: undef
#     expected: '"c"'
# Looks like you failed 2 tests of 2.
t/38-lvalue.t ............... Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/2 subtests
t/39-seen_override.t ........ ok
t/40-escape_chars.t ......... 1/? Warning: Use of "shift" without parentheses is ambiguous at t/40-escape_chars.t line 22.
Warning: Use of "shift" without parentheses is ambiguous at t/40-escape_chars.t line 32.
t/40-escape_chars.t ......... ok

Test Summary Report
-------------------
t/20-handles.t            (Wstat: 1536 Tests: 6 Failed: 6)
  Failed tests:  1-6
  Non-zero exit status: 6
t/35-vstrings.t           (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
t/36-valign.t             (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
t/37-format.t             (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
t/38-lvalue.t             (Wstat: 512 Tests: 2 Failed: 2)
  Failed tests:  1-2
  Non-zero exit status: 2
Files=53, Tests=300,  3 wallclock secs ( 0.23 usr  0.04 sys +  3.07 cusr  0.45 csys =  3.79 CPU)
Result: FAIL
bessarabov@b-yanote:~/git/Data-Printer$

And here are the test results if i delete config file:

bessarabov@b-yanote:~/git/Data-Printer$ rm /home/bessarabov/felix/tilde/.dataprinter
bessarabov@b-yanote:~/git/Data-Printer$ prove -Ilib
t/00-load.t ................. # Beginning Data::Printer tests in linux with Perl 5.010001, /usr/bin/perl
t/00-load.t ................. 1/1 # Testing Data::Printer 0.35
t/00-load.t ................. ok
t/01-p.t .................... ok
t/02-colors.t ............... ok
t/02.2-autocolor.t .......... skipped: IO::Pty::Easy required for auto-colored tests
t/03-conf.t ................. ok
t/03-conf_not_ref.t ......... ok
t/04-multiline.t ............ ok
t/05-obj.t .................. ok
t/06-obj2.t ................. ok
t/07-sort.t ................. ok
t/08-deparse.t .............. ok
t/09-alias.t ................ ok
t/10-filter.t ............... ok
t/11-aliased_with_filter.t .. ok
t/12-filter_class.t ......... ok
t/13-filter_datetime.t ...... ok
t/13.2-filter_db.t .......... ok
t/13.3-filter_digest.t ...... ok
t/14-local_conf.t ........... ok
t/15-rc_file.t .............. ok
t/16-rc_file2.t ............. ok
t/16.2-rc_overwrite.t ....... ok
t/16.3-rc_env.t ............. ok
t/16.4-rc_env2.t ............ ok
t/16.5-rc_env3.t ............ ok
t/17-parallel.t ............. ok
t/18-class_method.t ......... ok
t/19-tied.t ................. ok
t/20-handles.t .............. ok
t/21-ddp.t .................. ok
t/22-class_method.t ......... ok
t/23-caller_info.t .......... ok
t/24-no_prototypes.t ........ ok
t/25-weak.t ................. ok
t/26-tainted.t .............. ok
t/27-pass_through.t ......... skipped: Capture::Tiny not found
t/27.2-pass_through.t ....... skipped: Capture::Tiny not found
t/27.3-pass_through-DDP.t ... skipped: Capture::Tiny not found
t/27.4-pass_through-DDP.t ... skipped: Capture::Tiny not found
t/28-void_return.t .......... skipped: Capture::Tiny not found
t/29-output.t ............... skipped: Capture::Tiny not found
t/30-print_escapes.t ........ ok
t/31-bad_parameters.t ....... ok
t/32-quote_keys.t ........... ok
t/33-end_separator.t ........ ok
t/33-separator.t ............ ok
t/34-show_readonly.t ........ ok
t/35-vstrings.t ............. ok
t/36-valign.t ............... ok
t/37-format.t ............... ok
t/38-lvalue.t ............... ok
t/39-seen_override.t ........ ok
t/40-escape_chars.t ......... 1/? Warning: Use of "shift" without parentheses is ambiguous at t/40-escape_chars.t line 22.
Warning: Use of "shift" without parentheses is ambiguous at t/40-escape_chars.t line 32.
t/40-escape_chars.t ......... ok
All tests successful.
Files=53, Tests=300,  4 wallclock secs ( 0.19 usr  0.08 sys +  2.92 cusr  0.59 csys =  3.78 CPU)
Result: PASS
bessarabov@b-yanote:~/git/Data-Printer$
@garu garu merged commit e1fda90 into from
@garu
Owner

Sigh. I can't believe I've let this sit here for so long. Sorry!

@bessarabov

=) Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2012
  1. @bessarabov

    Fixing failing tests to work with DATAPRINTERRC

    bessarabov authored
    In my environment I have set up DATAPRINTERRC=
    /home/bessarabov/felix/tilde/.dataprinter (you can see the content of this
    file: https://gist.github.com/4216269)
    
    With this ENV variable set I had some tests failing. Now I have managed to
    find why it happens. The problem is with the BEGIN section in tests. If
    `use DDP` is in the BEGIN section of the test file then the import() method
    from file Data/Printer.pm is executed before the things written in the test
    BEGIN section.
    
    To prevent tests from failng I have moved `use DDP` out ouf BEGIN section. And
    now all my tests pass.
    
    I think if you accept this solution other test files also need to be fixed:
    with my rc file they pass, but I think that the otther rc file can cause them
    to fail.
This page is out of date. Refresh to see the latest.
View
4 t/20-handles.t
@@ -11,13 +11,13 @@ BEGIN {
use Test::More;
use Fcntl;
- use Data::Printer;
-
$filename = File::Spec->catfile(
File::HomeDir->my_home, 'test_file.dat'
);
};
+use Data::Printer;
+
if ( open $var, '>', $filename ) {
my $str = p $var;
View
3  t/26-tainted.t
@@ -17,9 +17,10 @@ BEGIN {
delete $ENV{DATAPRINTERRC};
use File::HomeDir::Test; # avoid user's .dataprinter
use_ok ('Term::ANSIColor');
- use_ok ('Data::Printer', colored => 1);
};
+use Data::Printer colored => 1;
+
is(
p($path),
color('reset') . q["] . colored($path, 'bright_yellow') . q["]
View
4 t/35-vstrings.t
@@ -7,10 +7,10 @@ BEGIN {
use File::HomeDir::Test; # avoid user's .dataprinter
use Test::More;
- use Data::Printer;
-
}
+use Data::Printer;
+
plan skip_all => 'Older perls do not have VSTRING support' if $] < 5.010;
my $scalar = v1.2.3;
eval {
View
3  t/36-valign.t
@@ -8,9 +8,10 @@ BEGIN {
$ENV{ANSI_COLORS_DISABLED} = 1;
delete $ENV{DATAPRINTERRC};
use File::HomeDir::Test; # avoid user's .dataprinter
- use Data::Printer;
};
+use Data::Printer;
+
my $var = { q[foo bar],2,3,4};
is(
View
3  t/37-format.t
@@ -7,10 +7,11 @@ BEGIN {
use File::HomeDir::Test; # avoid user's .dataprinter
use Test::More;
- use Data::Printer;
}
+use Data::Printer;
+
format TEST =
.
View
4 t/38-lvalue.t
@@ -7,10 +7,10 @@ BEGIN {
use File::HomeDir::Test; # avoid user's .dataprinter
use Test::More;
- use Data::Printer;
-
}
+use Data::Printer;
+
my $scalar = \substr( "abc", 2);
my $test_name = "LVALUE refs";
eval {
Something went wrong with that request. Please try again.