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
Test::DZil/Dist::Zilla::Tester: log is lost if dzil dies in construction. #485
Comments
I have managed the problem by such a trick: If Dist::Zilla dies in construction, my code saves the exception and creates fake, "stub" builder. Stub builder remembers the exception and original logger. When Such approach allows this code works:
This approach is implemented as DistZillaTester.pm module. It is not published separately (yet?), but is a part of my If you find this acceptable, it could be incorporated to However, I do not think is is the only possible solution. The primary goal: not loosing log messages, may be achieved in other ways. For example, probably the simplest solution would be saving reference to logger object in a global variable:
But anyway, log messages should not be lost if builder dies in construction. |
Sorry, I have closed in mistakenly. |
Why not capture the exceptions thrown from |
|
I mean, what specifically do you need to access in log_messages? Generally the only relevant data is why |
A generic example: A plugin may validate its arguments in A real example: My plugin |
Check out my log-log-events branch. With it, it will store the log events to |
I want to write some negative tests for my plugin to check error reporting. Unfortunately,
Test::DZil
/Dist::Zilla::Tester
lack support for negative tests. For example, straightforward approach:does not work if
Dist::Zilla
or its plugin dies in construction (infrom_config
class method). Attempts to catch an exception thrown fromfrom_config
works:but this is not enough for testing: I would like to check the log messages printed by
dzil
and plugins, but it is not possible, because$tzil
assignment is not completed, so$tzil
is undefined,$tzil->log_messages
does not work, all the messages are lost.It wold be nice if log messages are saved for later checking.
The text was updated successfully, but these errors were encountered: