Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Test::More and XML::Simple

by hypochrismutreefuzz (Scribe)
on Aug 11, 2004 at 21:06 UTC ( [id://382093]=perlquestion: print w/replies, xml ) Need Help??

hypochrismutreefuzz has asked for the wisdom of the Perl Monks concerning the following question:

I have been trying to write tests for a module that use's XML::Simple. However, Test::More and Test::Simple as well do not play well with XML::Simple.

There is a call to the built in function "lock" deep inside XML::Simple that conflicts with the thread-safe version of "lock" that is used by Test::More.

For some reason, Test::More imports itself into all the neighboring namespaces and packages. How do I work around this behavior?

Replies are listed 'Best First'.
Re: Test::More and XML::Simple
by grantm (Parson) on Aug 12, 2004 at 01:34 UTC

    Are you by chance running an incredibly old version of XML::Simple?

    The lock() function was added to allow XML::Simple to be thread safe under the 5.005 threading model while still working with older Perls. That threading model was replaced with a new model in Perl 5.6 and the lock function was removed from XML Simple in October 2002.

    Given that XML::Simple uses Test::More extensively in its own test suite, I'm pretty sure they get along OK :-)

      My version of XML::Simple came with the Active State Perl. It is version 1.06 and I see the current version of XML::Simple is 2.12.

      However, now I can't seem to recreate the errors I was getting. :I

      Thanks

Re: Test::More and XML::Simple
by fergal (Chaplain) on Aug 11, 2004 at 22:35 UTC
    Test::More exports plenty of stuff by default but you can control this by doing something like
    use Test::More (tests => 27, import => ['is' 'like']);
    the stuff in the [] tells it what symbols to export. Test::More uses the standard Exporter.pm to export symbols, it just takes the list of things to export in a slightly different way. Test::More does not export anything into a package unless that package asks for it with a use.

    That said, Test::More doesn't define a subroutine lock() so your problem is something else.

      Test::Builder does have lock() and share(), but they should be sufficiently encapsulated.

      Perhaps the OP's Perl configuration supports ithreads.

Re: Test::More and XML::Simple
by johnnywang (Priest) on Aug 11, 2004 at 22:38 UTC
    Can you provide a little more details? it's best to show how you're using XML::Simple and the test code. I'm using Test:More to test my application which uses XML::Simple, haven't seen any problems yet, but I probably don't have your locking issue. Anyhow, it's pretty hard to tell from what you wrote.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://382093]
Approved by Aristotle
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-28 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found