-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ament_(cmake_)xmllint packages (#104)
* add ament_(cmake_)xmllint packages * consider xsi:noNamespaceSchemaLocation of root tag
- Loading branch information
1 parent
d449f43
commit 489774b
Showing
15 changed files
with
605 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(ament_cmake_xmllint NONE) | ||
|
||
find_package(ament_cmake_core REQUIRED) | ||
find_package(ament_cmake_test REQUIRED) | ||
|
||
ament_package( | ||
CONFIG_EXTRAS "ament_cmake_xmllint-extras.cmake" | ||
) | ||
|
||
install( | ||
DIRECTORY cmake | ||
DESTINATION share/${PROJECT_NAME} | ||
) | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_cmake_copyright REQUIRED) | ||
ament_copyright() | ||
|
||
find_package(ament_cmake_lint_cmake REQUIRED) | ||
ament_lint_cmake() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2014-2018 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# copied from ament_cmake_xmllint/ament_cmake_xmllint-extras.cmake | ||
|
||
find_package(ament_cmake_test QUIET REQUIRED) | ||
|
||
include("${ament_cmake_xmllint_DIR}/ament_xmllint.cmake") | ||
|
||
ament_register_extension("ament_lint_auto" "ament_cmake_xmllint" | ||
"ament_cmake_xmllint_lint_hook.cmake") |
19 changes: 19 additions & 0 deletions
19
ament_cmake_xmllint/cmake/ament_cmake_xmllint_lint_hook.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2015-2018 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
file(GLOB_RECURSE _source_files FOLLOW_SYMLINKS "*.xml") | ||
if(_source_files) | ||
message(STATUS "Added test 'xmllint' to check XML markup files") | ||
ament_xmllint() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2014-2018 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# | ||
# Add a test to check XML files for validity with xmllint. | ||
# | ||
# :param TESTNAME: the name of the test, default: "xmllint" | ||
# :type TESTNAME: string | ||
# :param ARGN: the files or directories to check | ||
# :type ARGN: list of strings | ||
# | ||
# @public | ||
# | ||
function(ament_xmllint) | ||
cmake_parse_arguments(ARG "" "MAX_LINE_LENGTH;TESTNAME" "" ${ARGN}) | ||
if(NOT ARG_TESTNAME) | ||
set(ARG_TESTNAME "xmllint") | ||
endif() | ||
|
||
find_program(ament_xmllint_BIN NAMES "ament_xmllint") | ||
if(NOT ament_xmllint_BIN) | ||
message(FATAL_ERROR "ament_xmllint() could not find program 'ament_xmllint'") | ||
endif() | ||
|
||
set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml") | ||
set(cmd "${ament_xmllint_BIN}" "--xunit-file" "${result_file}") | ||
list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS}) | ||
|
||
find_program(xmllint_BIN NAMES "xmllint") | ||
|
||
if(NOT xmllint_BIN) | ||
if(${CMAKE_VERSION} VERSION_LESS "3.8.0") | ||
message(WARNING "WARNING: 'xmllint' not found, skipping xmllint test creation") | ||
return() | ||
endif() | ||
endif() | ||
|
||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_xmllint") | ||
ament_add_test( | ||
"${ARG_TESTNAME}" | ||
COMMAND ${cmd} | ||
OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_xmllint/${ARG_TESTNAME}.txt" | ||
RESULT_FILE "${result_file}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
set_tests_properties( | ||
"${ARG_TESTNAME}" | ||
PROPERTIES | ||
LABELS "xmllint;linter" | ||
) | ||
if(NOT xmllint_BIN) | ||
set_tests_properties( | ||
"${ARG_TESTNAME}" | ||
PROPERTIES | ||
DISABLED TRUE | ||
) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
ament_xmllint | ||
============= | ||
|
||
Checks XML markup files using `xmllint <http://xmlsoft.org/xmllint.html>`_. | ||
Files with the following extensions are being considered: ``.xml``. | ||
|
||
|
||
How to run the check from the command line? | ||
------------------------------------------- | ||
|
||
The command line tool is provided by the package `ament_xmllint | ||
<https://github.com/ament/ament_lint>`_. | ||
|
||
|
||
How to run the check from within a CMake ament package as part of the tests? | ||
---------------------------------------------------------------------------- | ||
|
||
``package.xml``: | ||
|
||
.. code:: xml | ||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
<test_depend>ament_cmake_xmllint</test_depend> | ||
``CMakeLists.txt``: | ||
|
||
.. code:: cmake | ||
find_package(ament_cmake REQUIRED) | ||
if(BUILD_TESTING) | ||
find_package(ament_cmake_xmllint REQUIRED) | ||
ament_xmllint() | ||
endif() | ||
When running multiple linters as part of the CMake tests the documentation of | ||
the package `ament_lint_auto <https://github.com/ament/ament_lint>`_ might | ||
contain some useful information. | ||
|
||
The documentation of the package `ament_cmake_test | ||
<https://github.com/ament/ament_cmake>`_ provides more information on testing | ||
in CMake ament packages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="2"> | ||
<name>ament_cmake_xmllint</name> | ||
<version>0.5.2</version> | ||
<description> | ||
The CMake API for ament_xmllint to check XML file using xmmlint. | ||
</description> | ||
<maintainer email="[email protected]">Dirk Thomas</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake_core</buildtool_depend> | ||
<buildtool_depend>ament_cmake_test</buildtool_depend> | ||
|
||
<buildtool_export_depend>ament_cmake_test</buildtool_export_depend> | ||
<buildtool_export_depend>ament_xmllint</buildtool_export_depend> | ||
|
||
<test_depend>ament_cmake_copyright</test_depend> | ||
<test_depend>ament_cmake_lint_cmake</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.