From 86987a461835652899f6414137be316fe35353fc Mon Sep 17 00:00:00 2001 From: S1yGus Date: Sat, 28 Oct 2023 02:17:43 +0300 Subject: [PATCH 1/2] add multiple excluded source paths support Added support for specifying multiple excluded source paths in OpenCPPCoverage on launch. --- setup/config.template | 3 ++- tests/run_tests.bat | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/setup/config.template b/setup/config.template index fb51e93..7808c35 100644 --- a/setup/config.template +++ b/setup/config.template @@ -46,6 +46,7 @@ rem Tests set TestNames= set TestOutputLogPath=%ProjectRoot%\Build\Tests\Tests.log set ReportOutputPath=%ProjectRoot%\Build\Tests -set ExludedPathForTestReport=%SourceCodePath%\%ProjectPureName%\Tests +::To specify multiple paths for excluding sources, use the semicolon symbol ";". Example: %SourceCodePath%\%ProjectPureName%\Public\Tests;%SourceCodePath%\%ProjectPureName%\Private\Tests +set ExludedPathsForTestReport=%SourceCodePath%\%ProjectPureName%\Tests set UEAutomationContentPath=%EnginePath%\Engine\Content\Automation set OpenCPPCoveragePath=C:\Program Files\OpenCppCoverage\OpenCppCoverage.exe diff --git a/tests/run_tests.bat b/tests/run_tests.bat index 2b3db90..4e4b7c1 100644 --- a/tests/run_tests.bat +++ b/tests/run_tests.bat @@ -30,11 +30,22 @@ set Module=%RETVAL% call :NORMALIZEPATH "%SourceCodePath%" set Sources=%RETVAL% -call :NORMALIZEPATH "%ExludedPathForTestReport%" -set ExludedSources=%RETVAL% +set "ExcludedSources=" +set First="true" +SETLOCAL ENABLEDELAYEDEXPANSION +for %%i in (%ExludedPathsForTestReport%) do ( + call :NORMALIZEPATH "%%i" + set PathToAdd=!RETVAL! + if !First!=="true" ( + set First="false" + set "ExcludedSources=--excluded_sources="!PathToAdd!"" + ) else ( + set "ExcludedSources=!ExcludedSources! --excluded_sources="!PathToAdd!"" + ) +) "%OpenCPPCoveragePath%" --modules="%Module%" --sources="%Sources%" ^ ---excluded_sources="%ExludedSources%" --export_type="%ExportType%" -v -- %TestRunner% +%ExcludedSources% --export_type="%ExportType%" -v -- %TestRunner% rem clean obsolete artifacts del /q LastCoverageResults.log From d8143c1fe306203a1ec2be891c8fd0904978f387 Mon Sep 17 00:00:00 2001 From: S1yGus Date: Sat, 28 Oct 2023 17:22:51 +0300 Subject: [PATCH 2/2] add pipeline multiple excluded source paths support Added support for specifying multiple excluded source paths in Jenkins pipeline test script. --- .../game/unreal_game_test_runner.jenkinsfile | 15 ++++++++++++++- pipelines/libs/vars/utils.groovy | 14 +++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pipelines/game/unreal_game_test_runner.jenkinsfile b/pipelines/game/unreal_game_test_runner.jenkinsfile index 97b16f6..e264a67 100644 --- a/pipelines/game/unreal_game_test_runner.jenkinsfile +++ b/pipelines/game/unreal_game_test_runner.jenkinsfile @@ -5,6 +5,18 @@ def ColorFromBuildResult(result){ return '#FF0000' } +def FormatExcludedPaths(paths) { + def prefix = "--excluded_sources=" + def pathList = paths.split(";") + def result = [] + + for (path in pathList) { + result.add("${prefix}\"${path}\"") + } + + env.EXCLUDED_SOURCES = result.join(" ") +} + pipeline { agent { node { @@ -86,12 +98,13 @@ pipeline { } stage('Test') { steps { + FormatExcludedPaths(EXCLUDED_SOURCES) bat ''' set TEST_RUNNER="%EDITOR_PATH%" "%PROJECT_PATH%" -ExecCmds="Automation %TEST_EXTRA_CMD%RunTests %TEST_NAMES%;Quit" ^ -ReportExportPath="%TEST_OUTPUT_PATH%" %EDITOR_FLAGS% "%OPEN_CPP_COVERAGE_PATH%" --modules="%BUILD_DIR%" --sources="%SOURCE_CODE_PATH%" ^ - --excluded_sources="%EXCLUDED_SOURCES%" --export_type="%CODE_COVERAGE_EXPORT_TYPE%" -- %TEST_RUNNER% + %EXCLUDED_SOURCES% --export_type="%CODE_COVERAGE_EXPORT_TYPE%" -- %TEST_RUNNER% if errorlevel 255 echo WARNING: Some tests failed, error code: %errorlevel% & exit /b 0 ''' diff --git a/pipelines/libs/vars/utils.groovy b/pipelines/libs/vars/utils.groovy index e0c1ffb..08e8f70 100644 --- a/pipelines/libs/vars/utils.groovy +++ b/pipelines/libs/vars/utils.groovy @@ -13,4 +13,16 @@ def loadEnvironmentVariables(path){ value = props["${key}"] env."${key}" = "${value}" } -} \ No newline at end of file +} + +def FormatExcludedPaths(paths) { + def prefix = "--excluded_sources=" + def pathList = paths.split(";") + def result = [] + + for (path in pathList) { + result.add("${prefix}\"${path}\"") + } + + env.EXCLUDED_SOURCES = result.join(" ") +}