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

Unified Diff: tools/variations/fieldtrial_util_unittest.py

Issue 1209743002: Generate a static struct from fieldtrial_testing_config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@codegen_nested_structs
Patch Set: add +x file permission Created 5 years, 5 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') | tools/variations/unittest_data/expected_output.h » ('j') | 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 1df6383e2201dc6ea91bf56c2910dc4f4479d40e..8f1c6d26a1a2e66dac233f0bcbf062bad0c1aaf4 100644
--- a/tools/variations/fieldtrial_util_unittest.py
+++ b/tools/variations/fieldtrial_util_unittest.py
@@ -3,18 +3,20 @@
# found in the LICENSE file.
import unittest
+
import fieldtrial_util
+import os
import tempfile
class FieldTrialUtilUnittest(unittest.TestCase):
def test_GenArgsEmptyPaths(self):
- args = fieldtrial_util.GenerateArgs('', '')
+ args = fieldtrial_util.GenerateArgs('')
self.assertEqual([], args)
def test_GenArgsOneConfig(self):
- with tempfile.NamedTemporaryFile('w') as base_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as base_file:
config = '''{
"BrowserBlackList": [
{ "group_name": "Enabled" }
@@ -32,43 +34,17 @@ class FieldTrialUtilUnittest(unittest.TestCase):
}
]
}'''
- base_file.write(config)
- base_file.flush()
-
- result = fieldtrial_util.GenerateArgs(base_file.name)
- self.assertEqual(['--force-fieldtrials='
- 'BrowserBlackList/Enabled/c/d./SimpleParams/Default',
- '--force-fieldtrial-params='
- 'c.d%2E:url/http%3A%2F%2Fwww%2Egoogle%2Ecom,'
- 'SimpleParams.Default:id/abc'], result)
-
- def test_GenArgsOverrideConfig(self):
- with tempfile.NamedTemporaryFile('w') as base_file:
- config = '''{
- "a": [
- { "group_name": "b" }
- ],
- "c": [
- { "group_name": "d" }
- ]
- }'''
- base_file.write(config)
- base_file.flush()
- with tempfile.NamedTemporaryFile('w') as platform_file:
- config = '''{
- "a": [
- { "group_name": "1" }
- ],
- "b": [
- { "group_name": "bgroup" }
- ]
- }'''
- platform_file.write(config)
- platform_file.flush()
- result = fieldtrial_util.GenerateArgs(base_file.name,
- platform_file.name)
+ try:
+ base_file.write(config)
+ base_file.close()
+ result = fieldtrial_util.GenerateArgs(base_file.name)
self.assertEqual(['--force-fieldtrials='
- 'a/1/c/d/b/bgroup'], result)
+ 'BrowserBlackList/Enabled/c/d./SimpleParams/Default',
+ '--force-fieldtrial-params='
+ 'c.d%2E:url/http%3A%2F%2Fwww%2Egoogle%2Ecom,'
+ 'SimpleParams.Default:id/abc'], result)
+ finally:
+ os.unlink(base_file.name)
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « tools/variations/fieldtrial_util.py ('k') | tools/variations/unittest_data/expected_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698