You've already forked linuxdeploy
mirror of
https://github.com/encounter/linuxdeploy.git
synced 2026-03-30 11:18:58 -07:00
Fix tests' structure, code style and use of GTest
This commit is contained in:
+11
-7
@@ -5,17 +5,21 @@ endif()
|
||||
add_subdirectory(simple_library)
|
||||
add_subdirectory(simple_executable)
|
||||
|
||||
add_executable(AppDirUnitTests AppDirUnitTests.cpp)
|
||||
target_link_libraries(AppDirUnitTests PRIVATE linuxdeploy_core)
|
||||
target_include_directories(AppDirUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
||||
add_executable(test_appdir test_appdir.cpp)
|
||||
target_link_libraries(test_appdir PRIVATE linuxdeploy_core gtest)
|
||||
target_include_directories(test_appdir PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
target_compile_definitions(AppDirUnitTests PRIVATE
|
||||
# calculate paths to resources using CMake and hardcode them in the test binary
|
||||
target_compile_definitions(test_appdir PRIVATE
|
||||
-DSIMPLE_LIBRARY_PATH="$<TARGET_FILE:simple_library>"
|
||||
-DSIMPLE_EXECUTABLE_PATH="$<TARGET_FILE:simple_executable>"
|
||||
-DSIMPLE_DESKTOP_ENTRY_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/simple_app.Desktop"
|
||||
-DSIMPLE_ICON_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/simple_icon.svg"
|
||||
-DSIMPLE_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/simple_file.txt"
|
||||
)
|
||||
)
|
||||
|
||||
add_gtest(AppDirUnitTests)
|
||||
add_dependencies(AppDirUnitTests simple_library simple_executable)
|
||||
# register in CTest
|
||||
add_test(test_appdir test_appdir)
|
||||
|
||||
# make sure library and executable are built before test_appdir
|
||||
add_dependencies(test_appdir simple_library simple_executable)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <cstdio>
|
||||
|
||||
extern "C" { void hello_world(); }
|
||||
#include <simple_library.h>
|
||||
|
||||
int main() {
|
||||
printf("Hello World");
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
add_library(simple_library SHARED simple_library.cpp)
|
||||
target_link_libraries(simple_library CImg)
|
||||
add_library(simple_library SHARED simple_library.cpp simple_library.h)
|
||||
target_link_libraries(simple_library PUBLIC CImg)
|
||||
target_include_directories(simple_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "CImg.h"
|
||||
using namespace cimg_library;
|
||||
|
||||
extern "C" {
|
||||
void hello_world() {
|
||||
cimg::info();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
void hello_world();
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
using namespace linuxdeploy::core::appdir;
|
||||
using namespace linuxdeploy::core::desktopfile;
|
||||
|
||||
using namespace boost::filesystem;
|
||||
namespace AppDirUnitTests {
|
||||
|
||||
namespace AppDirTest {
|
||||
class AppDirUnitTestsFixture : public ::testing::Test {
|
||||
public:
|
||||
AppDirUnitTestsFixture() :
|
||||
@@ -176,3 +176,8 @@ namespace AppDirUnitTests {
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user