Diff
Modified: trunk/Tools/ChangeLog (126370 => 126371)
--- trunk/Tools/ChangeLog 2012-08-23 00:38:08 UTC (rev 126370)
+++ trunk/Tools/ChangeLog 2012-08-23 00:59:54 UTC (rev 126371)
@@ -1,3 +1,47 @@
+2012-08-22 Dirk Pranke <[email protected]>
+
+ add debug info, another test to webkit-patch optimize-baselines
+ https://bugs.webkit.org/show_bug.cgi?id=94762
+
+ Reviewed by Adam Barth.
+
+ This patch adds more debug logging for optimize-baselines so
+ that you can tell the before and after states and figure out
+ what the command is actually deciding to do.
+
+ Also, this command adds a (disabled) test for the problem in bug
+ 94665. It's disabled because we don't have the fix yet (that
+ will be posted in a patch to that bug).
+
+ There should be no functional changes in this patch apart from
+ the additional logging.
+
+ Note that adding the debug logging exposed a bug in
+ filesystem_mock.relpath() (that would return None if the path
+ wasn't a subpath of the start); the real relpath computes a
+ relpath with parent dirs. Fixing this revealed a bad check in
+ the style checker's change_directory() call which was checking
+ for None.
+
+ * Scripts/webkitpy/common/checkout/baselineoptimizer.py:
+ (BaselineOptimizer._find_optimal_result_placement):
+ (BaselineOptimizer):
+ (BaselineOptimizer._optimize_by_most_specific_common_directory):
+ (BaselineOptimizer._move_baselines):
+ (BaselineOptimizer.optimize):
+ * Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py:
+ (BaselineOptimizerTest.disabled_test_platform_mac_different):
+ * Scripts/webkitpy/common/system/filesystem.py:
+ (FileSystem):
+ * Scripts/webkitpy/common/system/filesystem_mock.py:
+ (MockFileSystem):
+ (MockFileSystem.__init__):
+ (MockFileSystem.relpath):
+ * Scripts/webkitpy/common/system/filesystem_unittest.py:
+ (RealFileSystemTest.test_sep):
+ * Scripts/webkitpy/style/main.py:
+ (change_directory):
+
2012-08-22 Alejandro PiƱeiro <[email protected]>
Dojo toggle buttons should expose ROLE_TOGGLE_BUTTON not ROLE_PUSH_BUTTON
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer.py (126370 => 126371)
--- trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer.py 2012-08-23 00:38:08 UTC (rev 126370)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer.py 2012-08-23 00:59:54 UTC (rev 126371)
@@ -26,7 +26,11 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import logging
+
+_log = logging.getLogger(__name__)
+
# Yes, it's a hypergraph.
# FIXME: Should this function live with the ports somewhere?
# Perhaps this should move onto PortFactory?
@@ -121,6 +125,13 @@
results_by_port_name = self._results_by_port_name(results_by_directory)
port_names_by_result = _invert_dictionary(results_by_port_name)
+ results_by_directory, new_results_by_directory = self._optimize_by_most_specific_common_directory(results_by_directory, results_by_port_name, port_names_by_result)
+ if not new_results_by_directory:
+ pass # FIXME: Try something else.
+
+ return results_by_directory, new_results_by_directory
+
+ def _optimize_by_most_specific_common_directory(self, results_by_directory, results_by_port_name, port_names_by_result):
new_results_by_directory = {}
unsatisfied_port_names_by_result = port_names_by_result
while unsatisfied_port_names_by_result:
@@ -157,7 +168,12 @@
if new_results_by_directory.get(directory) != result:
file_names.append(self._filesystem.join(self._scm.checkout_root, directory, baseline_name))
if file_names:
+ _log.debug("deleting:")
+ for filename in file_names:
+ _log.debug(" " + self._filesystem.relpath(filename, self._scm.checkout_root).replace(baseline_name, ''))
self._scm.delete_list(file_names)
+ else:
+ _log.debug("nothing to delete")
file_names = []
for directory, result in new_results_by_directory.items():
@@ -167,7 +183,12 @@
self._filesystem.write_binary_file(destination, data_for_result[result])
file_names.append(destination)
if file_names:
+ _log.debug("adding:")
+ for filename in file_names:
+ _log.debug(" " + self._filesystem.relpath(filename, self._scm.checkout_root).replace(baseline_name, ''))
self._scm.add_list(file_names)
+ else:
+ _log.debug("nothing to add")
def directories_by_result(self, baseline_name):
results_by_directory = self._read_results_by_directory(baseline_name)
@@ -175,7 +196,20 @@
def optimize(self, baseline_name):
results_by_directory, new_results_by_directory = self._find_optimal_result_placement(baseline_name)
+ self.new_results_by_directory = new_results_by_directory
+ if new_results_by_directory == results_by_directory:
+ _log.debug("No optimization found, optimal?")
+ return True
if self._filtered_results_by_port_name(results_by_directory) != self._filtered_results_by_port_name(new_results_by_directory):
+ _log.warning("Optimization failed")
return False
+
+ _log.debug("before: ")
+ for path, result in results_by_directory.items():
+ _log.debug(" %s: %s" % (self._filesystem.relpath(path, self._scm.checkout_root).replace(baseline_name, ''), result[0:6]))
+ _log.debug("after: ")
+ for path, result in new_results_by_directory.items():
+ _log.debug(" %s: %s" % (self._filesystem.relpath(path, self._scm.checkout_root).replace(baseline_name, ''), result[0:6]))
+
self._move_baselines(baseline_name, results_by_directory, new_results_by_directory)
return True
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py (126370 => 126371)
--- trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py 2012-08-23 00:38:08 UTC (rev 126370)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/baselineoptimizer_unittest.py 2012-08-23 00:59:54 UTC (rev 126371)
@@ -74,6 +74,20 @@
})
self.assertEqual(host.filesystem.read_binary_file('/mock-checkout/LayoutTests/platform/chromium/another/test-expected.txt'), 'result A')
+ def disabled_test_platform_mac_different(self):
+ self._assertOptimization({
+ 'LayoutTests': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
+ 'LayoutTests/platform/mac': '453e67177a75b2e79905154ece0efba6e5bfb65d',
+ 'LayoutTests/platform/mac-lion': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
+ 'LayoutTests/platform/chromium-mac': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
+ 'LayoutTests/platform/chromium-win': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
+ }, {
+ 'LayoutTests': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
+ 'LayoutTests/platform/mac': '453e67177a75b2e79905154ece0efba6e5bfb65d',
+ 'LayoutTests/platform/mac-lion': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
+ 'LayoutTests/platform/chromium': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
+ })
+
def test_chromium_linux_redundant_with_win(self):
self._assertOptimization({
'LayoutTests/platform/chromium-win': '462d03b9c025db1b0392d7453310dbee5f9a9e74',
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem.py (126370 => 126371)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2012-08-23 00:38:08 UTC (rev 126370)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2012-08-23 00:59:54 UTC (rev 126371)
@@ -44,14 +44,9 @@
Unless otherwise noted, all paths are allowed to be either absolute
or relative."""
- def __init__(self):
- self._sep = os.sep
+ sep = os.sep
+ pardir = os.pardir
- def _get_sep(self):
- return self._sep
-
- sep = property(_get_sep, doc="pathname separator")
-
def abspath(self, path):
return os.path.abspath(path)
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py (126370 => 126371)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2012-08-23 00:38:08 UTC (rev 126370)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2012-08-23 00:59:54 UTC (rev 126371)
@@ -36,6 +36,9 @@
class MockFileSystem(object):
+ sep = '/'
+ pardir = '..'
+
def __init__(self, files=None, dirs=None, cwd='/'):
"""Initializes a "mock" filesystem that can be used to completely
stub out a filesystem.
@@ -48,7 +51,6 @@
self.files = files or {}
self.written_files = {}
self.last_tmpdir = None
- self._sep = '/'
self.current_tmpno = 0
self.cwd = cwd
self.dirs = set(dirs or [])
@@ -59,11 +61,6 @@
self.dirs.add(d)
d = self.dirname(d)
- def _get_sep(self):
- return self._sep
-
- sep = property(_get_sep, doc="pathname separator")
-
def clear_written_files(self):
# This function can be used to track what is written between steps in a test.
self.written_files = {}
@@ -343,8 +340,8 @@
path = self.abspath(path)
if not path.lower().startswith(start.lower()):
- # Then path is outside the directory given by start.
- return None # FIXME: os.relpath still returns a path here.
+ # path is outside the directory given by start; compute path from root
+ return '../' * start.count('/') + path
rel_path = path[len(start):]
@@ -359,7 +356,8 @@
else:
# We are in the case typified by the following example:
# path = "/tmp/foobar", start = "/tmp/foo" -> rel_path = "bar"
- return None
+ # FIXME: We return a less-than-optimal result here.
+ return '../' * start.count('/') + path
return rel_path
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py (126370 => 126371)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py 2012-08-23 00:38:08 UTC (rev 126370)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py 2012-08-23 00:59:54 UTC (rev 126371)
@@ -255,11 +255,6 @@
self.assertEquals(fs.join("foo", "bar"),
os.path.join("foo", "bar"))
- def test_sep__is_readonly(self):
- def assign_sep():
- fs.sep = ' '
- fs = FileSystem()
- self.assertRaises(AttributeError, assign_sep)
if __name__ == '__main__':
unittest.main()
Modified: trunk/Tools/Scripts/webkitpy/style/main.py (126370 => 126371)
--- trunk/Tools/Scripts/webkitpy/style/main.py 2012-08-23 00:38:08 UTC (rev 126370)
+++ trunk/Tools/Scripts/webkitpy/style/main.py 2012-08-23 00:59:54 UTC (rev 126371)
@@ -68,7 +68,7 @@
rel_paths = []
for path in paths:
rel_path = filesystem.relpath(path, checkout_root)
- if rel_path is None:
+ if rel_path.startswith(filesystem.pardir):
# Then the path is not below the checkout root. Since all
# paths should be interpreted relative to the same root,
# do not interpret any of the paths as relative to the