Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing an exception object in a test control method results in the object being dumped to the screen #102

Open
oschwald opened this issue May 8, 2020 · 2 comments

Comments

@oschwald
Copy link
Contributor

oschwald commented May 8, 2020

When an exception object is thrown from a test control method while using prove, the contents of the object are dumped to the screen rather than the stringified object.

For instance, with:

package TestsFor::Exception;

use Test::Class::Moose;
use Throwable::Error;

sub test_setup {
    Throwable::Error->throw('goodbye');
}

sub test_ok {
    ok(1);
}

package main;

use Test::Class::Moose::CLI;
Test::Class::Moose::CLI->new_with_options->run;

You get these 614 lines of output.

Note that this does not happen with yath. It could arguably be a bug in the Test2 TAP formatter. However, it is limited to exceptions in TCM test control methods.

@autarch
Copy link
Member

autarch commented May 8, 2020

Something somewhere has decided to Data::Dumper::Dumper the argument it was given instead of just stringifying it. I'm not sure what in the chain is doing that, but it's well after the flow of execution leaves TCM.

@exodist, any idea what's going on here?

@autarch
Copy link
Member

autarch commented May 8, 2020

To provide a bit more context, the exception is being passed to a context method like this:

$ctx->ok( 0, "$class->$phase failed", [$error] );

Where $error is the exception object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants