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

Add gtest_output support #81

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tonka3000
Copy link

This PR add support for gtest_output xml format.

gtest support --gtest_output to save files as xml. An example would be my.exe --gtest_output=xml:myfile.xml. gtest-parallel does not support this option right now, but it would be very practical to have support for it because many CI systems like e.g. GitLab CI support artifact upload to visualize the test results in a project.

How a user can use this option

I've added and --gtest_output option which is very similar to the original one.

Example: --gtest_output xml:myfile.xml

How is it implemented

I save the gtest xml file for every exectuable run in temp files and join them together after all tasks have finished. This way I get the original content of the gtest xml output which be joined together.

Greetings
Michael

@google-cla
Copy link

google-cla bot commented Mar 22, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@tonka3000
Copy link
Author

@googlebot I signed it!

@JensHuthmann
Copy link

The merging of the xml fails, if one of the tests crashes the test itself. Which happens for me with glog and CHECK(...). This creates a SIGABRT. The merge fails because no xml is created for that test.

@philipogorman
Copy link

this would be a great feature for running tests on jenkins.

@tonka3000
Copy link
Author

@JensHuthmann @pbos

I've merged the master branch and resolved the conflicts.

I also skip now files which are empty (0 bytes) when e.g. abort() is called in a test. This is not a great solution because the existence of the test is now fully hidden from the xml file, but I'm not quite sure how to handle it better. The gtest version I use (1.8.x) don't write a xml file when one of the tests send SIGABRT. Not quite sure if more recent version of gtest make a better job here.

Suggestions are welcome.

Greetings
Michael

'''join given files into a single one'''
from xml.dom import minidom

files = [f for f in files if os.path.exists(f) and os.path.getsize(f) > 0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you insert a TODO to revisit how empty files / crashes are handled and highlight that we skip that for now?

Also could we make sure to print a summary of how many tests failed to generate output? I think this may go through list of files before stripping out the !exists/empty ones. It would be OK to print every single failure here I think and not necessarily print x/y tests aborted. Can we get the test name corresponding to the failure as well?

@pbos
Copy link
Collaborator

pbos commented Oct 24, 2022

Sorry for the slow response I've been more busy than I'd like. Can we make sure this error handling is explicit (by comments and printing which tests aborted and that they're therefore not present in the xml output)?

@tonka3000
Copy link
Author

Hi @pbos ,

I will check it (hopefully in the next couple of days).

@mr1sunshine
Copy link

Such a helpful feature!

@tonka3000 I'm just wondering if you had a chance or if you are planning to finish a work on this PR, so it gets merged?

@tonka3000
Copy link
Author

Hey @mr1sunshine ,

never found the time to finish the PR. Work drifted to different technology and I used gtest rarely since the shift.
When somebody want to finish this in the meantime, feel free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants