Skip to content

Commit 3e7ee6c

Browse files
committed
add auto-naming of unit test suites
1 parent c356f1f commit 3e7ee6c

File tree

8 files changed

+12
-27
lines changed

8 files changed

+12
-27
lines changed

UNITTESTS/CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,17 @@ foreach(testfile ${unittest-file-list})
147147
# Get source files
148148
include("${testfile}")
149149

150-
if(TEST_SUITE_NAME)
151-
set(TEST_SUITES ${TEST_SUITES} ${TEST_SUITE_NAME})
152-
else()
153-
message(FATAL_ERROR "No TEST_SUITE_NAME found in test file. Add it to ${testfile}.")
154-
endif()
150+
get_filename_component(TEST_SUITE_DIR ${testfile} DIRECTORY)
151+
152+
file(RELATIVE_PATH
153+
TEST_SUITE_NAME # output
154+
${PROJECT_SOURCE_DIR} # root
155+
${TEST_SUITE_DIR} #abs dirpath
156+
)
157+
158+
string(REGEX REPLACE "/|\\\\" "-" TEST_SUITE_NAME ${TEST_SUITE_NAME})
159+
160+
set(TEST_SUITES ${TEST_SUITES} ${TEST_SUITE_NAME})
155161

156162
set(LIBS_TO_BE_LINKED gmock_main)
157163

@@ -178,7 +184,7 @@ foreach(testfile ${unittest-file-list})
178184
# Link the executable with the libraries.
179185
target_link_libraries(${TEST_SUITE_NAME} ${LIBS_TO_BE_LINKED})
180186

181-
add_test(NAME "${TEST_SUITE_NAME}UnitTests" COMMAND ${TEST_SUITE_NAME})
187+
add_test(NAME "${TEST_SUITE_NAME}" COMMAND ${TEST_SUITE_NAME})
182188

183189
# Append test build directory to list
184190
list(APPEND BUILD_DIRECTORIES "./CMakeFiles/${TEST_SUITE_NAME}.dir")

UNITTESTS/features/cellular/framework/AT/at_cellularbase/unittest.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# UNIT TESTS
44
####################
55

6-
# Unit test suite name
7-
set(TEST_SUITE_NAME "cellular-framework-AT-AT_CellularBase")
8-
96
# Add test specific include paths
107
set(unittest-includes ${unittest-includes}
118
features/cellular/framework/AT/AT_CellularBase

UNITTESTS/features/cellular/framework/common/util/unittest.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# UNIT TESTS
44
####################
55

6-
# Unit test suite name
7-
set(TEST_SUITE_NAME "cellular-framework-common-util")
8-
96
# Add test specific include paths
107
set(unittest-includes ${unittest-includes}
118
features/cellular/framework/common/util

UNITTESTS/features/netsocket/InternetSocket/unittest.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# UNIT TESTS
44
####################
55

6-
# Unit test suite name
7-
set(TEST_SUITE_NAME "features-netsocket-InternetSocket")
8-
96
set(unittest-sources
107
../features/netsocket/SocketAddress.cpp
118
../features/netsocket/NetworkStack.cpp

UNITTESTS/features/netsocket/NetworkInterface/unittest.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# UNIT TESTS
44
####################
55

6-
# Unit test suite name
7-
set(TEST_SUITE_NAME "features-netsocket-NetworkInterface")
8-
96
# Source files
107
set(unittest-sources
118
../features/netsocket/NetworkInterface.cpp

UNITTESTS/features/netsocket/TCPSocket/unittest.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# UNIT TESTS
44
####################
55

6-
# Unit test suite name
7-
set(TEST_SUITE_NAME "features-netsocket-TCPSocket")
8-
96
set(unittest-sources
107
../features/netsocket/SocketAddress.cpp
118
../features/netsocket/InternetSocket.cpp

UNITTESTS/features/netsocket/UDPSocket/unittest.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# UNIT TESTS
44
####################
55

6-
# Unit test suite name
7-
set(TEST_SUITE_NAME "features-netsocket-UDPSocket")
8-
96
set(unittest-sources
107
../features/netsocket/SocketAddress.cpp
118
../features/netsocket/NetworkStack.cpp

UNITTESTS/platform/CircularBuffer/unittest.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# UNIT TESTS
44
####################
55

6-
# Unit test suite name
7-
set(TEST_SUITE_NAME "platform-CircularBuffer")
8-
96
set(unittest-sources
107
)
118

0 commit comments

Comments
 (0)