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

only clean the test results of the current project #738

Merged
merged 2 commits into from
May 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cmake/test/remove_test_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python

from __future__ import print_function

import argparse
import os
import sys


def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser(
description='Remove all test result files found within a given path.')
parser.add_argument('path', help='The path to recursively process')
args = parser.parse_args(argv)

print("Removing test result files from '%s'" % os.path.abspath(args.path))
if not os.path.exists(args.path):
return 0

for dirpath, dirnames, filenames in os.walk(args.path):
# do not recurse into folders starting with a dot
dirnames[:] = [d for d in dirnames if not d.startswith('.')]
for filename in [f for f in filenames if f.endswith('.xml')]:
filename_abs = os.path.join(dirpath, filename)
print("- removing '%s'" % filename_abs)
os.remove(filename_abs)

return 0


if __name__ == '__main__':
sys.exit(main())
11 changes: 8 additions & 3 deletions cmake/test/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ if(NOT TARGET run_tests)
add_custom_target(run_tests)
endif()

# create target to clean test results
# create target to clean all test results
if(NOT TARGET clean_test_results)
add_custom_target(clean_test_results
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CATKIN_TEST_RESULTS_DIR})
COMMAND ${PYTHON_EXECUTABLE} "${catkin_EXTRAS_DIR}/test/remove_test_results.py" "${CATKIN_TEST_RESULTS_DIR}")
endif()
# create target to clean project specific test results
if(NOT TARGET clean_test_results_${PROJECT_NAME})
add_custom_target(clean_test_results_${PROJECT_NAME}
COMMAND ${PYTHON_EXECUTABLE} "${catkin_EXTRAS_DIR}/test/remove_test_results.py" "${CATKIN_TEST_RESULTS_DIR}/${PROJECT_NAME}")
endif()

#
Expand Down Expand Up @@ -140,5 +145,5 @@ function(catkin_run_tests_target type name xunit_filename)
add_custom_target(_run_tests_${PROJECT_NAME}_${type}_${name}
COMMAND ${cmd})
add_dependencies(_run_tests_${PROJECT_NAME}_${type} _run_tests_${PROJECT_NAME}_${type}_${name})
add_dependencies(_run_tests_${PROJECT_NAME}_${type}_${name} clean_test_results tests ${_testing_DEPENDENCIES})
add_dependencies(_run_tests_${PROJECT_NAME}_${type}_${name} clean_test_results_${PROJECT_NAME} tests ${_testing_DEPENDENCIES})
endfunction()