Skip Menu |

This queue is for tickets about the TAP-Formatter-JUnit CPAN distribution.

Report information
The Basics
Id: 53927
Status: resolved
Priority: 0/
Queue: TAP-Formatter-JUnit

People
Owner: GTERMARS [...] cpan.org
Requestors: marca [...] yahoo-inc.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Attachments


CC: Inna Brodkin <innab [...] yahoo-inc.com>, Sundar Rajagopalan <sundarr [...] yahoo-inc.com>, Anirban Kundu <akundu [...] yahoo-inc.com>, Mike Schilli <mschilli [...] yahoo-inc.com>
Subject: Times reported by TAP-Formatter-JUnit-0.06 for individual test cases in a .t file are incorrect
Date: Fri, 22 Jan 2010 15:42:50 -0800
To: "bug-TAP-Formatter-JUnit [...] rt.cpan.org" <bug-TAP-Formatter-JUnit [...] rt.cpan.org>
From: Marc Abramowitz <marca [...] yahoo-inc.com>
Hi Graham, Great module. Thanks for writing it! Like yourself, we are using it so that we can integrate Perl test results into Hudson builds. I originally tried using TAP::Harness::JUnit, but that module doesn't support accurate timing per test case, since it doesn't deal with individual lines of TAP output. I did, however, run into a small problem with the timing reporting in TAP-Formatter-JUnit-0.06. Here's a test that illustrates that the time reported for test case number x is actually the time for test case number x + 1. $ cat t/TestDelays.t; prove --timer --formatter TAP::Formatter::JUnit use Test::More tests => 4; sleep(0); ok(1, 'After sleeping for 0 seconds'); sleep(2); ok(2, 'After sleeping for 2 seconds'); sleep(3); ok(3, 'After sleeping for 3 seconds'); sleep(4); ok(4, 'After sleeping for 4 seconds'); <testsuites> <testsuite failures="0" errors="0" time="9.02368998527527" tests="4" name="TestDelays_t"> <testcase time="2.01857495307922" name="1 - After sleeping for 0 seconds"></testcase> <testcase time="3.00161695480347" name="2 - After sleeping for 2 seconds"></testcase> <testcase time="4.00286602973938" name="3 - After sleeping for 3 seconds"></testcase> <testcase time="0.000725984573364258" name="4 - After sleeping for 4 seconds"></testcase> <system-out><![CDATA[1..4 ok 1 - After sleeping for 0 seconds ok 2 - After sleeping for 2 seconds ok 3 - After sleeping for 3 seconds ok 4 - After sleeping for 4 seconds ]]></system-out> <system-err></system-err> </testsuite> If I change the sleep(0) above to a sleep(1), then the output is: <testsuites> <testsuite failures="0" errors="0" time="10.0256741046906" tests="4" name="TestDelays_t"> <testcase time="3.02052903175354" name="1 - After sleeping for 1 seconds"></testcase> <testcase time="3.00264096260071" name="2 - After sleeping for 2 seconds"></testcase> <testcase time="4.00192308425903" name="3 - After sleeping for 3 seconds"></testcase> <testcase time="0.000674962997436523" name="4 - After sleeping for 4 seconds"></testcase> <system-out><![CDATA[1..4 ok 1 - After sleeping for 1 seconds ok 2 - After sleeping for 2 seconds ok 3 - After sleeping for 3 seconds ok 4 - After sleeping for 4 seconds ]]></system-out> <system-err></system-err> </testsuite> This is similar to the previous case in that the times are shifted by 1, but in this case the first time reported is the time for the 2nd test case + 1 second. I'm attaching a patch for the Session.pm file in TAP-Formatter-JUnit-0.06 which fixes the problem for me. With this patch, I get the following output for the second case I mentioned: <testsuites> <testsuite failures="0" errors="0" time="10.0242660045624" tests="4" name="TestDelays_t"> <testcase time="1.00341320037842" name="1 - After sleeping for 1 seconds"></testcase> <testcase time="2.00243878364563" name="2 - After sleeping for 2 seconds"></testcase> <testcase time="3.0014500617981" name="3 - After sleeping for 3 seconds"></testcase> <testcase time="4.00225710868835" name="4 - After sleeping for 4 seconds"></testcase> <system-out><![CDATA[1..4 ok 1 - After sleeping for 1 seconds ok 2 - After sleeping for 2 seconds ok 3 - After sleeping for 3 seconds ok 4 - After sleeping for 4 seconds ]]></system-out> <system-err></system-err> </testsuite> </testsuites> I hope that this patch helps you and thanks again for a great module! -Marc
Download TAP-Formatter-JUnit_times.patch.zip
application/octet-stream 990b

Message body not shown because it is not plain text.

Marc, many thanks for the patch. Greatly appreciated. I've had a look at the patch here and would like to spend a bit more time with it before committing/releasing it; although it looks like it works great for helping address the offset problem, it has trouble working with TAP streams created with prove's "--merge" option. When run with "--merge", STDOUT+STDERR
Argh! Fat fingered and submitted before I was done. Doh! Let me try this again.... When run with "--merge", STDOUT+STDERR are interleaved together and this in turn throws off the timing calculations. If you have any "diag" statements between two tests, the timing you get for the test after the "diag" is "from diag to test", not "from test to test". Seeing your patch, though, has given me some ideas on how to try to approach this to see if I can't find a better way to handle this. Bear with me while I poke at this a bit further, and we'll get this fixed up.
Fixed in TAP-Formatter-JUnit 0.07. *Many* thanks for providing the patch Marc! Managed to get things worked out so that it handles timings correctly whether or not we've got "merged" output or not, as well as dealing with the idiosynchracies of whether or not the test had an initial "plan" or not. Enjoy!