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

_indent() is a private method of Test::Builder #2

Open
schwern opened this issue Jul 10, 2012 · 6 comments
Open

_indent() is a private method of Test::Builder #2

schwern opened this issue Jul 10, 2012 · 6 comments
Assignees

Comments

@schwern
Copy link
Contributor

schwern commented Jul 10, 2012

This is going to break in Test::Builder1.5.

Unfortunately, I don't have a better way to do it right now.

In addition, the Test::Builder structured diagnostic design is unlikely to follow the pattern of:

ok( ... );
structured_diagnostics( ... );

and instead do them either as a single call or building a single object. This is so that the result and diagnostics can be formatted as one. TAP is special in allowing them to be separate.

Sooo... I'm not sure what happens to this module in Test::Builder1.5 space. For the moment maybe detect a Test::Builder::VERSION >= 1.5 and die with a nice error message?

@renormalist
Copy link
Owner

There should be some way to indent, also in TB2. I was so happy to find that internal method
after years of doing it outside Test::Builder using lame regex filtering. I would happily switch the way
depending on TB version.

The ok+structured_diagnostics thing will probably not change soon, by the nature of TAP, as you said.
Although my TAP::DOM generates a parent/child connection on structured_diagnostics I'm aware that
the TAP creator has to take care of that relation in advance.

In our TAP-centric test infrastructure Tapper we always run "prove -m"
to at least merge STDERR into STDOUT to avoid divergence of ok and structured_diagnostics,
and in our non-Perl toolchains do not use STDERR at all for diagnostics, all just
to keep ok+structure_diagnostics together.

@renormalist
Copy link
Owner

Ah, and BTW, why not integrate the whole Test::TAPv13 functionality into TB2?

@schwern
Copy link
Contributor Author

schwern commented Aug 7, 2012

The real complication is this: Test::Builder 1.5 is no longer wielded to TAP. There's a multitude of different formatters now. Rather than test libraries crafting output directly, they send events which are used by the formatters to produce output. "Indent this output" or even "output this exactly" is not a concept that makes sense in Test::Builder 1.5, because a test library doesn't know what format the program has chosen (it could introspect and look, but don't do that).

Meta-data associated with a test result has been in the plans for some time, but Test::TAPv13's implementation doesn't make sense for Test::Builder 1.5. It would instead be additional data associated with Result, TestStart and TestEnd events. Potentially any event could have a hash of extra data attached to it.

I put this on hold because I need to concentrate on stabilizing Test::Builder 1.5, but you could work on it. Starting with something simple like is(). File and line information is already part of the result object and the "# Failed test" line is produced by the formatter from event information. Try changing TB2::Formatter::TAP::Base to produce structured diagnostics from a result. Try adding the have/want information to a result from is() and format that.

@exodist
Copy link

exodist commented May 25, 2016

bump

With the release of Test2 this problem is once again surfacing. ->_indent is now gone, and this will not pass on the latest releases.

Here are some possible paths forward:

  • Create Test2::Event::YAML using the Test2::Event structure (If you implement it correctly this can be a generic event that works regardless of formatter
  • Create Test2::Formatter::TAPv13 which is a subclass of Test2::Formatter::TAP

I recommend doing both of these. You can write the YAML event and fire it off instead of doing what you do now. The TAPv13 formatter can output the TAP 13 header/pragma, and can write YAML output correctly according to spec. Using the generic interface the YAML can be rendered as comments, or hidden entirely in non-TAP13 formatters. Your module here could then simply provide the function to fire off YAML events, and also load/set the formatter.

@renormalist
Copy link
Owner

ACK. I will have a look.

Steffen

Chad Granum [email protected] writes:

bump

With the release of Test2 this problem is once again surfacing. ->_indent is now gone, and this will not pass on the latest releases.

Here are some possible paths forward:

  • Create Test2::Event::YAML using the Test2::Event structure (If you implement it correctly this can be a generic event that works regardless of formatter
  • Create Test2::Formatter::TAPv13 which is a subclass of Test2::Formatter::TAP

I recommend doing both of these. You can write the YAML event and fire it off instead of doing what you do now. The TAPv13 formatter can output the TAP 13 header/pragma, and can write YAML output
correctly according to spec. Using the generic interface the YAML can be rendered as comments, or hidden entirely in non-TAP13 formatters. Your module here could then simply provide the function to fire
off YAML events, and also load/set the formatter.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub*

Steffen Schwigon [email protected]

@renormalist
Copy link
Owner

I just marked this issue in RT as WONTFIX and uploaded a new version with a DEPRECATION hint in Changelog.
Not sure if I keep this ticket here open, too.

@renormalist renormalist self-assigned this Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants