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

Unified Diff: build/android/pylib/flag_changer.py

Issue 1414403002: Add CommandLineArgumentParameter and use it for WebView tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-cr-526885-read-nested-annotations
Patch Set: Comments addressed Created 5 years, 1 month 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
Index: build/android/pylib/flag_changer.py
diff --git a/build/android/pylib/flag_changer.py b/build/android/pylib/flag_changer.py
index 28580c757dc7997547d877bbe3d0a758572969d5..5b9021f4ed0025baea2ce16ed81400a545a9115e 100644
--- a/build/android/pylib/flag_changer.py
+++ b/build/android/pylib/flag_changer.py
@@ -56,9 +56,7 @@ class FlagChanger(object):
Args:
flags: A sequence of flags to add on, eg. ['--single-process'].
"""
- new_flags = self._state_stack[-1].copy()
- new_flags.update(flags)
- self.ReplaceFlags(new_flags)
+ self.PushFlags(add=flags)
def RemoveFlags(self, flags):
"""Removes flags from the command line, if they exist.
@@ -74,8 +72,25 @@ class FlagChanger(object):
to remove a switch with a value, you must use the exact string
used to add it in the first place.
"""
+ self.PushFlags(remove=flags)
+
+ def PushFlags(self, add=None, remove=None):
+ """Appends and removes flags to/from the command line if they aren't already
+ there. Saves the current flags state on the stack, so a call to Restore
+ will change the state back to the one preceeding the call to PushFlags.
+
+ Args:
+ add: A list of flags to add on, eg. ['--single-process'].
+ remove: A list of flags to remove, eg. ['--single-process']. Note that we
+ expect a complete match when removing flags; if you want to remove
+ a switch with a value, you must use the exact string used to add
+ it in the first place.
+ """
new_flags = self._state_stack[-1].copy()
- new_flags.difference_update(flags)
+ if add:
+ new_flags.update(add)
+ if remove:
+ new_flags.difference_update(remove)
self.ReplaceFlags(new_flags)
def Restore(self):

Powered by Google App Engine
This is Rietveld 408576698