http://www.perlmonks.org?node_id=1136635


in reply to Test::Exception error on Strawberry Perl 5.14.3 ('Bareword "xception" ...')

Can you post the test file (or at least to just after line 14), or otherwise let us know which module you're speaking of?

I need to troubleshoot some failing tests for Strawberry Perl as well today...

Replies are listed 'Best First'.
Re^2: Test::Exception error on Strawberry Perl 5.14.3 ('Bareword "xception" ...')
by 1nickt (Canon) on Jul 28, 2015 at 17:34 UTC

    Hi stevieb, test code is below. The dist in question is CMS::Drupal::Modules::MembershipEntity. As I mentioned I find it very odd since t/40_fetch_memberships.t failed whereas t/10_obj_and_params.t, t/20_valid_drupal.t, t/50_term_object_params.t and t/60_membership_object_params.t all passed. Also the error only occurred on Strawberry 5.14.3.

    It really looks like the interpreter had a hiccup!

    Error message:

    Bareword "xception" not allowed while "strict subs" in use at C:/straw +berry5143/perl/vendor/lib/Test/Exception.pm line 4. Compilation failed in require at t/40_fetch_memberships.t line 14. BEGIN failed--compilation aborted at t/40_fetch_memberships.t line 14.

    First 7 lines of Test/Exception.pm:

    1: use strict; 2: use warnings; 3: 4: package Test::Exception; # <-- line cited in error message 5: use Test::Builder; 6: use Sub::Uplevel qw( uplevel ); 7: use base qw( Exporter );

    This is t/40_fetch_memberships.t:

    #! perl use strict; use warnings; BEGIN { ## Make sure we don't connect to our real DB if we ## have given the credentials for it $ENV{'DRUPAL_IGNORE_TEST_CREDS'} = 1; } use open ':std', ':encoding(utf8)'; use Test::More tests => 1; use Test::Group; use Test::Exception; # <-- line cited in error message use CMS::Drupal; use CMS::Drupal::Modules::MembershipEntity; use CMS::Drupal::Modules::MembershipEntity::Test; my $drupal = CMS::Drupal->new; my $dbh = build_test_db( $drupal ); my $ME = CMS::Drupal::Modules::MembershipEntity->new( dbh => $dbh +); subtest 'Feed various things to fetch_memberships()', sub { plan tests => 2; subtest 'Various arrays of valid mids', sub { plan tests => 10; for ( [], [3694], [3694, 2966], [3694, 2966, 42], [3302, 3358, 3414, 3470, 3530, 3582, 3638, 3694, 3750, 3948, + 3974, 4006, 4030, 4086], ) { my @array = @{ $_ }; my $hashref; lives_ok { $hashref = $ME->fetch_memberships( @array ) } 'Called fetch_memberships().'; my $cmp_data = build_test_data( @array ); test 'Data comparison with '. @array .' mids', sub { is( (scalar keys %{ $hashref }), (scalar keys %{ $cmp_data }), 'One item returned for each mid passed in' ); is_deeply($hashref, $cmp_data, 'Data matches' ); }; } }; subtest 'Various arrays with invalid mids', sub { plan tests => 4; for ( [3694, 'foo'], [3694, $ME], [3694, chr(0x263a)], [3694, sub { print "Hello, world\n" }], ) { my @array = @{ $_ }; dies_ok { my $hashref = $ME->fetch_memberships( @array ) } $arra +y[1]; } }; }; __END__
    The way forward always starts with a minimal test.
      As I mentioned I find it very odd since t/40_fetch_memberships.t failed whereas t/10_obj_and_params.t, t/20_valid_drupal.t, t/50_term_object_params.t and t/60_membership_object_params.t all passed.

      In those test files, the one that fails is the only one that contains:
      use open ':std', ':encoding(utf8)';
      Could that be connected to the error ? (Comment it out and see whether the same error arises.)
      Does that line *have* to be situated before the loading of Test::Exception ?

      Cheers,
      Rob

        Thanks syphilis, it's worth a try. I'll make a new version and upload it tonight.

        The way forward always starts with a minimal test.
      Did you try to reproduce the problem without all that extra CMS stuff?