File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
ament_cmake_xmllint/cmake Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- file (GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.xml" )
15+ # Forces ament_xmllint to consider ament_cmake_xmllint_EXTENSIONS as the given extensions if defined
16+ set (_extensions "xml" )
17+ if (DEFINED ament_cmake_xmllint_EXTENSIONS)
18+ string (REGEX REPLACE "[ \\ *\\ .,]+" ";" _extensions ${ament_cmake_xmllint_EXTENSIONS} )
19+ message (STATUS "Configured xmllint extensions: ${_extensions} " )
20+ endif ()
21+
22+ # Make sure all extensions start with '*.' or add it if not
23+ foreach (_extension ${_extensions} )
24+ string (REGEX MATCH "^\\ *?\\ .?(.+)$" _bare_extension ${_extension} )
25+ list (APPEND _glob_extensions "*.${_bare_extension} " )
26+ endforeach ()
27+
28+ message (DEBUG "Globbing for xml files with extensions: ${_glob_extensions} " )
29+
30+ file (GLOB_RECURSE _source_files FOLLOW_SYMLINKS ${_glob_extensions} )
1631if (_source_files)
32+ message (DEBUG "Found files with extensions: ${_source_files} " )
1733 message (STATUS "Added test 'xmllint' to check XML markup files" )
18- ament_xmllint()
34+ ament_xmllint(EXTENSIONS ${_extensions} )
35+ else ()
36+ message (DEBUG "No files with extensions: ${_extensions} found, skipping test 'xmllint'" )
1937endif ()
Original file line number Diff line number Diff line change 2323# @public
2424#
2525function (ament_xmllint)
26- cmake_parse_arguments (ARG "" "MAX_LINE_LENGTH; TESTNAME" "" ${ARGN} )
26+ cmake_parse_arguments (ARG "" "TESTNAME" "PATHS;EXCLUDE;EXTENSIONS " ${ARGN} )
2727 if (NOT ARG_TESTNAME)
2828 set (ARG_TESTNAME "xmllint" )
2929 endif ()
@@ -35,6 +35,14 @@ function(ament_xmllint)
3535
3636 set (result_file "${AMENT_TEST_RESULTS_DIR} /${PROJECT_NAME} /${ARG_TESTNAME} .xunit.xml" )
3737 set (cmd "${ament_xmllint_BIN} " "--xunit-file" "${result_file} " )
38+
39+ if (ARG_EXTENSIONS)
40+ list (APPEND cmd "--extensions" )
41+ foreach (ext ${ARG_EXTENSIONS} )
42+ list (APPEND cmd "${ext} " )
43+ endforeach ()
44+ endif ()
45+
3846 list (APPEND cmd ${ARG_UNPARSED_ARGUMENTS} )
3947
4048 find_program (xmllint_BIN NAMES "xmllint" )
You can’t perform that action at this time.
0 commit comments