File: 0003-Integrate-unit-tests-into-CMake-build.patch

package info (click to toggle)
tinygltf 2.9.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,512 kB
  • sloc: cpp: 8,607; sh: 45; makefile: 27
file content (66 lines) | stat: -rw-r--r-- 1,895 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From: =?utf-8?q?Timo_R=C3=B6hling?= <timo.roehling@fkie.fraunhofer.de>
Date: Tue, 31 Mar 2020 17:42:23 +0200
Subject: Integrate unit tests into CMake build

Forwarded: not-needed
---
 CMakeLists.txt       | 4 ++++
 tests/CMakeLists.txt | 9 +++++++++
 tests/tester.cc      | 4 ++--
 3 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 tests/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34778cf..5f630da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@ project(TinyGLTF VERSION ${TINYGLTF_VERSION} LANGUAGES CXX)
 
 include(GNUInstallDirs)
 include(CMakePackageConfigHelpers)
+include(CTest)
 
 find_package(nlohmann_json 3 REQUIRED)
 find_path(stb_INCLUDE_DIRS NAMES stb_image.h PATH_SUFFIXES stb)
@@ -77,3 +78,6 @@ install(FILES
 	${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
 	DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
 )
+
+add_subdirectory(tests)
+
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..80148fc
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,9 @@
+if(BUILD_TESTING)
+	add_executable(tester tester.cc)
+	add_test(NAME tester COMMAND tester WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+	target_include_directories(tester PRIVATE
+		${CMAKE_SOURCE_DIR}
+		${stb_INCLUDE_DIRS}
+	)
+endif()
+
diff --git a/tests/tester.cc b/tests/tester.cc
index 135f84e..a8578bb 100644
--- a/tests/tester.cc
+++ b/tests/tester.cc
@@ -1,13 +1,13 @@
 #define TINYGLTF_IMPLEMENTATION
 #define STB_IMAGE_IMPLEMENTATION
 #define STB_IMAGE_WRITE_IMPLEMENTATION
-#include "tiny_gltf.h"
+#include <tiny_gltf.h>
 
 // Nlohmann json(include ../json.hpp)
 #include <nlohmann/json.hpp>
 
 #define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
-#include "catch.hpp"
+#include <catch.hpp>
 
 #include <cstdio>
 #include <cstdlib>