diff --git a/vars/sconsBuild.groovy b/vars/sconsBuild.groovy index 53faf4a36..8d1b2f321 100644 --- a/vars/sconsBuild.groovy +++ b/vars/sconsBuild.groovy @@ -69,6 +69,7 @@ Map call(Map config = [:]) { * . Additional stashes * will be created for "install" and "build_vars" with similar * prefixes. + * config['code_coverage'] Boolean, build with code coverage. Default false. */ Date startDate = new Date() @@ -192,6 +193,9 @@ Map call(Map config = [:]) { if (config['WARNING_LEVEL']) { scons_args += " WARNING_LEVEL=${config['WARNING_LEVEL']}" } + if (config['code_coverage']) { + scons_args += ' --code-coverage' + } //scons -c is not perfect so get out the big hammer String clean_cmd = "" if (config['skip_clean']) { @@ -315,6 +319,9 @@ Map call(Map config = [:]) { if (stage_info['compiler'] == 'covc') { vars_includes += ', test.cov' } + if (config['code_coverage']) { + vars_includes += ', build/**/*.gcno' + } stash name: target_stash + '-build-vars', includes: vars_includes String test_files = readFile "${env.WORKSPACE}/${config['stash_files']}" diff --git a/vars/unitTest.groovy b/vars/unitTest.groovy index 5801df361..a0b42b595 100755 --- a/vars/unitTest.groovy +++ b/vars/unitTest.groovy @@ -223,5 +223,11 @@ Map call(Map config = [:]) { stash name: results_map, includes: results_map + // Stash any optional test coverage rreports for the stage + String code_coverage = 'code_coverage_' + sanitizedStageName() + stash name: code_coverage, + includes: '**/code_coverage.json', + allowEmpty: true + return runData }