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 SKIP_RETURN_CODE argument to ament_add_test #264

Merged
merged 2 commits into from Jul 15, 2020
Merged

Conversation

cottsay
Copy link
Contributor

@cottsay cottsay commented Jul 15, 2020

This makes the run_test.py wrapper aware of the SKIP_RETURN_CODE property on CTest tests. In the existing implementation, the wrapper detects that no result file was generated and overrides the special return code coming from the test, making the the CTest feature fail completely.

This change makes the wrapper script aware of the special return code, and when detected, will write a 'skipped' result file instead of a 'failed' result file, and pass along the special return code as-is. Now the gtest result and the ctest results both show the test as 'skipped' when the special return flag is used.

Note that none of this behavior is enabled by default, which is important because we wouldn't want a test to fail and return a code which we've decided is the special 'skip' return code. Only tests which are aware of this feature should use it.

This makes the `run_test.py` wrapper aware of the `SKIP_RETURN_CODE`
property on CTest tests. In the existing implementation, the wrapper
detects that no result file was generated and overrides the special
return code coming from the test, making the the CTest feature fail
completely.

This change makes the wrapper script aware of the special return code,
and when detected, will write a 'skipped' result file instead of a
'failed' result file, and pass along the special return code as-is. Now
the gtest result and the ctest results both show the test as 'skipped'
when the special return flag is used.

Note that none of this behavior is enabled by default, which is
important because we wouldn't want a test to fail and return a code
which we've decided is the special 'skip' return code. Only tests which
are aware of this feature should use it.

Signed-off-by: Scott K Logan <logans@cottsay.net>
@cottsay cottsay added enhancement New feature or request in review Waiting for review (Kanban column) labels Jul 15, 2020
@cottsay cottsay self-assigned this Jul 15, 2020
Comment on lines 90 to 95
if(ARG_SKIP_TEST)
list(APPEND cmd_wrapper "--skip-test")
set(ARG_SKIP_RETURN_CODE 0)
elseif(ARG_SKIP_RETURN_CODE)
list(APPEND cmd_wrapper "--skip-return-code" "${ARG_SKIP_RETURN_CODE}")
endif()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify this elseif(), unconditionally skipping a test using SKIP_TEST overrides the return code behavior because we'll never invoke the test and therefore will never get the magic return code to skip it because we'll ALWAYS skip it. However, since we know that we'll always skip it, setting the SKIP_RETURN_CODE to 0 makes CTest invoke the test so that the wrapper can write the gtest result, while still reporting the test as skipped in it's own console output and result file.

Signed-off-by: Scott K Logan <logans@cottsay.net>
@cottsay cottsay merged commit cba4e09 into master Jul 15, 2020
@delete-merged-branch delete-merged-branch bot deleted the skip_return_code branch July 15, 2020 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in review Waiting for review (Kanban column)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants