neilwatson has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Avout, I'm attempting to use TAP::Harness to test CFEngine policy and I'm having trouble creating the final test commands. The following code is supposed to check the TAP output for these two commands:

/usr/bin/cf-agent -D efl_returnszero_csv -Kf ./promises.cf /usr/bin/cf-agent -D efl_returnszero_json -Kf ./promises.cf

The -f switch must have the ./promises.cf argument. When I run prove t/efl_returnszero.t I get this error:

t/efl_returnszero.t .. No subtests run Test Summary Report ------------------- t/efl_returnszero.t (Wstat: 0 Tests: 0 Failed: 0) Parse errors: No plan found in TAP output Files=1, Tests=0, 2 wallclock secs ( 0.03 usr 0.00 sys + 1.54 cusr + 0.04 csys = 1.61 CPU) Result: FAIL

My guess is that the final commands are coming out in a scrambled order resulting in no output, but how can I test that?

#!/usr/bin/perl use strict; use warnings; use Carp; use TAP::Harness; chdir 'test/masterfiles' or croak "Cannot cd to test/masterfiles $!"; my @tests = ( [ './promises.cf', 'using_csv' ], [ './promises.cf', 'using_json' ], ); # Final test command is exec + element from test + arg? my $harness = TAP::Harness->new({ exec => [ qw( /usr/bin/cf-agent -Kf ) ], test_args => { using_csv => [ '-D efl_returnszero_csv' ], using_json => [ '-D efl_returnszero_json' ], }, verbosity => 1, errors => 1, show_count => 1, }); $harness->runtests( @tests );

UPDATE: turns out the test args cannot have white space so

test_args => { using_csv => [ '-D efl_returnszero_csv' ], using_json => [ '-D efl_returnszero_json' ], }, # Must be: test_args => { using_csv => [ '-D', 'efl_returnszero_csv' ], using_json => [ '-D', 'efl_returnszero_json' ], },

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re: Testing non perl app using TAP::Harness
by Anonymous Monk on Aug 07, 2015 at 13:26 UTC

    What do the commands output when run from the command line?

      $ /usr/bin/cf-agent -Kf ./promises.cf -D efl_returnszero_csv R: 1..3 R: ok 1 - Class if /bin/true R: ok 2 - Class if /bin/false R: ok 3 - Is not true

      Neil Watson
      watson-wilson.ca