Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix duration_ms to be correct #38

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tap2junit/__main__.py
Original file line number Diff line number Diff line change
@@ -30,8 +30,7 @@ def extract_test_info_from_description(description):

def map_yaml_to_junit(test):
yaml = test.yaml or {}
# Even though the name is `duration_ms` the value is in seconds.
elapsed_sec = yaml.get("duration_ms", None)
elapsed_sec = yaml.get("duration_ms", 0) / 1000 or None
(test_class, test_name) = extract_test_info_from_description(test.description)
t = TestCase(test_name, classname=test_class, elapsed_sec=elapsed_sec)
if test.result == "ok":
18 changes: 9 additions & 9 deletions test/output/test-nested.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites disabled="0" errors="0" failures="2" tests="7" time="10.541631082">
<testsuite disabled="0" errors="0" failures="2" name="test/fixtures/test-nested" skipped="0" tests="7" time="10.541631082" hostname="{HOSTNAME}">
<testcase name="- top level 1" time="0.340575"/>
<testcase name="- top level 2" time="0.303039"/>
<testcase name="- nested 1" time="2.367745"/>
<testcase name="- nested 2" time="2.332324">
<testsuites disabled="0" errors="0" failures="2" tests="7" time="0.010541631081999998">
<testsuite disabled="0" errors="0" failures="2" name="test/fixtures/test-nested" skipped="0" tests="7" time="0.010541631081999998" hostname="{HOSTNAME}">
<testcase name="- top level 1" time="0.000341"/>
<testcase name="- top level 2" time="0.000303"/>
<testcase name="- nested 1" time="0.002368"/>
<testcase name="- nested 2" time="0.002332">
<failure type="failure" message=" (0)">
---
code: ERR_TEST_FAILURE
@@ -14,7 +14,7 @@ failureType: cancelledByParent
...
</failure>
</testcase>
<testcase name="- nested" time="2.367871">
<testcase name="- nested" time="0.002368">
<failure type="failure" message=" (0)">
---
code: ERR_TEST_FAILURE
@@ -25,7 +25,7 @@ failureType: fail
</failure>
<system-err>['# Subtest: top level 4']</system-err>
</testcase>
<testcase name="- top level 4" time="0.340575"/>
<testcase name="- parent" time="2.489501"/>
<testcase name="- top level 4" time="0.000341"/>
<testcase name="- parent" time="0.002490"/>
</testsuite>
</testsuites>
4,744 changes: 2,372 additions & 2,372 deletions test/output/test.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/output/test2.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites disabled="0" errors="0" failures="1" tests="1" time="1.711">
<testsuite disabled="0" errors="0" failures="1" name="test/fixtures/test2" skipped="0" tests="1" time="1.711" hostname="{HOSTNAME}">
<testcase name="test-accessor-properties" time="1.711000" classname="parallel">
<testsuites disabled="0" errors="0" failures="1" tests="1" time="0.001711">
<testsuite disabled="0" errors="0" failures="1" name="test/fixtures/test2" skipped="0" tests="1" time="0.001711" hostname="{HOSTNAME}">
<testcase name="test-accessor-properties" time="0.001711" classname="parallel">
<failure type="1" message="fail (1)">
---
duration_ms: 1.711
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no change here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this includes raw TAP - so it is expected to be milliseconds, but jUnit time attribute is expected as seconds

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. No wonder that everyone is confused.

4,738 changes: 2,369 additions & 2,369 deletions test/output/test3.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/output/yaml-block.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites disabled="0" errors="0" failures="1" tests="1" time="4.758">
<testsuite disabled="0" errors="0" failures="1" name="test/fixtures/yaml-block" skipped="0" tests="1" time="4.758" hostname="{HOSTNAME}">
<testcase name="test_runner_describe_it" time="4.758000" classname="message">
<testsuites disabled="0" errors="0" failures="1" tests="1" time="0.004758">
<testsuite disabled="0" errors="0" failures="1" name="test/fixtures/yaml-block" skipped="0" tests="1" time="0.004758" hostname="{HOSTNAME}">
<testcase name="test_runner_describe_it" time="0.004758" classname="message">
<failure type="1" message="fail (1)">
---
duration_ms: 4.758
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no change here?