mirror of
https://github.com/audacity/linuxdeploy.git
synced 2026-04-19 09:45:16 -05:00
Add unit test for AppDir::deployExecutable
This commit is contained in:
committed by
TheAssassin
parent
a0503a7102
commit
4c9943f0d1
@@ -87,4 +87,28 @@ namespace AppDirUnitTests {
|
||||
if (!libsimple_library_found)
|
||||
FAIL();
|
||||
}
|
||||
|
||||
TEST_F(AppDirUnitTestsFixture, deployExecutable) {
|
||||
path exePath = SIMPLE_EXECUTABLE_PATH;
|
||||
appDir.deployExecutable(exePath);
|
||||
appDir.executeDeferredOperations();
|
||||
|
||||
bool libsimple_library_found = false;
|
||||
bool simple_executable_found = false;
|
||||
recursive_directory_iterator end_itr; // default construction yields past-the-end
|
||||
for (recursive_directory_iterator itr(tmpAppDir);
|
||||
itr != end_itr && (!libsimple_library_found || !simple_executable_found);
|
||||
itr++) {
|
||||
const auto path = relative(itr->path(), tmpAppDir).filename().string();
|
||||
|
||||
if (path.find("libsimple_library") != std::string::npos)
|
||||
libsimple_library_found = true;
|
||||
|
||||
if (path.find("simple_executable") != std::string::npos)
|
||||
simple_executable_found = true;
|
||||
}
|
||||
|
||||
if (!libsimple_library_found || !simple_executable_found)
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,16 @@ if(NOT TARGET gtest)
|
||||
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)
|
||||
target_compile_definitions(AppDirUnitTests PRIVATE -DSIMPLE_LIBRARY_PATH="$<TARGET_LINKER_FILE:simple_library>")
|
||||
|
||||
target_compile_definitions(AppDirUnitTests PRIVATE
|
||||
-DSIMPLE_LIBRARY_PATH="$<TARGET_FILE:simple_library>"
|
||||
-DSIMPLE_EXECUTABLE_PATH="$<TARGET_FILE:simple_executable>"
|
||||
)
|
||||
|
||||
add_gtest(AppDirUnitTests)
|
||||
add_dependencies(AppDirUnitTests simple_library)
|
||||
add_dependencies(AppDirUnitTests simple_library simple_executable)
|
||||
|
||||
2
tests/simple_executable/CMakeLists.txt
Normal file
2
tests/simple_executable/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
add_executable(simple_executable simple_executable.cpp)
|
||||
target_link_libraries(simple_executable simple_library pthread)
|
||||
10
tests/simple_executable/simple_executable.cpp
Normal file
10
tests/simple_executable/simple_executable.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <cstdio>
|
||||
|
||||
extern "C" { void hello_world(); }
|
||||
|
||||
int main() {
|
||||
printf("Hello World");
|
||||
hello_world();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
add_library(simple_library SHARED simple_library.cpp)
|
||||
target_link_libraries(simple_library cairo)
|
||||
target_link_libraries(simple_library CImg)
|
||||
Reference in New Issue
Block a user