Title: [89808] trunk/Tools
- Revision
- 89808
- Author
- [email protected]
- Date
- 2011-06-27 01:41:55 -0700 (Mon, 27 Jun 2011)
Log Message
2011-06-27 Eric Seidel <[email protected]>
Reviewed by Adam Barth.
Remove evil uses of hasattr
https://bugs.webkit.org/show_bug.cgi?id=63430
For some reason these classes believe that they may be called with
various flavors of "option" elements and so carefully check to make
sure that the options element has their option before checking it.
We had a set_option_default method which was never called, so I made it
do what callsites seemed to want it to do and replaced 3 callers
who previously used hasattr manually to use set_option_default instead.
* Scripts/webkitpy/layout_tests/port/base.py:
* Scripts/webkitpy/layout_tests/port/webkit.py:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (89807 => 89808)
--- trunk/Tools/ChangeLog 2011-06-27 08:37:54 UTC (rev 89807)
+++ trunk/Tools/ChangeLog 2011-06-27 08:41:55 UTC (rev 89808)
@@ -1,3 +1,21 @@
+2011-06-27 Eric Seidel <[email protected]>
+
+ Reviewed by Adam Barth.
+
+ Remove evil uses of hasattr
+ https://bugs.webkit.org/show_bug.cgi?id=63430
+
+ For some reason these classes believe that they may be called with
+ various flavors of "option" elements and so carefully check to make
+ sure that the options element has their option before checking it.
+
+ We had a set_option_default method which was never called, so I made it
+ do what callsites seemed to want it to do and replaced 3 callers
+ who previously used hasattr manually to use set_option_default instead.
+
+ * Scripts/webkitpy/layout_tests/port/base.py:
+ * Scripts/webkitpy/layout_tests/port/webkit.py:
+
2011-06-27 Kent Tamura <[email protected]>
Reviewed by Hajime Morita.
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (89807 => 89808)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py 2011-06-27 08:37:54 UTC (rev 89807)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py 2011-06-27 08:41:55 UTC (rev 89808)
@@ -136,15 +136,12 @@
"bugs.webkit.org", "PrettyPatch", "prettify.rb")
self._pretty_patch_available = None
- if not hasattr(self._options, 'configuration') or self._options.configuration is None:
- self._options.configuration = self.default_configuration()
+ self.set_option_default('configuration', self.default_configuration())
self._test_configuration = None
self._multiprocessing_is_available = (multiprocessing is not None)
self._results_directory = None
+ self.set_option_default('use_apache', self._default_to_apache())
- if not hasattr(self._options, 'use_apache') or self._options.use_apache is None:
- self._options.use_apache = self._default_to_apache()
-
def wdiff_available(self):
if self._wdiff_available is None:
self._wdiff_available = self.check_wdiff(logging=False)
@@ -582,7 +579,9 @@
return default_value
def set_option_default(self, name, default_value):
- if not hasattr(self._options, name):
+ # FIXME: Callers could also use optparse_parser.Values.ensure_value,
+ # since this should always be a optparse_parser.Values object.
+ if not hasattr(self._options, name) or getattr(self._options, name) is None:
return setattr(self._options, name, default_value)
def path_from_webkit_base(self, *comps):
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py (89807 => 89808)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py 2011-06-27 08:37:54 UTC (rev 89807)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py 2011-06-27 08:41:55 UTC (rev 89808)
@@ -55,10 +55,8 @@
base.Port.__init__(self, **kwargs)
self._cached_apache_path = None
- # FIXME: disable pixel tests until they are run by default on the
- # build machines.
- if not hasattr(self._options, "pixel_tests") or self._options.pixel_tests == None:
- self._options.pixel_tests = False
+ # FIXME: disable pixel tests until they are run by default on the build machines.
+ self.set_option_default("pixel_tests", False)
def baseline_search_path(self):
return [self._webkit_baseline_path(self._name)]
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes