cmake: add unit testing option and shunit2 tests
authorPetr Štetiar <ynezz@true.cz>
Fri, 1 Nov 2019 08:13:42 +0000 (09:13 +0100)
committerPetr Štetiar <ynezz@true.cz>
Thu, 14 Nov 2019 16:11:08 +0000 (17:11 +0100)
For convenient tests invocation.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
CMakeLists.txt
tests/CMakeLists.txt [new file with mode: 0644]
tests/shunit2/CMakeLists.txt [new file with mode: 0644]

index 578c0212779a78070dd7225335259e88b2ff8906..5720a5f8c024e012014f3307806d93061fc2b33c 100644 (file)
@@ -43,6 +43,11 @@ ADD_LIBRARY(ucimap STATIC ucimap.c)
 
 ADD_SUBDIRECTORY(lua)
 
+IF(UNIT_TESTING)
+  ENABLE_TESTING()
+  ADD_SUBDIRECTORY(tests)
+ENDIF()
+
 INSTALL(FILES uci.h uci_config.h uci_blob.h ucimap.h
        DESTINATION include
 )
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b7a7ccb
--- /dev/null
@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(shunit2)
diff --git a/tests/shunit2/CMakeLists.txt b/tests/shunit2/CMakeLists.txt
new file mode 100644 (file)
index 0000000..42cb43f
--- /dev/null
@@ -0,0 +1,7 @@
+ADD_TEST(
+       NAME shunit2
+       COMMAND tests.sh
+       WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+SET_PROPERTY(TEST shunit2 APPEND PROPERTY ENVIRONMENT "UCI_BIN=$<TARGET_FILE:cli>")