From 83c755957b0934825dadea9074466918e88694b8 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Mon, 8 Apr 2024 10:27:38 +0200 Subject: [PATCH 01/12] adding windows test driver fix --- src/drivers/QtTestDriver.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/drivers/QtTestDriver.cpp b/src/drivers/QtTestDriver.cpp index 95b46f78..4745262e 100644 --- a/src/drivers/QtTestDriver.cpp +++ b/src/drivers/QtTestDriver.cpp @@ -8,25 +8,32 @@ namespace cucumber { namespace internal { const InvokeResult QtTestStep::invokeStepBody() { - QTemporaryFile file; - if (!file.open()) { - return InvokeResult::failure("Unable to open temporary file needed for this test"); + QString file_name; + { + QTemporaryFile file; + if (!file.open()) { + return InvokeResult::failure("Unable to open temporary file needed for this test"); + } + file.close(); } - file.close(); - QtTestObject testObject(this); + file_name += ".txt"; + + QtTestObject testObject( this ); int returnValue = QTest::qExec( &testObject, QStringList() << "test" - << "-o" << file.fileName() + << "-o" << file_name ); - if (returnValue == 0) { - return InvokeResult::success(); - } else { - file.open(); - QTextStream ts(&file); - return InvokeResult::failure(ts.readAll().toLocal8Bit()); + auto ok = ( returnValue == 0 ) ? true : false; + std::string error_text; + QFile file( file_name ); + if(!ok) { + file.open( QIODevice::ReadOnly ); + error_text = QString::fromLocal8Bit( file.readAll() ).toStdString(); } + //file.remove(); + return ok ? InvokeResult::success() : InvokeResult::failure( error_text ); } } From 8ec2b388fb88208db160d9974819889374159553 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Thu, 11 Apr 2024 09:04:44 +0200 Subject: [PATCH 02/12] integrate changes from review --- src/drivers/QtTestDriver.cpp | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/drivers/QtTestDriver.cpp b/src/drivers/QtTestDriver.cpp index 4745262e..707eb5a2 100644 --- a/src/drivers/QtTestDriver.cpp +++ b/src/drivers/QtTestDriver.cpp @@ -10,30 +10,39 @@ namespace internal { const InvokeResult QtTestStep::invokeStepBody() { QString file_name; { - QTemporaryFile file; + QTemporaryFile file(QString("%1/%2_%3") + .arg( + QDir::tempPath(), + qApp->applicationName().isEmpty() ? "qt_temp" + : qApp->applicationName() + ) + .arg(qApp->applicationPid())); if (!file.open()) { return InvokeResult::failure("Unable to open temporary file needed for this test"); } - file.close(); + file_name = file.fileName() + ".txt"; } - file_name += ".txt"; - - QtTestObject testObject( this ); + QtTestObject testObject(this); int returnValue = QTest::qExec( &testObject, QStringList() << "test" << "-o" << file_name ); - auto ok = ( returnValue == 0 ) ? true : false; - std::string error_text; - QFile file( file_name ); - if(!ok) { - file.open( QIODevice::ReadOnly ); - error_text = QString::fromLocal8Bit( file.readAll() ).toStdString(); + + const auto ok = returnValue == 0; + if (ok) { + QFile::remove(file_name); + return InvokeResult::success(); + } else { + std::string error_text; + QFile file(file_name); + file.open(QIODevice::ReadOnly); + error_text = QString::fromLocal8Bit(file.readAll()).toStdString(); + file.close(); + file.remove(); + return InvokeResult::failure(error_text); } - //file.remove(); - return ok ? InvokeResult::success() : InvokeResult::failure( error_text ); } } From 75e4b0fc174af7a5d21853ce8cbf45e9a2f50f84 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Thu, 11 Apr 2024 16:13:41 +0200 Subject: [PATCH 03/12] run more windows tests --- run-windows.ps1 | 61 ++++++++++++++++++++++++++++++++++++++++---- tests/CMakeLists.txt | 33 ++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 5 deletions(-) diff --git a/run-windows.ps1 b/run-windows.ps1 index 3adbc3cf..b70c2e05 100755 --- a/run-windows.ps1 +++ b/run-windows.ps1 @@ -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" +$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}" @@ -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) +{ + 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) { + 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" + + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a66c56b..0e039c05 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 "$,PATH,LD_LIBRARY_PATH>") + list(APPEND environment "$,PATH,LD_LIBRARY_PATH>=path_list_prepend:$") + endif() + if( NOT "${CUKE_ENV_BINPATH}" STREQUAL "") + if(WIN32) + string(REPLACE ";" "\;" binpath "${CUKE_ENV_BINPATH}") + endif() + list(APPEND environment "PATH=path_list_prepend:$") + endif() + + set(${environment} ${${environment}} PARENT_SCOPE) +endfunction() + function(cuke_add_driver_test TEST_FILE) get_filename_component(TEST_NAME ${TEST_FILE} NAME) message(STATUS "Adding " ${TEST_NAME}) @@ -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 "$" ) + set_tests_properties(QtTestDriverTest PROPERTIES ENVIRONMENT_MODIFICATION ${QTTEST_ENVIRONMENT}) endif() cuke_add_driver_test(integration/drivers/GenericDriverTest) From cfd1cd4ca247d591091a1fd767ee0eeff9c5c58b Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Thu, 11 Apr 2024 16:25:52 +0200 Subject: [PATCH 04/12] fix linux tests (both qt5 and qt6 available) --- run-linux.sh | 1 + tests/CMakeLists.txt | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/run-linux.sh b/run-linux.sh index cc74aea2..c1da876f 100755 --- a/run-linux.sh +++ b/run-linux.sh @@ -11,6 +11,7 @@ cmake -E chdir build cmake \ -DCUKE_ENABLE_BOOST_TEST=on \ -DCUKE_ENABLE_GTEST=on \ -DCUKE_ENABLE_QT_6=on \ + -DCUKE_ENABLE_QT_5=off \ -DCUKE_ENABLE_EXAMPLES=on \ -DCUKE_TESTS_UNIT=on \ -DCUKE_CODE_COVERAGE=on \ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0e039c05..f939c342 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,16 +27,16 @@ function(cuke_set_environment environment) if( NOT "${CUKE_ENV_RUNPATH}" STREQUAL "") if(WIN32) - string(REPLACE ";" "\;" runpath "${CUKE_ENV_RUNPATH}") + string(REPLACE ";" "\;" CUKE_ENV_RUNPATH "${CUKE_ENV_RUNPATH}") endif() set(RUNPATH "$,PATH,LD_LIBRARY_PATH>") - list(APPEND environment "$,PATH,LD_LIBRARY_PATH>=path_list_prepend:$") + list(APPEND environment "$,PATH,LD_LIBRARY_PATH>=path_list_prepend:$") endif() if( NOT "${CUKE_ENV_BINPATH}" STREQUAL "") if(WIN32) - string(REPLACE ";" "\;" binpath "${CUKE_ENV_BINPATH}") + string(REPLACE ";" "\;" CUKE_ENV_BINPATH "${CUKE_ENV_BINPATH}") endif() - list(APPEND environment "PATH=path_list_prepend:$") + list(APPEND environment "PATH=path_list_prepend:$") endif() set(${environment} ${${environment}} PARENT_SCOPE) @@ -94,7 +94,7 @@ if((TARGET Qt::Test) AND (NOT VALGRIND_TESTS) ) cuke_add_driver_test(integration/drivers/QtTestDriverTest Qt::Test) - cuke_set_environment( QTTEST_ENVIRONMENT RUNPATH "$" ) + cuke_set_environment( QTTEST_ENVIRONMENT RUNPATH "$" ) set_tests_properties(QtTestDriverTest PROPERTIES ENVIRONMENT_MODIFICATION ${QTTEST_ENVIRONMENT}) endif() From 6895dc02957393ae2b3c119ea75e17662703cea2 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 12 Apr 2024 08:00:51 +0200 Subject: [PATCH 05/12] determine cuke_qt runtime path for qt tests from library names as variable --- CMakeLists.txt | 16 +++++++--------- tests/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc983531..cc2cbe58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,7 @@ endif() # if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Werror -Wall -Wextra -Wsuggest-override ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -Wextra -Wsuggest-override ${CMAKE_CXX_FLAGS}") # TODO: A better fix should handle ld's --as-needed flag if(UNIX AND NOT APPLE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker '--no-as-needed'") @@ -165,14 +165,11 @@ if(CUKE_ENABLE_QT_5) message(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}") if(Qt5Core_VERSION_STRING VERSION_LESS 5.15.0) - add_library(Qt::Core INTERFACE IMPORTED) - add_library(Qt::Gui INTERFACE IMPORTED) - add_library(Qt::Widgets INTERFACE IMPORTED) - add_library(Qt::Test INTERFACE IMPORTED) - set_target_properties(Qt::Core PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Core ) - set_target_properties(Qt::Gui PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Gui ) - set_target_properties(Qt::Widgets PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Widgets) - set_target_properties(Qt::Test PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Test ) + add_library( Qt::Core ALIAS Qt5::Core) + add_library( Qt::Gui ALIAS Qt5::Gui) + add_library( Qt::Widgets ALIAS Qt5::Widgets) + add_library( Qt::Test ALIAS Qt5::Test) + set( CUKE_QT_RUNTIME_PATH $ ) endif() endif() @@ -185,6 +182,7 @@ if(CUKE_ENABLE_QT_6) ) message(STATUS "Found Qt version: ${Qt6Core_VERSION}") + set( CUKE_QT_RUNTIME_PATH $ ) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f939c342..5f4fcf62 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -94,7 +94,7 @@ if((TARGET Qt::Test) AND (NOT VALGRIND_TESTS) ) cuke_add_driver_test(integration/drivers/QtTestDriverTest Qt::Test) - cuke_set_environment( QTTEST_ENVIRONMENT RUNPATH "$" ) + cuke_set_environment( QTTEST_ENVIRONMENT RUNPATH "${CUKE_QT_RUNTIME_PATH}" ) set_tests_properties(QtTestDriverTest PROPERTIES ENVIRONMENT_MODIFICATION ${QTTEST_ENVIRONMENT}) endif() From dc8316410b9d1f76dcac1b33dc0471ed38dec83a Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 12 Apr 2024 08:07:34 +0200 Subject: [PATCH 06/12] fix CUKE_RUNTIME_PATH scope issue --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc2cbe58..a24d44b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,8 +169,8 @@ if(CUKE_ENABLE_QT_5) add_library( Qt::Gui ALIAS Qt5::Gui) add_library( Qt::Widgets ALIAS Qt5::Widgets) add_library( Qt::Test ALIAS Qt5::Test) - set( CUKE_QT_RUNTIME_PATH $ ) endif() + set( CUKE_QT_RUNTIME_PATH $ ) endif() if(CUKE_ENABLE_QT_6) From b9232fdde1f9d41d27345d3caf923e3a63a77e67 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 12 Apr 2024 09:01:25 +0200 Subject: [PATCH 07/12] integrate QTemporaryTestDriver suggestion --- run-windows.ps1 | 27 ++++++++----- src/drivers/QtTestDriver.cpp | 75 +++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 33 deletions(-) diff --git a/run-windows.ps1 b/run-windows.ps1 index b70c2e05..2deee63b 100755 --- a/run-windows.ps1 +++ b/run-windows.ps1 @@ -71,20 +71,26 @@ Invoke-CMake "--build","build","--config","Release","--target","RUN_TESTS" # $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 -} +If ((Get-Command "qmake.exe" -ErrorAction SilentlyContinue) -ne $null) +{ + $CalcTests += "build\examples\Calc\Release\QtTestCalculatorSteps.exe" +} +For ($i=0; $i -lt $CalcTests.Length; $i++) { + If (Test-Path -path $CalcTests[$i] -PathType Leaf) { + Write-Host "Start Test $($CalcTests[$i])" -f Green + 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 # @@ -101,6 +107,7 @@ Else For ($i=0; $i -lt $QtCalcTests.Length; $i++) { If (Test-Path -path $QtCalcTests[$i] -PathType Leaf) { + Write-Host "Start Test $($QtCalcTests[$i])" -f Green Start-Process -NoNewWindow $QtCalcTests[$i] Start-Sleep -Seconds 1.0 Set-Location -Path 'examples/CalcQt' diff --git a/src/drivers/QtTestDriver.cpp b/src/drivers/QtTestDriver.cpp index 707eb5a2..5915a45e 100644 --- a/src/drivers/QtTestDriver.cpp +++ b/src/drivers/QtTestDriver.cpp @@ -4,44 +4,73 @@ #include #include +#include + namespace cucumber { namespace internal { -const InvokeResult QtTestStep::invokeStepBody() { - QString file_name; + +// wraps the QTemporaryFile creation +// on Windows the file could not be written as long as QTemporaryFile owner of the file. + +class TemporaryFileWrapper { +public: + static TemporaryFileWrapper create() { - QTemporaryFile file(QString("%1/%2_%3") - .arg( - QDir::tempPath(), - qApp->applicationName().isEmpty() ? "qt_temp" - : qApp->applicationName() - ) - .arg(qApp->applicationPid())); - if (!file.open()) { - return InvokeResult::failure("Unable to open temporary file needed for this test"); + QTemporaryFile tempFile{}; + + if(!tempFile.open()) { + return {}; } - file_name = file.fileName() + ".txt"; + + return {tempFile.fileName() + ".txt"}; + } + + TemporaryFileWrapper(): filename{} { + } + + TemporaryFileWrapper(QString filename): filename{filename} { + } + + ~TemporaryFileWrapper() { + auto ok = QFile::remove(filename); + } + + bool TemporaryFileWrapper::exists() const { return !filename.isEmpty(); } + + QString name() const { + return filename; + } + + QString read() const { + QFile file{ filename }; + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return QString(); + QTextStream in(&file); + return in.readAll(); + } + +private: + QString filename; +}; + +const InvokeResult QtTestStep::invokeStepBody() { + const auto file = TemporaryFileWrapper::create(); + if (!file.exists()) { + return InvokeResult::failure("Unable to open temporary file needed for this test"); } QtTestObject testObject(this); int returnValue = QTest::qExec( &testObject, QStringList() << "test" - << "-o" << file_name + << "-o" << file.name() ); - const auto ok = returnValue == 0; - if (ok) { - QFile::remove(file_name); + if (returnValue == 0) { return InvokeResult::success(); } else { - std::string error_text; - QFile file(file_name); - file.open(QIODevice::ReadOnly); - error_text = QString::fromLocal8Bit(file.readAll()).toStdString(); - file.close(); - file.remove(); - return InvokeResult::failure(error_text); + return InvokeResult::failure(file.read().toLocal8Bit()); } } From bcb880d15616186640196b9f06c2573598c77041 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 12 Apr 2024 09:02:30 +0200 Subject: [PATCH 08/12] fix clang-format of driver --- src/drivers/QtTestDriver.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/drivers/QtTestDriver.cpp b/src/drivers/QtTestDriver.cpp index 5915a45e..f8943802 100644 --- a/src/drivers/QtTestDriver.cpp +++ b/src/drivers/QtTestDriver.cpp @@ -9,41 +9,43 @@ namespace cucumber { namespace internal { - // wraps the QTemporaryFile creation // on Windows the file could not be written as long as QTemporaryFile owner of the file. - + class TemporaryFileWrapper { public: - static TemporaryFileWrapper create() - { + static TemporaryFileWrapper create() { QTemporaryFile tempFile{}; - if(!tempFile.open()) { + if (!tempFile.open()) { return {}; } return {tempFile.fileName() + ".txt"}; } - TemporaryFileWrapper(): filename{} { + TemporaryFileWrapper() : + filename{} { } - TemporaryFileWrapper(QString filename): filename{filename} { + TemporaryFileWrapper(QString filename) : + filename{filename} { } ~TemporaryFileWrapper() { auto ok = QFile::remove(filename); } - - bool TemporaryFileWrapper::exists() const { return !filename.isEmpty(); } + + bool TemporaryFileWrapper::exists() const { + return !filename.isEmpty(); + } QString name() const { return filename; } QString read() const { - QFile file{ filename }; + QFile file{filename}; if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return QString(); QTextStream in(&file); @@ -52,7 +54,7 @@ class TemporaryFileWrapper { private: QString filename; -}; +}; const InvokeResult QtTestStep::invokeStepBody() { const auto file = TemporaryFileWrapper::create(); From aa604ef3f39ecc16c96efe6aadac2e61834249d1 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 12 Apr 2024 09:05:06 +0200 Subject: [PATCH 09/12] fix linux compilation errors --- src/drivers/QtTestDriver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drivers/QtTestDriver.cpp b/src/drivers/QtTestDriver.cpp index f8943802..e10e7250 100644 --- a/src/drivers/QtTestDriver.cpp +++ b/src/drivers/QtTestDriver.cpp @@ -33,10 +33,10 @@ class TemporaryFileWrapper { } ~TemporaryFileWrapper() { - auto ok = QFile::remove(filename); + QFile::remove(filename); } - bool TemporaryFileWrapper::exists() const { + bool exists() const { return !filename.isEmpty(); } From 85903d2159abd61bbc921782296020f663e86421 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 12 Apr 2024 09:15:27 +0200 Subject: [PATCH 10/12] add pid and app name to temp file template --- src/drivers/QtTestDriver.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/drivers/QtTestDriver.cpp b/src/drivers/QtTestDriver.cpp index e10e7250..a3091e11 100644 --- a/src/drivers/QtTestDriver.cpp +++ b/src/drivers/QtTestDriver.cpp @@ -15,7 +15,15 @@ namespace internal { class TemporaryFileWrapper { public: static TemporaryFileWrapper create() { - QTemporaryFile tempFile{}; + QTemporaryFile tempFile( + QString("%1/%2_%3") + .arg( + QDir::tempPath(), + qApp->applicationName().isEmpty() ? "qt_temp" + : qApp->applicationName() + ) + .arg(qApp->applicationPid()) + ); if (!tempFile.open()) { return {}; From 6a181036ed25b8a5684b659b0e5dfed4ae2d8b2b Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Fri, 12 Apr 2024 09:16:27 +0200 Subject: [PATCH 11/12] clang-format changed QtTestDriver --- src/drivers/QtTestDriver.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/drivers/QtTestDriver.cpp b/src/drivers/QtTestDriver.cpp index a3091e11..d702b1fe 100644 --- a/src/drivers/QtTestDriver.cpp +++ b/src/drivers/QtTestDriver.cpp @@ -15,15 +15,13 @@ namespace internal { class TemporaryFileWrapper { public: static TemporaryFileWrapper create() { - QTemporaryFile tempFile( - QString("%1/%2_%3") - .arg( - QDir::tempPath(), - qApp->applicationName().isEmpty() ? "qt_temp" - : qApp->applicationName() - ) - .arg(qApp->applicationPid()) - ); + QTemporaryFile tempFile(QString("%1/%2_%3") + .arg( + QDir::tempPath(), + qApp->applicationName().isEmpty() ? "qt_temp" + : qApp->applicationName() + ) + .arg(qApp->applicationPid())); if (!tempFile.open()) { return {}; From 3ffd0b648bc58959dfc8c69ec1252903751ad6f8 Mon Sep 17 00:00:00 2001 From: Joerg Kreuzberger Date: Mon, 15 Apr 2024 22:09:06 +0200 Subject: [PATCH 12/12] applied changes required from review --- run-linux.sh | 1 - run-windows.ps1 | 60 +++++++++++++++----------------------------- tests/CMakeLists.txt | 9 +------ 3 files changed, 21 insertions(+), 49 deletions(-) diff --git a/run-linux.sh b/run-linux.sh index c1da876f..cc74aea2 100755 --- a/run-linux.sh +++ b/run-linux.sh @@ -11,7 +11,6 @@ cmake -E chdir build cmake \ -DCUKE_ENABLE_BOOST_TEST=on \ -DCUKE_ENABLE_GTEST=on \ -DCUKE_ENABLE_QT_6=on \ - -DCUKE_ENABLE_QT_5=off \ -DCUKE_ENABLE_EXAMPLES=on \ -DCUKE_TESTS_UNIT=on \ -DCUKE_CODE_COVERAGE=on \ diff --git a/run-windows.ps1 b/run-windows.ps1 index 2deee63b..199a19eb 100755 --- a/run-windows.ps1 +++ b/run-windows.ps1 @@ -50,8 +50,7 @@ $cmake_params += "-DCMAKE_CXX_STANDARD=${cpp_standard}" $cmake_params += "-DCUKE_ENABLE_BOOST_TEST=OFF" $cmake_params += "-DCUKE_ENABLE_GTEST=ON" -$cmake_params += "-DCUKE_ENABLE_QT_6=OFF" -$cmake_params += "-DCUKE_ENABLE_QT_5=ON" +$cmake_params += "-DCUKE_ENABLE_QT_6=ON" $cmake_params += "-DCUKE_ENABLE_EXAMPLES=ON" $cmake_params += "-DCUKE_TESTS_UNIT=ON" $cmake_params += "-DCUKE_CODE_COVERAGE=OFF" @@ -72,51 +71,32 @@ Invoke-CMake "--build","build","--config","Release","--target","RUN_TESTS" $CalcTests = @("build\examples\Calc\Release\GTestCalculatorSteps.exe", "build\examples\Calc\Release\BoostCalculatorSteps.exe", -"build\examples\Calc\Release\FuncArgsCalculatorSteps.exe") - -If ((Get-Command "qmake.exe" -ErrorAction SilentlyContinue) -ne $null) -{ - $CalcTests += "build\examples\Calc\Release\QtTestCalculatorSteps.exe" -} +"build\examples\Calc\Release\FuncArgsCalculatorSteps.exe", +"build\examples\Calc\Release\QtTestCalculatorSteps.exe") For ($i=0; $i -lt $CalcTests.Length; $i++) { - If (Test-Path -path $CalcTests[$i] -PathType Leaf) { - Write-Host "Start Test $($CalcTests[$i])" -f Green - 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 - } + Write-Host "Start Test $($CalcTests[$i])" -f Green + Start-Process -NoNewWindow $CalcTests[$i] + Start-Sleep -Seconds 1.0 + Set-Location -Path 'examples/Calc' + Start-Process cucumber -NoNewWindow -Wait + set-Location -Path $PSScriptRoot } # # Execute QtCalc examples # -If ((Get-Command "qmake.exe" -ErrorAction SilentlyContinue) -eq $null) -{ - 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) { - Write-Host "Start Test $($QtCalcTests[$i])" -f Green - 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 - } - } +$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++) { + Write-Host "Start Test $($QtCalcTests[$i])" -f Green + Start-Process -NoNewWindow $QtCalcTests[$i] + Start-Sleep -Seconds 1.0 + Set-Location -Path 'examples/CalcQt' + Start-Process cucumber -NoNewWindow -Wait + set-Location -Path $PSScriptRoot } Invoke-CMake "--build","build","--config","Release","--target","INSTALL" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5f4fcf62..cceda78c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,7 +14,7 @@ target_include_directories(utils INTERFACE function(cuke_set_environment environment) set(options) set(oneValueArgs ) - set(multiValueArgs RUNPATH BINPATH) + set(multiValueArgs RUNPATH) cmake_parse_arguments(CUKE_ENV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -32,13 +32,6 @@ function(cuke_set_environment environment) set(RUNPATH "$,PATH,LD_LIBRARY_PATH>") list(APPEND environment "$,PATH,LD_LIBRARY_PATH>=path_list_prepend:$") endif() - if( NOT "${CUKE_ENV_BINPATH}" STREQUAL "") - if(WIN32) - string(REPLACE ";" "\;" CUKE_ENV_BINPATH "${CUKE_ENV_BINPATH}") - endif() - list(APPEND environment "PATH=path_list_prepend:$") - endif() - set(${environment} ${${environment}} PARENT_SCOPE) endfunction()