blob: 587754f06ef857a63270f5d4b8e6d154cbf80ae6 [file] [log] [blame] [edit]
"""Recipe for building and running JUnit tests."""
from slave import base_recipe
from slave.step import unittest_step, jacoco_coverage_processing_step
# This is needed to override the "DEFAULT_MANIFEST_STRING" in test_generator.py
# by adding the chromium/tools/depot_tools project.
SAMPLE_MANIFEST_STRING = """
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch="https://chromium.googlesource.com/" name="chromium" review="https://chromium-review.googlesource.com/"/>
<remote fetch="https://eureka-internal.googlesource.com/" name="eureka" review="sso://eureka-internal"/>
<remote fetch="https://github.com/" name="github"/>
<default revision="master"/>
<project name="chromium/src" remote="eureka" revision="unfork_m43"/>
<project name="chromium/tools/depot_tools" remote="chromium"/>
<project name="chromiumos/chromite" path="chromite/chromite" remote="chromium"/>
<project name="chromiumos/third_party/autotest" path="autotest" remote="chromium"/>
<project name="continuous-tests" remote="eureka"/>
<project name="fake/unittest" remote="eureka"/>
<project name="fragglerock" remote="eureka"/>
<project name="prebuilt/toolchain" path="toolchain" remote="eureka"/>
<project name="google/sprockets" path="test/sprockets" remote="github"/>
<project name="test" remote="eureka"/>
<project name="chromecast/internal" path="chromium/src/chromecast/internal" remote="eureka"/>
<project name="chromecast/internal/voice_ui" path="chromium/src/chromecast/internal/chirp" remote="eureka"/>
<project name="vendor/amlogic" remote="eureka"/>
<project name="vendor/marvell" remote="eureka"/>
</manifest>
"""
BUILD_CONFIGS = {
'junit_androidtv': {
'build_args_product': 'atv_x86_user',
'build_args_official': False,
'code_coverage': True,
},
'junit_soba': {
'build_args_product': 'soba_arm_internal',
'build_args_official': False,
'code_coverage': True,
},
'junit_udon': {
'build_args_product': 'udon_x64_user',
'build_args_official': False,
'code_coverage': True,
},
}
def GetValidBuildNames():
return BUILD_CONFIGS.keys()
def CreateRecipe(build_name: str, **kwargs):
"""Builds a recipe object."""
config = BUILD_CONFIGS[build_name]
return JunitRecipe(config, **kwargs)
class JunitRecipe(base_recipe.BaseRecipe):
"""Recipe to build and run JUnit tests."""
def __init__(self, config, **kwargs):
base_recipe.BaseRecipe.__init__(
self, enable_build_accelerator=True, **kwargs)
self._config = config
def get_steps(self):
build_args_product = self._config['build_args_product']
build_args_official = self._config['build_args_official']
code_coverage = self._config['code_coverage']
steps = []
steps += [
unittest_step.BuildAffectedUnitTestsStep(
build_args_product=build_args_product,
build_args_official=build_args_official,
halt_on_failure=True, junit=True,
code_coverage=code_coverage, **self._step_kwargs),
unittest_step.RunAffectedUnitTestsStep(
report_url='', recipe_steps=steps,
build_args_product=build_args_product,
build_args_official=build_args_official,
enable_network_service=False, junit=True, **self._step_kwargs),
]
# If code coverage is enabled we must process coverage
# files and generate a report.
if code_coverage:
steps.append(
jacoco_coverage_processing_step.JacocoCoverageProcessingStep(
'coverage', build_args_product=build_args_product,
build_args_official=build_args_official, **self._step_kwargs
)
)
return steps