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

Cannot redirect HTML output to a file using TAP::Formatter

by mkhan (Sexton)
on Jun 28, 2011 at 21:45 UTC ( #911859=perlquestion: print w/ replies, xml ) Need Help??
mkhan has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to redirect the output of the generated HTML code but I'm missing something.
Could you help me figure out what?

Code:
use TAP::Harness use IO::Handle; use TAP::Formatter::HTML; use File::Glob::Windows; use TAP::Parser::Aggregator; my $fmt = TAP::Formatter::HTML->new; my @tests = glob( 'te*.pl'); my $harness = TAP::Harness->new( { formatter => $fmt, merge => 1 } ); $fmt->output_file('output.html'); $harness->runtests(@tests);

The output_file function fails with error:
Can't locate object method "output_file" via package "TAP::Formatter::HTML" at tap.pl line 12.

Thanks,
Mohsin Khan

Comment on Cannot redirect HTML output to a file using TAP::Formatter
Download Code
Re: Cannot redirect HTML output to a file using TAP::Formatter
by Illuminatus (Curate) on Jun 28, 2011 at 22:47 UTC
    Are you sure that you're using the latest version of TAP::Formatter::HTML (ie 0.09)? This small code sample runs fine for me:
    #! /usr/bin/perl use strict; use warnings; use TAP::Harness; use TAP::Formatter::HTML; my @tests = glob( 't/*.t' ); # to use a custom formatter: my $fmt = TAP::Formatter::HTML->new; my $my_css; $fmt->css_uris([])->inline_css( $my_css ) ->js_uris(['http://mysite.com/jquery.js', 'http://mysite.com/cust +om.js']) ->inline_js( '$(div.summary).hide()' ); my $harness = TAP::Harness->new({ formatter => $fmt, merge => 1 }); $fmt->output_file( '/tmp/foo.html' );
    If you are running an older version and can't upgrade, perhaps the output_fh accessor is there, and/or the environment variable.

    fnord

      I'm relatively new to this.
      Could you give me an example/sample code on how to use the output_fh accessor?

      Your help is appreciated. Also, I'm not able to install the TAP::Formatter:HTML package using cpanm on Strawberry Perl + Windows. It just hangs at "Building and testing .. ". How do I get around that? :S
        TAP::Formatter::HTML has a large number of dependencies. Run this script:
        #!/usr/bin/perl use strict; use warnings; use CPAN; CPAN::Shell->install( "accessors", "ExtUtils::ParseXS", "Module::CoreList", "Module::Load", "Params::Check", "Module::Load::Conditional", "Locale::Maketext::Simple", "IPC::Cmd", "ExtUtils::CBuilder", "Perl::OSType", "IO::Dir", "Version::Requirements", "Exporter", "CPAN::Meta::YAML", "JSON::PP", "Parse::CPAN::Meta", "CPAN::Meta", "version", "Module::Metadata", "Module::Build", "AppConfig", "File::Temp", "File::Spec", "Scalar::Util", "Template", "MIME::Base64", "Test::More", "URI", "Test::Harness", "TAP::Formatter::HTML");
        Then run this:
        #!/usr/bin/perl use strict; use warnings; use TAP::Harness; use TAP::Formatter::HTML; my $fmt = TAP::Formatter::HTML->new; my @tests = glob('*.t'); my $harness = TAP::Harness->new( { formatter => $fmt, merge => 1 } ); $fmt->output_file('output.html'); $harness->runtests(@tests);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-08-23 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (175 votes), past polls