Howdy,
This is for Any Armstrong, primarily, but someone else might know the
answer, or be interested, anyway.
I added xUnit-style test programming to pgTAP recently. What this
means is that, rather than putting tests in a .sql test file, a
developer can define a function that returns the results of tests
(TAP, basically). They can then call a single function to run the
tests, like so:
psql -c 'SELECT * FROM tap.runtest()';
This call no_plan(), finds the test functions, runs them, then outputs
the test results.
Now, I use TAP::Harness in the pg_prove script that ships with pgTAP
to run scripts. It specifies that all test scripts will be run through
psql. So a user could create a single test that just call the above
command, but what I'd like to do is add an option to pg_prove so that
pg_prove can call that function and no test scripts need even exist.
It looks like I could have pg_prove run the tests, collect all the
output, and pass it to TAP::Harness as a string, but this delays the
output until after all the tests are done running. I'd rather have it
output as a stream as test are run, just as if a script was installed.
So my question is: Is there a way to tell TAP::Harness->runtests, and
therefore TAP::Parser, since that's what gets the arguments to
runtests(), to execute a command without having a file argument?
Ideally, it'd look something like this:
TAP::Harness->new({
verbosity => $opts->{verbose} || $ENV{TEST_VERBOSE},
timer => $opts->{timer},
color => $opts->{color},
exec => ['psql', '-c' 'SELECT * FROM tap.runtest()'],
})->runtests();
The issue with this is that, currently, no tests will be run because
nothing is passed to runtests()! Is there something I could pass that
runtest() wouldn't stat or parse but would run the `exec` command
anyway?
Thanks!
David