testing/variations/PRESUBMIT.py
def _ValidateExperimentConfig(experiment_config, create_message_fn):
  """Validates one config in a configuration entry."""
  if not isinstance(experiment_config, dict):
    return create_message_fn('Expecting dict for experiment config')
  if not 'experiments' in experiment_config:
    return create_message_fn('Missing valid experiments for experiment config')
  if not isinstance(experiment_config['experiments'], list):
    return create_message_fn('Expecting list for experiments')
  for experiment_group in experiment_config['experiments']:
    warnings = _ValidateExperimentGroup(experiment_group, create_message_fn)
    if warnings:
      return warnings
  if not 'platforms' in experiment_config:
    return create_message_fn('Missing valid platforms for experiment config')
  if not isinstance(experiment_config['platforms'], list):
    return create_message_fn('Expecting list for platforms')
  supported_platforms = [
      'android', 'android_weblayer', 'android_webview', 'chromeos',
      'chromeos_lacros', 'ios', 'linux', 'mac', 'windows'
  ]
  experiment_platforms = experiment_config['platforms']
  unsupported_platforms = list(
      set(experiment_platforms).difference(supported_platforms))
  if unsupported_platforms:
    return create_message_fn('Unsupported platforms %s', unsupported_platforms)
  return []
Validates one config in a configuration entry.
Validates one config in a configuration entry.
Validates one config in a configuration entry .
def _ValidateExperimentConfig(experiment_config, create_message_fn):
  if not isinstance(experiment_config, dict):
    return create_message_fn('Expecting dict for experiment config')
  if not 'experiments' in experiment_config:
    return create_message_fn('Missing valid experiments for experiment config')
  if not isinstance(experiment_config['experiments'], list):
    return create_message_fn('Expecting list for experiments')
  for experiment_group in experiment_config['experiments']:
    warnings = _ValidateExperimentGroup(experiment_group, create_message_fn)
    if warnings:
      return warnings
  if not 'platforms' in experiment_config:
    return create_message_fn('Missing valid platforms for experiment config')
  if not isinstance(experiment_config['platforms'], list):
    return create_message_fn('Expecting list for platforms')
  supported_platforms = [
      'android', 'android_weblayer', 'android_webview', 'chromeos',
      'chromeos_lacros', 'ios', 'linux', 'mac', 'windows'
  ]
  experiment_platforms = experiment_config['platforms']
  unsupported_platforms = list(
      set(experiment_platforms).difference(supported_platforms))
  if unsupported_platforms:
    return create_message_fn('Unsupported platforms %s', unsupported_platforms)
  return []
def _ValidateExperimentConfig ( experiment_config , create_message_fn ) : if not isinstance ( experiment_config , dict ) : return create_message_fn ( 'Expecting dict for experiment config' ) if not 'experiments' in experiment_config : return create_message_fn ( 'Missing valid experiments for experiment config' ) if not isinstance ( experiment_config [ 'experiments' ] , list ) : return create_message_fn ( 'Expecting list for experiments' ) for experiment_group in experiment_config [ 'experiments' ] : warnings = _ValidateExperimentGroup ( experiment_group , create_message_fn ) if warnings : return warnings if not 'platforms' in experiment_config : return create_message_fn ( 'Missing valid platforms for experiment config' ) if not isinstance ( experiment_config [ 'platforms' ] , list ) : return create_message_fn ( 'Expecting list for platforms' ) supported_platforms = [ 'android' , 'android_weblayer' , 'android_webview' , 'chromeos' , 'chromeos_lacros' , 'ios' , 'linux' , 'mac' , 'windows' ] experiment_platforms = experiment_config [ 'platforms' ] unsupported_platforms = list ( set ( experiment_platforms ) . difference ( supported_platforms ) ) if unsupported_platforms : return create_message_fn ( 'Unsupported platforms %s' , unsupported_platforms ) return [ ]
Validates one config in a configuration entry.
Validates one config in a configuration entry .
"""Validates one config in a configuration entry."""
experiment_config
create_message_fn