Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding windows test driver fix #293

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
61 changes: 56 additions & 5 deletions run-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ $cmake_params = "-E chdir build cmake",
$cmake_params += "-DCMAKE_CXX_STANDARD=${cpp_standard}"

$cmake_params += "-DCUKE_ENABLE_BOOST_TEST=OFF"
$cmake_params += "-DCUKE_ENABLE_GTEST=OFF"
$cmake_params += "-DCUKE_ENABLE_GTEST=ON"
$cmake_params += "-DCUKE_ENABLE_QT_6=OFF"
$cmake_params += "-DCUKE_ENABLE_EXAMPLES=OFF"
$cmake_params += "-DCUKE_TESTS_UNIT=OFF"
$cmake_params += "-DCUKE_ENABLE_QT_5=ON"
kreuzberger marked this conversation as resolved.
Show resolved Hide resolved
$cmake_params += "-DCUKE_ENABLE_EXAMPLES=ON"
$cmake_params += "-DCUKE_TESTS_UNIT=ON"
$cmake_params += "-DCUKE_CODE_COVERAGE=OFF"

$cmake_params += "-Dnlohmann_json_DIR=${nlohmann_json_DIR}"
Expand All @@ -61,6 +62,56 @@ $cmake_params += "-DTCLAP_ROOT=${TCLAP_ROOT}"

$cmake_params += ".."


Invoke-CMake "$cmake_params"
Invoke-CMake "--build","build" #,"--parallel"
Invoke-CMake "--build","build","--config","Release" #,"--parallel"
Invoke-CMake "--build","build","--config","Release","--target","RUN_TESTS"

#
# Execute Calc examples
#

$CalcTests = @("build\examples\Calc\Release\GTestCalculatorSteps.exe",
"build\examples\Calc\Release\QtTestCalculatorSteps.exe",
"build\examples\Calc\Release\BoostCalculatorSteps.exe",
"build\examples\Calc\Release\FuncArgsCalculatorSteps.exe")

If (Test-Path -path $CalcTests[$i] -PathType Leaf) {
Start-Process -NoNewWindow $CalcTests[$i]
Start-Sleep -Seconds 1.0
Set-Location -Path 'examples/Calc'
Start-Process cucumber -NoNewWindow -Wait
set-Location -Path $PSScriptRoot
} Else {
Write-Host "Skipping $($CalcTests[$i]): file not exisiting" -f Yellow
}

#
# Execute QtCalc examples
#

If ((Get-Command "qmake.exe" -ErrorAction SilentlyContinue) -eq $null)
kreuzberger marked this conversation as resolved.
Show resolved Hide resolved
{
Write-Host "Qt not found in PATH, skipping QtCalc Tests" -f Yellow
}
Else
{
$QtCalcTests = @("build\examples\CalcQt\Release\GTestCalculatorQtSteps.exe",
"build\examples\CalcQt\Release\QtTestCalculatorQtSteps.exe",
"build\examples\CalcQt\Release\BoostCalculatorQtSteps.exe")

For ($i=0; $i -lt $QtCalcTests.Length; $i++) {
If (Test-Path -path $QtCalcTests[$i] -PathType Leaf) {
kreuzberger marked this conversation as resolved.
Show resolved Hide resolved
Start-Process -NoNewWindow $QtCalcTests[$i]
Start-Sleep -Seconds 1.0
Set-Location -Path 'examples/CalcQt'
Start-Process cucumber -NoNewWindow -Wait
set-Location -Path $PSScriptRoot
} Else {
Write-Host "Skipping $($QtCalcTests[$i]): file not exisiting" -f Yellow
}
}
}

Invoke-CMake "--build","build","--config","Release","--target","INSTALL"


33 changes: 33 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@ target_include_directories(utils INTERFACE
.
)

function(cuke_set_environment environment)
set(options)
set(oneValueArgs )
set(multiValueArgs RUNPATH BINPATH)

cmake_parse_arguments(CUKE_ENV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if(NOT "${CUKE_ENV_UNPARSED_ARGUMENTS}" STREQUAL "")
message(
FATAL_ERROR
"unparsed arguments in call to cuke_set_environment: ${CUKE_ENV_UNPARSED_ARGUMENTS} from ${CMAKE_CURRENT_LIST_FILE}"
)
endif()

if( NOT "${CUKE_ENV_RUNPATH}" STREQUAL "")
if(WIN32)
string(REPLACE ";" "\;" runpath "${CUKE_ENV_RUNPATH}")
endif()
set(RUNPATH "$<IF:$<PLATFORM_ID:Windows>,PATH,LD_LIBRARY_PATH>")
list(APPEND environment "$<IF:$<PLATFORM_ID:Windows>,PATH,LD_LIBRARY_PATH>=path_list_prepend:$<SHELL_PATH:${runpath}>")
endif()
if( NOT "${CUKE_ENV_BINPATH}" STREQUAL "")
if(WIN32)
string(REPLACE ";" "\;" binpath "${CUKE_ENV_BINPATH}")
endif()
list(APPEND environment "PATH=path_list_prepend:$<SHELL_PATH:${binpath}>")
endif()

set(${environment} ${${environment}} PARENT_SCOPE)
endfunction()

kreuzberger marked this conversation as resolved.
Show resolved Hide resolved
function(cuke_add_driver_test TEST_FILE)
get_filename_component(TEST_NAME ${TEST_FILE} NAME)
message(STATUS "Adding " ${TEST_NAME})
Expand Down Expand Up @@ -63,6 +94,8 @@ if((TARGET Qt::Test)
AND (NOT VALGRIND_TESTS)
)
cuke_add_driver_test(integration/drivers/QtTestDriverTest Qt::Test)
cuke_set_environment( QTTEST_ENVIRONMENT RUNPATH "$<TARGET_FILE_DIR:Qt5::Core>" )
set_tests_properties(QtTestDriverTest PROPERTIES ENVIRONMENT_MODIFICATION ${QTTEST_ENVIRONMENT})
endif()

cuke_add_driver_test(integration/drivers/GenericDriverTest)