Skip to content
Snippets Groups Projects
Commit a9d6258e authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-windows-conan-create' into 'dev'

Make integration tests runnable on Windows

See merge request !38
parents 1c699b6c 47b4ebbf
Branches
No related tags found
2 merge requests!41Release 0.3.0,!38Make integration tests runnable on Windows
Pipeline #57604 passed
......@@ -40,6 +40,13 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# "${CONAN_PKG_LIBS}")
find_package(linkahead CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(protobuf CONFIG REQUIRED)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
enable_testing()
add_subdirectory(test)
......
......@@ -33,6 +33,29 @@ or manually via
path to the pem file in the `CAOSDB_SERVER_CERT` environment variable.
7. Run with `ctest` in the build directory.
### Windows ###
On windows, you still need to build and create a conan package from
linkahead-cpplib using conan-create or the make.ps1 script in the
cpplib repo.
This repo also provides a make script `make.ps1` to run the
integration tests on Windows. You need to create a python virtual
environment and install the requirements from linkahead cpplib or
recycle the one you used to create the package there:
```sh
python -m venv .venv # Choose any path you like for your venv
.venv/Scripts/Actvate.ps1
pip install ../linkahead-cpplib/requirements.txt # You may need to change the pass to cpplib here
```
Then build and run the tests with
```sh
make.ps1 all
```
### Troubleshooting ###
- If you don't have `clang-tidy` installed, you can run the first `cmake` command with
......
make.ps1 0 → 100644
param (
[string]$target
)
$buildType = "Release"
$cppStd=17
function Install-Conan {
Write-Output "Installing Release dependencies with Conan..."
# check if conan is available
if (-not (Get-Command conan -ErrorAction SilentlyContinue)) {
Write-Output "Conan is not available. Please install Conan or activate the Conan environment venv"
exit 1
}
conan install . --build=missing -s build_type=$buildType -s compiler.cppstd=$cppStd
cmake --preset conan-default
}
function Invoke-Build {
Write-Output "Building the project..."
# check if msbuild is available
if (-not (Get-Command msbuild -ErrorAction SilentlyContinue)) {
Write-Output "msbuild is not available. Please install Visual Studio or open the Developer PowerShell."
exit 1
}
# check if conan install was run
if (-not (Test-Path .\build\liblinkahead_inttests.sln)) {
Write-Output "Please run conan-install first."
exit 1
}
msbuild .\build\liblinkahead_inttests.sln /property:Configuration=$buildType
}
function Invoke-Tests {
Write-Output "Running tests..."
Set-Location .\build\
ctest
Set-Location ..\
}
function Invoke-Create {
Write-Output "Creating Conan package..."
conan create .
}
# check if vswhere is available
if (-not (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe")) {
Write-Output "vswhere is not available. Please install Visual Studio"
exit 1
}
# locate the latest Visual Studio installation
$currentPath = Get-Location
$installPath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $installPath
Set-Location $currentPath
# Windows is with Release only for now
switch ($target) {
"build" {
Invoke-Build
}
"test" {
Invoke-Tests
}
"conan-install" {
Install-Conan
}
"conan-create" {
Invoke-Create
}
"clean"{
Write-Output "Cleaning the project..."
Remove-Item -Recurse -Force .\build\*
}
"all" {
Install-Conan
Invoke-Build
Invoke-Tests
Invoke-Create
}
default {
Write-Output "Usage: .\make.ps1 [all|conan-install|build|test|clean]"
}
}
......@@ -35,6 +35,9 @@ set(test_cases
add_compile_definitions(BUILD_ACM)
# copy DLLs from linkahead_LIB_DIRS_RELEASE to the binary directory
file(COPY ${linkahead_LIB_DIRS_RELEASE}/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)
......@@ -99,14 +102,10 @@ endif()
### Set up tests using GoogleTest (GTest)
###################################################
# add special cmake functions for gtest
include(GoogleTest REQUIRED)
find_package(linkahead)
find_package(GTest)
find_package(gRPC)
find_package(protobuf)
# loop over all test cases and add them to the test runner
list(LENGTH test_cases len_test_cases)
math(EXPR len_test_cases "${len_test_cases} - 1")
......@@ -114,10 +113,13 @@ foreach (i RANGE "${len_test_cases}")
list(GET test_cases ${i} test_case_name)
add_executable(${test_case_name} ${test_case_name}.cpp)
target_link_libraries(${test_case_name} PRIVATE
linkahead::linkahead gtest::gtest grpc::grpc protobuf::protobuf
linkahead::linkahead linkahead clinkahead caosdb_grpc
gtest::gtest grpc::grpc protobuf::protobuf
)
target_include_directories(${test_case_name}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(${test_case_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
if(LINTING)
set_target_properties(${test_case_name}
PROPERTIES
......@@ -125,6 +127,6 @@ foreach (i RANGE "${len_test_cases}")
CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}")
endif()
gtest_discover_tests(${test_case_name}
PROPERTIES
PROPERTIES
LABELS "linkahead-cpplib-int-tests")
endforeach ()
......@@ -591,7 +591,7 @@ TEST_F(test_clinkahead, test_up_n_download_file) {
linkahead_entity_entity original_entity;
linkahead_entity_create_entity(&original_entity);
linkahead_entity_entity_set_role(&original_entity, "FILE");
linkahead_entity_entity_set_local_path(&original_entity, test_upload_file_1.c_str());
linkahead_entity_entity_set_local_path(&original_entity, test_upload_file_1.string().c_str());
linkahead_entity_entity_set_file_path(&original_entity, "/some/file");
linkahead_transaction_transaction insert_transaction;
......@@ -619,7 +619,7 @@ TEST_F(test_clinkahead, test_up_n_download_file) {
// return_code = linkahead_transaction_transaction_retrieve_by_id(
// &retrieve_transaction_1, rec_id);
return_code = linkahead_transaction_transaction_retrieve_and_download_file_by_id(
&retrieve_transaction_1, rec_id, test_download_file_1.c_str());
&retrieve_transaction_1, rec_id, test_download_file_1.string().c_str());
EXPECT_EQ(return_code, linkahead::StatusCode::GO_ON);
return_code = linkahead_transaction_transaction_execute(&retrieve_transaction_1);
EXPECT_EQ(return_code, 0);
......@@ -628,4 +628,7 @@ TEST_F(test_clinkahead, test_up_n_download_file) {
return_code =
linkahead_transaction_transaction_get_result_set(&retrieve_transaction_1, &result_set);
EXPECT_EQ(return_code, 0);
return_code = linkahead_transaction_delete_transaction(&retrieve_transaction_1);
EXPECT_EQ(return_code, 0);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment