On 07/08/2015 11:26 AM, Michael Paquier wrote:
> On Wed, Jul 8, 2015 at 6:10 AM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>> * whenever a test case is reported as success/fail.
>
> Just to be sure, does this concern the "ok/not ok" messages printed
> out by each test run? Or is it a custom message that you have in mind?
Right. It would be nice to have the same output that's printed to the
console also in the log.
>> Looking at the manual page of Test::More, it looks like you could change
>> where the perl script's STDOUT and STDERR point to, because Test::More takes
>> a copy of them (when? at program startup I guess..). That would be much more
>> convenient than decorating every run call with ">> logfile".
>
> Hm. There are two types of logs we want to capture:
> 1) stdout and stderr from the subprocesses kicked by IPC::Run::run
> 2) Status messages written in the log file by the process running the tests.
> Perhaps we could redirect the output of stdout and stderr but I think
> that this is going to need an fd open from the beginning of the test
> until the end, with something like that:
> open my $test_logfile_fd, '>>', $test_logfile;
> *STDOUT = $test_logfile_fd;
> *STDERR = $test_logfile_fd;
>
> While that would work on OSX and Linux for sure, I suspect that this
> will not on Windows where two concurrent processes cannot write to the
> same file.
Hmm, as long as you make sure all the processes use the same filehandle,
rather than open the log file separately, I think it should work. But
it's Windows, so who knows..
I came up with the attached, which does that. It also plays some tricks
with perl "tie", to copy the "ok - ..." lines that go to the console, to
the log.
I tried to test that on my Windows system, but I don't have IPC::Run
installed. How did you get that on Windows? Can you test this?
> Also, the output can be correctly captured by just
> appending that to a couple of places:
> [ '>>', $test_logfile, '2>&1']
> And this solution proves to work as well on Windows...
Yeah, but that's tedious.
- Heikki