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 public interface for XmlUnitTestResultPrinter #4402

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LittleFox94
Copy link

Allowing custom gtest_main implementations to instantiate the XmlUnitTestResultPrinter with either a given file path or any other kind of std::ostream to write to.

This is useful for e.g. embedded cases where an XML report is still wanted, but not file system is available, by instantiating with a std::stringstream and delivering the data via any custom mean.

Related to #1930

This clearly needs some more polishing (e.g. docs in the header), but before I'll do the chores, I'd like some feedback :)

Allowing custom gtest_main implementations to instantiate the
XmlUnitTestResultPrinter with either a given file path or any other kind
of std::ostream to write to.

This is useful for e.g. embedded cases where an XML report is still
wanted, but not file system is available, by instantiating with a
std::stringstream and delivering the data via any custom mean.

Related to google#1930
@google-cla
Copy link

google-cla bot commented Oct 29, 2023

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

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Make XmlUnitTestResultPrinter usable when GTEST_HAS_FILE_SYSTEM=0,
though this should probably be another class extending
XmlUnitTestResultPrinter instead - but feels like the preprocessor
feature flag logic matches the existing code base.
@LittleFox94
Copy link
Author

For some context, this is an example how that might be used:
https://praios.lf-net.org/littlefox/lf-os_amd64/-/blame/d499372dc4d35ddc468027955006f4af3edcebe8/src/runtime-tests/gtest_main.cxx#L19-21

(this is not merged to my main yet, so I hope that commit hash stays non-GC'd long enough to be useful ^^')

@dinord
Copy link
Collaborator

dinord commented Nov 13, 2023

Making this a public interface generally sounds good to me.

void ListTestsMatchingFilter(const std::vector<TestSuite*>& test_suites);

private:
#if GTEST_HAS_FILE_SYSTEM
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think we could have a separate interface for "output sink"?

Perhaps we could even turn XmlUnitTestResultPrinter into an abstract class, and have a FileXmlUnitTestResultPrinter vs. a StreamXmlUnitTestResultPrinter?

Copy link
Author

Choose a reason for hiding this comment

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

what do you think about having XmlUnitTestResultPrinter be the one that prints to a stream and FileXmlUnitTestResultPrinter inheriting from that, opening a file stream to give to the base?

I don't think the additional abstract base, from which both Stream.. and File.. inherit is useful here

@LittleFox94
Copy link
Author

Making this a public interface generally sounds good to me.

thank you for that feedback - sorry for getting back here this late, will look into tidying this up, hopefully soon :)

Copy link

@byt3n33dl3 byt3n33dl3 left a comment

Choose a reason for hiding this comment

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

Just want to see (XmlUnitTestResultPrinter)

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.

3 participants