in utils/benchmark_config.py [0:0]
def _parse_unit(cls, unit):
"""Performs parsing of a benchmarking unit.
Also fills up default values for attributes if they're not specified.
Args:
unit: the benchmarking unit.
Returns:
A dictionary that contains various attributes of the benchmarking unit.
"""
parsed_unit = copy.copy(cls._DEFAULT_VALS)
parsed_unit.update(unit)
if 'command' not in unit or not isinstance(unit['command'], str):
raise ValueError('A command has to be specified either as a global option'
' or in each individual benchmarking unit.')
full_command_tokens = shlex.split(unit['command'])
startup_options = []
while full_command_tokens and full_command_tokens[0].startswith('--'):
startup_options.append(full_command_tokens.pop(0))
try:
command = full_command_tokens.pop(0)
except IndexError:
raise ValueError('\'%s\' does not contain a Blaze command (e.g. build)' %
unit['command'])
options = []
while full_command_tokens and full_command_tokens[0].startswith('--'):
options.append(full_command_tokens.pop(0))
# This is a workaround for https://github.com/bazelbuild/bazel/issues/3236.
if sys.platform.startswith('linux'):
options.append('--sandbox_tmpfs_path=/tmp')
targets = full_command_tokens
# Attributes that need special handling.
parsed_unit['startup_options'] = startup_options
parsed_unit['command'] = command
parsed_unit['options'] = options
parsed_unit['targets'] = targets
return parsed_unit