-
Notifications
You must be signed in to change notification settings - Fork 42
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 GoogleTest support #203
base: master
Are you sure you want to change the base?
Conversation
47d9d18
to
06f5045
Compare
faf4eac
to
faea701
Compare
🎉
|
Hmmm... that's strange. I'll see if I can reproduce that. |
faea701
to
6e6a8b2
Compare
"kyua report" still give me the same error even with your newest patch. |
I suspect it's one of the cases involving the skipped or disabled status. Need to do some more digging here with your branch.. |
As I suspected, the issue is that GTEST_SKIP is being called without a reason:
Wait... the fact that GTEST_SKIP is not properly emitting any messages is a bug in our (FreeBSD base) version of googletest too. Argh... |
Hmmm... that didn't work :/...
|
Shouldn't that be allowed? If you don't supply a reason to |
That’s what I’m trying to implement as a workaround, but it’s a waste of space on disk. |
Ok. I'm starting to understand where the issue's coming from:
|
Well! It looks like
|
And... magic!
|
633e3ee
to
ff52f04
Compare
@jmmv: I realize this is a large change, but I was wondering if there's a way that I could work with you to get this change reviewed and into the kyua project? I'm asking, because there's a chance that I might get a job in the next few months which will invalidate my individual CLA. Plus, this change makes it markably easier to run Google Test programs in FreeBSD with Kyua. |
@jmmv: ping? |
@jmmv could you please review this change? If this gets merged and released before I finish my fusefs work, it will change how I organize the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the long delay. This PR is huge and requires a big time and mental investment to get into -- which I had failed to find the time for until now.
The general structure, considering that this is mostly a copy/paste of what other interfaces do, seems fine, so at least that helped with the initial review.
For iterations on this PR, I'd like to ask that you don't amend the commit. Please push iterations as new commits (with garbage descriptions if you like, and without force-pushing) so that GitHub can show incremental diffs. Once we are done, we will just squash all changes into one commit right before merge.
One general question: somewhere you mention that you capture the stdout of the test. What happens with stderr?
This change does the following things: * Leverages utils/cmdline/*, instead of reinventing the wheel. * Consolidates googletest_results tests/setting for clarity. * Eliminates an unnecessary variable/comments. * Removes some duplicative TODOs/fixes TODO comment formatting. * Inlines temporary variables where possible/sensible. * Moves global variables into the anonymous global namespace. * Localizes the variable initialization near its use. * Adds more helpful comments above potentially obfuscated code. * Use list/set initialization instead of using the equivalent unrolled version with `.insert()`/`.push_back()`. * Fix indentation. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay for GitHub. I can only see a few of the comments when I click on "View changes". Sending replies for those now. Hopefully I can find the other discussions later...
38b7189
to
fa43d07
Compare
This change does the following things: * Leverages utils/cmdline/*, instead of reinventing the wheel. * Consolidates googletest_results tests/setting for clarity. * Eliminates an unnecessary variable/comments. * Removes some duplicative TODOs/fixes TODO comment formatting. * Inlines temporary variables where possible/sensible. * Moves global variables into the anonymous global namespace. * Localizes the variable initialization near its use. * Adds more helpful comments above potentially obfuscated code. * Use list/set initialization instead of using the equivalent unrolled version with `.insert()`/`.push_back()`. * Fix indentation. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
fa43d07
to
07a6708
Compare
* Use initializer with std::map instead of initializing by hand. * Fix method definition indentation. * const poison some variables and inline where possible, eliminating need for unnecessary intermediate values. * Eliminate obfuscated proposed solution in `engine::googletest_result::apply` and deduplicate code by using a lambda to check the failed vs !failed case when checking the exit status. * Remove superfluous parentheses. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
@jmmv: ping..? |
@emaste: given the lack of feedback in this PR, I think it's time to consider officially forking atf/kyua/lutok into a FreeBSD-org managed repo and install the ports from that repo. I'll reach out to you soon about this. |
This change does the following things: * Leverages utils/cmdline/*, instead of reinventing the wheel. * Consolidates googletest_results tests/setting for clarity. * Eliminates an unnecessary variable/comments. * Removes some duplicative TODOs/fixes TODO comment formatting. * Inlines temporary variables where possible/sensible. * Moves global variables into the anonymous global namespace. * Localizes the variable initialization near its use. * Adds more helpful comments above potentially obfuscated code. * Use list/set initialization instead of using the equivalent unrolled version with `.insert()`/`.push_back()`. * Fix indentation. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
* Use initializer with std::map instead of initializing by hand. * Fix method definition indentation. * const poison some variables and inline where possible, eliminating need for unnecessary intermediate values. * Eliminate obfuscated proposed solution in `engine::googletest_result::apply` and deduplicate code by using a lambda to check the failed vs !failed case when checking the exit status. * Remove superfluous parentheses. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
1f9eaea
to
b99bf61
Compare
Now that this is done, is there any chance this PR could be rebased and landed? The lack of googletest support in kyua bit me recently: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281100 |
@ngie-eign do you have time to pick this back up? |
I'm working on it, but for the sake of getting a new release out sooner with all of the changes in the backlog, I'll be targeting the effort at 0.14. |
b99bf61
to
52ae4ed
Compare
This change adds fine grained execution of GoogleTest framework-based test programs. First, the GoogleTest test is executed with `--gtest_list_tests`. Next, based on the output from `--gtest_list_tests`, the testcases are run individually. Finally, the output from each unique testcase is scraped and digested by Kyua in a format that Kyua supports. The output from each unique testcase is based on the standard output it provides, per the test output protocol defined in the GoogleTest docs on github [1], [2], and instrumented via various demo programs I created, which can be found on GitHub [here](https://github.com/ngie-eign/scratch/tree/main/programming/c++/gtest). This is initial framework integration. There're additional improvements that can be made by leveraging either the JSON or XML structured output format, instead of scraping standard output using beginning and ending sentinels to search for regular expressions. In order to do that though without reinventing the wheel, Kyua would need to rely on an external JSON or XML library. This test interface supports fine grained execution of test programs like the ATF test interface, but matches behavior of plain/TAP interfaces by instead supporting metadata passing via `$TEST_ENV_` prefixed environment variables. This support adds additional tests for verifying pass, fail, skip (available in GoogleTest 1.9.0+), and disabled result determination, using mock output and a mock test program (`engine/googletest_helpers`), for parity with other test formats (ATF, plain, TAP). The helper test program purposely avoids relying on `getopt_long*` for portability reasons, and the GoogleTest test infrastructure, in order to limit Kyua's dependencies. As part of this change, `store/read_transaction.cpp` needed to support optional reasons provided with skip results. While it's bad form to omit test results with tests, providing a reason is optional with GoogleTest, and unfortunately not all portions of the test framework output a reason when `GTEST_SKIP()` is called. See the issue in [3] for one such example issue when `GTEST_SKIP()` is called from SetUp test fixtures. 1. https://github.com/google/googletest/blob/main/docs/primer.md 2. https://github.com/google/googletest/blob/main/docs/advanced.md 3. google/googletest#2208 Signed-off-by: Enji Cooper <ngie@FreeBSD.org>
52ae4ed
to
30f0010
Compare
I should add conditional testing with GoogleTest enabled in a later revision of Kyua (after this feature is introduced). I don't feel comfortable not having actual framework-related tests integrated into the end-to-end testing of kyua (seems ripe for breakage later and increased maintenance overhead). |
This change adds fine grained execution of GoogleTest framework-based test
programs.
First, the GoogleTest test is executed with
--gtest_list_tests
. Next,based on the output from
--gtest_list_tests
, the testcases are runindividually. Finally, the output from each unique testcase is scraped
and digested by Kyua in a format that Kyua supports.
The output from each unique testcase is based on the standard output it
provides, per the test output protocol defined in the GoogleTest docs on
github [1], [2], and instrumented via various demo programs I created,
which can be found on GitHub here.
This is initial framework integration. There're additional improvements that
can be made by leveraging either the JSON or XML structured output format,
instead of scraping standard output using beginning and ending sentinels to
search for regular expressions. In order to do that though without reinventing
the wheel, Kyua would need to rely on an external JSON or XML library.
This test interface supports fine grained execution of test programs
like the ATF test interface, but matches behavior of plain/TAP interfaces by
instead supporting metadata passing via
$TEST_ENV_
prefixed environmentvariables.
This support adds additional tests for verifying pass, fail, skip (available in
GoogleTest 1.9.0+), and disabled result determination, using mock output and a
mock test program (
engine/googletest_helpers
), for parity with other testformats (ATF, plain, TAP). The helper test program purposely avoids relying on
getopt_long*
for portability reasons, and the GoogleTest test infrastructure,in order to limit Kyua's dependencies.
As part of this change,
store/read_transaction.cpp
needed to supportoptional reasons provided with skip results. While it's bad form to omit
test results with tests, providing a reason is optional with GoogleTest, and
unfortunately not all portions of the test framework output a reason when
GTEST_SKIP()
is called. See the issue in [3] for one such example issue whenGTEST_SKIP()
is called from SetUp test fixtures.GTEST_SKIP() << {message}
doesn't output message when executed from SetUp() fixtures google/googletest#2208Signed-off-by: Enji Cooper ngie@FreeBSD.org