mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
tests: add test for duplicate headers
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
2298846fef
commit
67e0ceb48d
@ -9,6 +9,11 @@ if (PYTHON_DEFAULT_AVAILABLE)
|
|||||||
add_test (NAME check_file_encoding COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
|
add_test (NAME check_file_encoding COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/check_file_encoding.py
|
${CMAKE_CURRENT_SOURCE_DIR}/check_file_encoding.py
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src)
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
||||||
|
# Check for duplicate headers
|
||||||
|
add_test (NAME check_duplicate_headers COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/check_duplicate_headers.py
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
endif (PYTHON_DEFAULT_AVAILABLE)
|
endif (PYTHON_DEFAULT_AVAILABLE)
|
||||||
|
|
||||||
# Add some java tests
|
# Add some java tests
|
||||||
|
27
tests/check_duplicate_headers.py
Normal file
27
tests/check_duplicate_headers.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import os
|
||||||
|
|
||||||
|
class DuplicateHeadersTests(unittest.TestCase):
|
||||||
|
'''Checks for duplicate header names. Since all sensor headers get
|
||||||
|
installed as part of the API, duplicate headers can cause bad linking,
|
||||||
|
namespace class collisions and so on.'''
|
||||||
|
|
||||||
|
def test_duplicate_headers(self):
|
||||||
|
# Keep a list of all the header files in library
|
||||||
|
header_files = []
|
||||||
|
|
||||||
|
# Recusively search cwd for headers and add them to the list
|
||||||
|
for root, dirs, files in os.walk(os.curdir):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith(('.h', '.hpp', '.hxx')):
|
||||||
|
header_files.append(file)
|
||||||
|
|
||||||
|
# Test for duplicates
|
||||||
|
duplicates = len(header_files) - len(set(header_files))
|
||||||
|
self.assertEqual(duplicates, 0,
|
||||||
|
"\nDuplicate headers: %d\n" % duplicates)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user