Re: [Module::Build] Capturing test output to please CPANPLUS
Status: Beta
Brought to you by:
kwilliams
From: Jos I. B. <ka...@xs...> - 2006-04-10 08:45:20
|
On Apr 10, 2006, at 8:46 AM, Randy W. Sims wrote: > Randy W. Sims wrote: >> Will something like this work for a temporary solution that we can >> maybe figure out how to extend in the future to always capture >> output? > > Regarding Ticket #9793 [1] > > Scratch that. I don't really like my previous solution. I'm not > sure Module::Build needs to be responsible for capturing output; I > can't really see any benifit. Well as an API to a build interface, it would be nice to get the diagnostics back from that API, without having to rely on retie'ing STDOUT in your client application -- not just CPANPLUS will want to use this API, but every coder (else, why bother with an API?). The point is that you have the data available at a very precise location in M::B, and all you need to do is store it, and every user can happily use it -- make an accessor called ->stack() with all your 'extra' messages? a specific one called ->test_output?; it's all the same to the user, as long as it doesn't get thrown away! > Is there a reason CPANPLUS (or CPANPLUS::Dist::Build) can't do > this, like below (borrowing again from Jos' patch), or are there > other issues I'm not aware of? It would have to be in CPANPLUS::Dist::Build (which is under the module-build group care now as well) -- It's not an elegant solution, and might break if you change any of the internals of M::B (or test::harness), but it beats not having any output at all, since this renders test reports sent to testers.cpan.org for authors who use M::B quite useless :( > use Module::Build; > my $mb = Module::Build->new_from_context; > $mb->dispatch('build'); > > my $out = ''; > { > require IO::String; > local *STDOUT; > my $io = tie( *STDOUT, 'IO::String' ); > eval { $mb->dispatch('test') }; > $out = $io->string_ref; > } > > print $$out; > die $@ if $@; > > > 1. <http://rt.cpan.org/Public/Bug/Display.html?id=9793> -- Jos Boumans "Two rules to success in life: 1. Don't tell people everything you know" --Sassan Tat CPANPLUS http://cpanplus.sf.net |