| Index: tools/variations/fieldtrial_util.py
|
| diff --git a/tools/variations/fieldtrial_util.py b/tools/variations/fieldtrial_util.py
|
| index 024894ab21ea7f219151282a1878adbdcc5e158a..ae029aa45b0b9de702202420b707eda2c0363e17 100644
|
| --- a/tools/variations/fieldtrial_util.py
|
| +++ b/tools/variations/fieldtrial_util.py
|
| @@ -5,7 +5,6 @@
|
| import json
|
| import sys
|
|
|
| -import fieldtrial_to_struct
|
|
|
| def _hex(ch):
|
| hv = hex(ord(ch)).replace('0x', '')
|
| @@ -45,49 +44,45 @@
|
| raise Exception('Conflicting features set as both enabled and disabled: ' +
|
| ', '.join(features_in_both))
|
|
|
| -# Generate a list of command-line switches to enable field trials for the
|
| -# provided config_path and platform.
|
| -def GenerateArgs(config_path, platform):
|
| +# Generate a list of command-line switches to enable field trials defined in
|
| +# fieldtrial_testing_config_*.json.
|
| +def GenerateArgs(config_path):
|
| try:
|
| - with open(config_path, 'r') as config_file:
|
| - config = json.load(config_file)
|
| + with open(config_path, 'r') as base_file:
|
| + variations = json.load(base_file)
|
| except (IOError, ValueError):
|
| return []
|
|
|
| - platform_studies = fieldtrial_to_struct.ConfigToStudies(config, platform)
|
| -
|
| - studies = []
|
| + field_trials = []
|
| params = []
|
| enable_features = []
|
| disable_features = []
|
| -
|
| - for study in platform_studies:
|
| - study_name = study['name']
|
| - experiments = study['experiments']
|
| - # For now, only take the first experiment.
|
| - experiment = experiments[0]
|
| - selected_study = [study_name, experiment['name']]
|
| - studies.extend(selected_study)
|
| + for trial, groups in variations.iteritems():
|
| + if not len(groups):
|
| + continue
|
| + # For now, only take the first group.
|
| + group = groups[0]
|
| + trial_group = [trial, group['group_name']]
|
| + field_trials.extend(trial_group)
|
| param_list = []
|
| - if 'params' in experiment:
|
| - for param in experiment['params']:
|
| - param_list.append(param['key'])
|
| - param_list.append(param['value'])
|
| + if 'params' in group:
|
| + for key, value in group['params'].iteritems():
|
| + param_list.append(key)
|
| + param_list.append(value)
|
| if len(param_list):
|
| # Escape the variables for the command-line.
|
| - selected_study = [_escape(x) for x in selected_study]
|
| + trial_group = [_escape(x) for x in trial_group]
|
| param_list = [_escape(x) for x in param_list]
|
| - param = '%s:%s' % ('.'.join(selected_study), '/'.join(param_list))
|
| + param = '%s:%s' % ('.'.join(trial_group), '/'.join(param_list))
|
| params.append(param)
|
| - if 'enable_features' in experiment:
|
| - enable_features.extend(experiment['enable_features'])
|
| - if 'disable_features' in experiment:
|
| - disable_features.extend(experiment['disable_features'])
|
| -
|
| - if not len(studies):
|
| + if 'enable_features' in group:
|
| + enable_features.extend(group['enable_features'])
|
| + if 'disable_features' in group:
|
| + disable_features.extend(group['disable_features'])
|
| + if not len(field_trials):
|
| return []
|
| _CheckForDuplicateFeatures(enable_features, disable_features)
|
| - args = ['--force-fieldtrials=%s' % '/'.join(studies)]
|
| + args = ['--force-fieldtrials=%s' % '/'.join(field_trials)]
|
| if len(params):
|
| args.append('--force-fieldtrial-params=%s' % ','.join(params))
|
| if len(enable_features):
|
| @@ -98,15 +93,8 @@
|
|
|
| def main():
|
| if len(sys.argv) < 3:
|
| - print 'Usage: fieldtrial_util.py [config_path] [platform]'
|
| + print 'Usage: fieldtrial_util.py [base_config_path] [platform_config_path]'
|
| exit(-1)
|
| -
|
| - supported_platforms = ['android', 'chromeos', 'ios', 'linux', 'mac', 'win']
|
| - if sys.argv[2] not in supported_platforms:
|
| - print ('\'%s\' is an unknown platform. Supported platforms: %s' %
|
| - (sys.argv[2], supported_platforms))
|
| - exit(-1)
|
| -
|
| print GenerateArgs(sys.argv[1], sys.argv[2])
|
|
|
| if __name__ == '__main__':
|
|
|