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

Unified Diff: tools/chrome_proxy/webdriver/common.py

Issue 2538773004: Fix cmd line args override in common.py (Closed)
Patch Set: Created 4 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/chrome_proxy/webdriver/common.py
diff --git a/tools/chrome_proxy/webdriver/common.py b/tools/chrome_proxy/webdriver/common.py
index 794918fcddcedfbfa3a24e996a32d86efd568b8e..0690de24e640348de6e1101e2001177c38e06717 100644
--- a/tools/chrome_proxy/webdriver/common.py
+++ b/tools/chrome_proxy/webdriver/common.py
@@ -77,11 +77,24 @@ class TestDriver:
def _OverrideChromeArgs(self):
"""
- Overrides any given flags in the code with those given on the command line.
+ Overrides any given arguments in the code with those given on the command
RyanSturm 2016/11/30 20:46:36 I'm a little confused about how this is used. Can
Robert Ogden 2016/12/01 01:23:04 CL description improved, but yes you were correct.
RyanSturm 2016/12/01 01:32:11 SGTM.
+ line. Arguments that need to be overridden may contain different values for
+ a flag given in the code. In that case, check by the flag whether to
+ override the argument.
"""
+ def GetDictKey(argument):
+ return argument.split('=', 1)[0]
if self._flags.browser_args and len(self._flags.browser_args) > 0:
- for arg in shlex.split(self._flags.browser_args):
- self._chrome_args.add(arg)
+ # Build a dict of flags mapped to the whole argument.
+ originalArgs = {}
RyanSturm 2016/11/30 20:46:36 s/originalArgs/original_args/ AFAIK naming for py
Robert Ogden 2016/12/01 01:23:04 Done.
+ for arg in self._chrome_args:
+ originalArgs[GetDictKey(arg)] = arg
+ # Override by flag.
+ for overrideArg in shlex.split(self._flags.browser_args):
RyanSturm 2016/11/30 20:46:36 s/overrideArg/override_arg/
Robert Ogden 2016/12/01 01:23:04 Done.
+ argKey = GetDictKey(overrideArg)
RyanSturm 2016/11/30 20:46:36 s/argKey/arg_key/
Robert Ogden 2016/12/01 01:23:04 Done.
+ if argKey in originalArgs:
+ self._chrome_args.remove(originalArgs[argKey])
+ self._chrome_args.add(overrideArg)
def _StartDriver(self):
"""
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698