Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: tools/variations/fieldtrial_util_unittest.py

Issue 2373843002: Update fieldtrial_util To Handle Combined Fieldtrial Config Format (Closed)
Patch Set: Update Bootstrap Deps Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/variations/fieldtrial_util.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/variations/fieldtrial_util_unittest.py
diff --git a/tools/variations/fieldtrial_util_unittest.py b/tools/variations/fieldtrial_util_unittest.py
index 9d53a7f3ea837e298ec68ecb24633f1a0df64a3f..a215201a5fb43001544de8c5783d5435647b5639 100644
--- a/tools/variations/fieldtrial_util_unittest.py
+++ b/tools/variations/fieldtrial_util_unittest.py
@@ -11,68 +11,91 @@ import tempfile
class FieldTrialUtilUnittest(unittest.TestCase):
- def runGenerateArgs(self, config):
+ def runGenerateArgs(self, config, platform):
result = None
with tempfile.NamedTemporaryFile('w', delete=False) as base_file:
try:
base_file.write(config)
base_file.close()
- result = fieldtrial_util.GenerateArgs(base_file.name)
+ result = fieldtrial_util.GenerateArgs(base_file.name, platform)
finally:
os.unlink(base_file.name)
return result
def test_GenArgsEmptyPaths(self):
- args = fieldtrial_util.GenerateArgs('')
+ args = fieldtrial_util.GenerateArgs('', 'linux')
self.assertEqual([], args)
def test_GenArgsOneConfig(self):
config = '''{
"BrowserBlackList": [
- { "group_name": "Enabled" }
- ],
- "c": [
{
- "group_name": "d.",
- "params": {"url": "http://www.google.com"},
- "enable_features": ["x"],
- "disable_features": ["y"]
+ "platforms": ["win"],
+ "experiments": [{"name": "Enabled"}]
}
],
"SimpleParams": [
{
- "group_name": "Default",
- "params": {"id": "abc"},
- "enable_features": ["a", "b"]
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "Default",
+ "params": {"id": "abc"},
+ "enable_features": ["a", "b"]
+ }
+ ]
+ }
+ ],
+ "c": [
+ {
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "d.",
+ "params": {"url": "http://www.google.com"},
+ "enable_features": ["x"],
+ "disable_features": ["y"]
+ }
+ ]
}
]
}'''
- result = self.runGenerateArgs(config)
+ result = self.runGenerateArgs(config, 'win')
self.assertEqual(['--force-fieldtrials='
- 'BrowserBlackList/Enabled/c/d./SimpleParams/Default',
+ 'BrowserBlackList/Enabled/SimpleParams/Default/c/d.',
'--force-fieldtrial-params='
- 'c.d%2E:url/http%3A%2F%2Fwww%2Egoogle%2Ecom,'
- 'SimpleParams.Default:id/abc',
- '--enable-features=x,a,b',
+ 'SimpleParams.Default:id/abc,'
+ 'c.d%2E:url/http%3A%2F%2Fwww%2Egoogle%2Ecom',
+ '--enable-features=a,b,x',
'--disable-features=y'], result)
def test_DuplicateEnableFeatures(self):
config = '''{
"X": [
{
- "group_name": "x",
- "enable_features": ["x"]
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "x",
+ "enable_features": ["x"]
+ }
+ ]
}
],
"Y": [
{
- "group_name": "Default",
- "enable_features": ["x", "y"]
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "Default",
+ "enable_features": ["x", "y"]
+ }
+ ]
}
]
}'''
with self.assertRaises(Exception) as raised:
- self.runGenerateArgs(config)
+ self.runGenerateArgs(config, 'win')
self.assertEqual('Duplicate feature(s) in enable_features: x',
str(raised.exception))
@@ -80,19 +103,29 @@ class FieldTrialUtilUnittest(unittest.TestCase):
config = '''{
"X": [
{
- "group_name": "x",
- "enable_features": ["y", "z"]
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "x",
+ "enable_features": ["y", "z"]
+ }
+ ]
}
],
"Y": [
{
- "group_name": "Default",
- "enable_features": ["z", "x", "y"]
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "Default",
+ "enable_features": ["z", "x", "y"]
+ }
+ ]
}
]
}'''
with self.assertRaises(Exception) as raised:
- self.runGenerateArgs(config)
+ self.runGenerateArgs(config, 'win')
self.assertEqual('Duplicate feature(s) in enable_features: y, z',
str(raised.exception))
@@ -101,21 +134,31 @@ class FieldTrialUtilUnittest(unittest.TestCase):
config = '''{
"X": [
{
- "group_name": "x",
- "enable_features": ["x"]
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "x",
+ "enable_features": ["x"]
+ }
+ ]
}
],
"Y": [
{
- "group_name": "Default",
- "disable_features": ["x", "y"]
+ "platforms": ["win"],
+ "experiments": [
+ {
+ "name": "Default",
+ "disable_features": ["x", "y"]
+ }
+ ]
}
]
}'''
with self.assertRaises(Exception) as raised:
- self.runGenerateArgs(config)
+ self.runGenerateArgs(config, 'win')
self.assertEqual('Conflicting features set as both enabled and disabled: x',
str(raised.exception))
if __name__ == '__main__':
- unittest.main()
+ unittest.main()
« no previous file with comments | « tools/variations/fieldtrial_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698