Conversation
* Added an srunner_set_xml_format function and also an CK_XML_FORMAT_NAME environment variable to select JUnit formatting * Test timings are not supported at this time * Add tests to cover new functionality * Update documentation The implementation was inspired by Glenn Washburn's original patches. references - Original Patches - https://sourceforge.net/p/check/mailman/message/2963561/
|
My CircleCI job for a pet project is using the patched version of check based on these changes. You can see the results files on any given build in https://app.circleci.com/pipelines/github/trevershick/wpp under the tests tab ( a recent build: https://app.circleci.com/pipelines/github/trevershick/wpp/48/workflows/8d0d5d1a-8fc2-4eac-95aa-bae3f84435a5/jobs/48/tests ). I can't guarantee that build will be there when you look though. |
|
@mikkoi Any tips for getting a maintainer to run the workflows? I'd like to contribute more. |
|
Hm. I did not realize that the tests would not run automatically for first-time collaborators. That must be a recent change: On another PR I saw this week there was a "run workflow" button I could click to start the workflows. However, on this PR there is no such button. Does the branch need to be up-to-date with the https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks |
|
Thanks for looking at this @brarcher . I've brought the PR up to date with |
|
Ah, that was is, thanks. The test workflows did run, though a number of them hit test failures. The tests are passing on the master branch, so I don't believe the test failures are pre-existing. |
doc/check.texi
Outdated
| then check will log to both files. In other words logging in plain text and XML | ||
| format simultaneously is supported. | ||
|
|
||
| JUnit Support is also available. It is enabled by a call to |
There was a problem hiding this comment.
Is it "JUnit support" or "JUnit XML support" ?
doc/check.texi
Outdated
|
|
||
| JUnit Support is also available. It is enabled by a call to | ||
| @code{srunner_set_xml_format(CK_XML_FORMAT_JUNIT)} before the tests are run. | ||
| It can also be enabled by environment variable as well. It is enabled by setting the |
There was a problem hiding this comment.
Could combine two sentences this way:
It can also be enabled by setting the environment varaible @code{CK_XML_FORMAT_NAME} to @code{junit}.
Also, if a new environment variable is being added, add a reference here:
https://github.com/libcheck/check/blob/master/doc/check.texi#L2286
doc/check.texi
Outdated
| It can also be enabled by environment variable as well. It is enabled by setting the | ||
| @code{CK_XML_FORMAT_NAME} environment variable to @code{junit}. | ||
|
|
||
| Here is an example of the JUnit xml format: |
| * enum describing the specific XML format used for XML logging | ||
| */ | ||
| enum xml_format { | ||
| CK_XML_FORMAT_UNSPECIFIED, |
There was a problem hiding this comment.
should the unspecified state be the default state? What is the motivation for having an unspecified state? And, if it were unspecified what XML stlye ends up being used?
There was a problem hiding this comment.
CK_XML_FORMAT_UNSPECIFIED is the default value when srunner_create is called. This is in fact what I was missing and why my tests were failing.
srunner_xml_format is used to determine what format to use.
srunner_xml_format will never yield CK_XML_FORMAT_UNSPECIFIED, it will yield only CK_XML_FORMAT_DEFAULT or CK_XML_FORMAT_JUNIT.
The motivation for the unspecified state is that I needed an initial state which was unspecified since the environment variable to set the format only overrides the selected format if it's unspecified. If it were set to 'default', then I couldn't tell if someone had set it explicitly or not.
| * This value can be explicitly set via `srunner_set_xml_format` or can | ||
| * be set via the CK_XML_FORMAT_NAME environment variable. | ||
| * | ||
| * @return CK_XML_FORMAT_DEFAULT unless the format is explicitly set via |
There was a problem hiding this comment.
If another XML style were introduced in the future, the docs here would need to be updated to remove the JUNIT reference (as there would be other possibilities).
Perhaps mention how the environment variable and value set in the code interact instead, so that is more clear. For example, mention that if the environment variable is set then its value is used, otherwise whatever is set in srunner_set_xml_format is used, and the default is CK_XML_FORMAT_DEFAULT.
|
|
||
| // junit is the only value of CK_XML_FORMAT_NAME that will | ||
| // return something other than CK_XML_FORMAT_DEFAULT | ||
| const char *format_name = getenv("CK_XML_FORMAT_NAME"); |
There was a problem hiding this comment.
I think in other places in the code the environment variable takes precedence. Example:
https://github.com/libcheck/check/blob/master/src/check.c#L317
Should that be the case here as well?
There was a problem hiding this comment.
Since it's logging, I made the precedence the same as srunner_xml_fname. This seems sane to me even if it's different than other items. These two should at least agree probably.
src/check_impl.h
Outdated
| List *resultlst; /* List of unit test results */ | ||
| const char *log_fname; /* name of log file */ | ||
| const char *xml_fname; /* name of xml output file */ | ||
| enum xml_format xml_format; |
There was a problem hiding this comment.
there are comments on the other fields, maybe add one for this field too?
src/check_print.c
Outdated
| enum print_output print_mode CK_ATTRIBUTE_UNUSED) | ||
| { | ||
| char status[10]; | ||
| char type[10]; |
There was a problem hiding this comment.
I don't see type used in the function
|
Got a linux box up and going - got a clean test run: |
* JUnit Support -> JUnit XML Support * Combine two sentences in check.texi * xml->XML * Add a line in the environment appendix * Update the xml_format source code header comment * Add a comment to xml_format
|
I just noticed this is still open. I believe I addressed most comments. There are a couple where I attempted to explain my reasoning. |
|
I'd love to see this moving forward. Is there anything I can help with getting that to happen? |

The implementation was inspired by Glenn Washburn's original patches.
references -
Original Patches - https://sourceforge.net/p/check/mailman/message/2963561/
Issue #334