From 591ad7f824d86e664c8710e3de58e2a385963d75 Mon Sep 17 00:00:00 2001 From: AMZN-AlexOteiza <82234181+AMZN-AlexOteiza@users.noreply.github.com> Date: Tue, 11 May 2021 12:44:27 +0100 Subject: [PATCH] Added xml output for tests (#664) Added test reporting information for jenkins --- scripts/build/Jenkins/Jenkinsfile | 30 ++++++++++++++++--- .../build/Platform/Windows/build_config.json | 18 +++++++---- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index f85b0b5ef4..ae2779eba8 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -60,7 +60,7 @@ def palRm(path) { } else { def win_path = path.replace('/','\\') bat label: "Removing ${win_path}", - script: "del ${win_path}" + script: "del /Q ${win_path}" } } @@ -354,6 +354,16 @@ def TestMetrics(Map pipelineConfig, String workspace, String branchName, String } } +def ExportTestResults(Map options, String platform, String type, String workspace, Map params) { + catchError(message: "Error exporting tests results (this won't fail the build)", buildResult: 'SUCCESS', stageResult: 'FAILURE') { + def o3deroot = "${workspace}/${ENGINE_REPOSITORY_NAME}" + dir("${o3deroot}/${params.OUTPUT_DIRECTORY}") { + junit testResults: "Testing/**/*.xml" + palRmDir("Testing") + } + } +} + def PostBuildCommonSteps(String workspace, boolean mount = true) { echo 'Starting post-build common steps...' @@ -396,6 +406,14 @@ def CreateTestMetricsStage(Map pipelineConfig, String branchName, Map environmen } } +def CreateExportTestResultsStage(Map pipelineConfig, String platformName, String jobName, Map environmentVars, Map params) { + return { + stage("${jobName}_results") { + ExportTestResults(pipelineConfig, platformName, jobName, environmentVars['WORKSPACE'], params) + } + } +} + def CreateTeardownStage(Map environmentVars) { return { stage('Teardown') { @@ -511,11 +529,15 @@ try { } } finally { - if (env.MARS_REPO && platform.value.build_types[build_job_name].PARAMETERS.containsKey('TEST_METRICS') && platform.value.build_types[build_job_name].PARAMETERS.TEST_METRICS == 'True') { - def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY - def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION + def params = platform.value.build_types[build_job_name].PARAMETERS + if (env.MARS_REPO && params && params.containsKey('TEST_METRICS') && params.TEST_METRICS == 'True') { + def output_directory = params.OUTPUT_DIRECTORY + def configuration = params.CONFIGURATION CreateTestMetricsStage(pipelineConfig, branchName, envVars, build_job_name, output_directory, configuration).call() } + if (params && params.containsKey('TEST_RESULTS') && params.TEST_RESULTS == 'True') { + CreateExportTestResultsStage(pipelineConfig, platform.key, build_job_name, envVars, params).call() + } CreateTeardownStage(envVars).call() } } diff --git a/scripts/build/Platform/Windows/build_config.json b/scripts/build/Platform/Windows/build_config.json index ff57e007cc..ee34bae3e3 100644 --- a/scripts/build/Platform/Windows/build_config.json +++ b/scripts/build/Platform/Windows/build_config.json @@ -106,7 +106,8 @@ "CMAKE_TARGET": "TEST_SUITE_smoke TEST_SUITE_main", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", "CTEST_OPTIONS": "-L \"(SUITE_smoke|SUITE_main)\" -LE \"(REQUIRES_gpu)\" -T Test", - "TEST_METRICS": "True" + "TEST_METRICS": "True", + "TEST_RESULTS": "True" } }, "profile_vs2019": { @@ -154,7 +155,8 @@ "CMAKE_TARGET": "TEST_SUITE_smoke TEST_SUITE_main", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", "CTEST_OPTIONS": "-L \"(SUITE_smoke|SUITE_main)\" -LE \"(REQUIRES_gpu)\" -T Test", - "TEST_METRICS": "True" + "TEST_METRICS": "True", + "TEST_RESULTS": "True" } }, "test_gpu_profile_vs2019": { @@ -174,7 +176,8 @@ "CMAKE_TARGET": "TEST_SUITE_smoke TEST_SUITE_main", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", "CTEST_OPTIONS": "-L \"(SUITE_smoke_REQUIRES_gpu|SUITE_main_REQUIRES_gpu)\" -T Test", - "TEST_METRICS": "True" + "TEST_METRICS": "True", + "TEST_RESULTS": "True" } }, "asset_profile_vs2019": { @@ -211,7 +214,8 @@ "CMAKE_TARGET": "TEST_SUITE_periodic", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", "CTEST_OPTIONS": "-L \"(SUITE_periodic)\" -T Test", - "TEST_METRICS": "True" + "TEST_METRICS": "True", + "TEST_RESULTS": "True" } }, "sandbox_test_profile_vs2019": { @@ -232,7 +236,8 @@ "CMAKE_TARGET": "TEST_SUITE_sandbox", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", "CTEST_OPTIONS": "-L \"(SUITE_sandbox)\" -T Test", - "TEST_METRICS": "True" + "TEST_METRICS": "True", + "TEST_RESULTS": "True" } }, "benchmark_test_profile_vs2019": { @@ -250,7 +255,8 @@ "CMAKE_TARGET": "TEST_SUITE_benchmark", "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", "CTEST_OPTIONS": "-L \"(SUITE_benchmark)\" -T Test", - "TEST_METRICS": "True" + "TEST_METRICS": "True", + "TEST_RESULTS": "True" } }, "release_vs2019": {