summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorgwilson@google.com <gwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 22:44:14 +0000
committergwilson@google.com <gwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 22:44:14 +0000
commitaea5c1ff5fddfbb51f2861dea0e7a2876dac28e0 (patch)
tree32a35e034b2e2dd2e6f7edcea1d457dcadd27280 /webkit
parentd546029a268e19c244bcbfba57e4bd2d39d44a83 (diff)
downloadchromium_src-aea5c1ff5fddfbb51f2861dea0e7a2876dac28e0.zip
chromium_src-aea5c1ff5fddfbb51f2861dea0e7a2876dac28e0.tar.gz
chromium_src-aea5c1ff5fddfbb51f2861dea0e7a2876dac28e0.tar.bz2
Modifies the layout test formatter to not have any dependencies on chromium_utils. This should allow it to run on Mac successfully.
Also adds some methods to path_utils that only existed in src-buildbot/chromium_utils. These did not exist anywhere else under webkit/tools/. R=ojan BUG=none TEST=run "test_output_formatter.sh -v -i" on Mac, it should not fail. Review URL: http://codereview.chromium.org/271035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28614 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/layout_tests/layout_package/failure_finder.py17
-rw-r--r--webkit/tools/layout_tests/layout_package/path_utils.py60
2 files changed, 69 insertions, 8 deletions
diff --git a/webkit/tools/layout_tests/layout_package/failure_finder.py b/webkit/tools/layout_tests/layout_package/failure_finder.py
index 62b6ce1..1e37928 100644
--- a/webkit/tools/layout_tests/layout_package/failure_finder.py
+++ b/webkit/tools/layout_tests/layout_package/failure_finder.py
@@ -6,12 +6,13 @@
# 2. Change text_expectations parsing to existing
# logic in layout_pagckage.test_expectations.
-import chromium_utils
import difflib
import errno
import os
import path_utils
+import platform_utils
import re
+import shutil
import subprocess
import sys
import urllib2
@@ -425,8 +426,8 @@ class FailureFinder(object):
if self.delete_zip_file:
if self.verbose:
print "Cleaning up zip file..."
- chromium_utils.RemoveDirectory(TEMP_ZIP_DIR)
- chromium_utils.RemoveFile(filename)
+ path_utils.RemoveDirectory(TEMP_ZIP_DIR)
+ os.remove(filename)
return True
else:
if self.verbose:
@@ -528,7 +529,7 @@ class FailureFinder(object):
if test_path_key in dict:
local_baseline = dict[test_path_key]
url_of_baseline = local_baseline
- chromium_utils.CopyFileToDir(local_baseline, local_directory)
+ shutil.copy(local_baseline, local_directory)
elif self.verbose:
print "Baseline %s does not exist in the index." % test_path_key
else:
@@ -573,9 +574,9 @@ class FailureFinder(object):
self.webkit_baseline_dict = {}
base = os.path.abspath(os.path.curdir)
- webkit_base = chromium_utils.FindUpward(base, 'third_party', 'Webkit',
- 'LayoutTests')
- chromium_base = chromium_utils.FindUpward(base, 'data', 'layout_tests')
+ webkit_base = path_utils.PathFromBase('third_party', 'Webkit',
+ 'LayoutTests')
+ chromium_base = path_utils.PathFromBase('webkit', 'data', 'layout_tests')
chromium_base_platform = os.path.join(chromium_base, PLATFORM)
webkit_base_platform = os.path.join(webkit_base, PLATFORM)
@@ -765,7 +766,7 @@ class FailureFinder(object):
dir = os.path.join(os.path.split(file_to_create)[0:-1])[0]
CreateDirectory(dir)
file = os.path.normpath(os.path.join(TEMP_ZIP_DIR, file_in_zip))
- chromium_utils.CopyFileToDir(file, dir)
+ shutil.copy(file, dir)
def _ExtractFileFromZip(self, zip, file_in_zip, file_to_create):
modifiers = ""
diff --git a/webkit/tools/layout_tests/layout_package/path_utils.py b/webkit/tools/layout_tests/layout_package/path_utils.py
index 39e8d13..da0c705 100644
--- a/webkit/tools/layout_tests/layout_package/path_utils.py
+++ b/webkit/tools/layout_tests/layout_package/path_utils.py
@@ -12,6 +12,7 @@ us including a few things that don't really have anything to do
import errno
import os
+import stat
import sys
import platform_utils
@@ -245,6 +246,65 @@ def PathFromBase(*comps):
raise PathNotFound('could not find %s' % (path))
return path
+def RemoveDirectory(*path):
+ """Recursively removes a directory, even if it's marked read-only.
+
+ Remove the directory located at *path, if it exists.
+
+ shutil.rmtree() doesn't work on Windows if any of the files or directories
+ are read-only, which svn repositories and some .svn files are. We need to
+ be able to force the files to be writable (i.e., deletable) as we traverse
+ the tree.
+
+ Even with all this, Windows still sometimes fails to delete a file, citing
+ a permission error (maybe something to do with antivirus scans or disk
+ indexing). The best suggestion any of the user forums had was to wait a
+ bit and try again, so we do that too. It's hand-waving, but sometimes it
+ works. :/
+ """
+ file_path = os.path.join(*path)
+ if not os.path.exists(file_path):
+ return
+
+ win32 = False
+ if sys.platform == 'win32':
+ win32 = True
+ # Some people don't have the APIs installed. In that case we'll do without.
+ try:
+ win32api = __import__('win32api')
+ win32con = __import__('win32con')
+ except ImportError:
+ win32 = False
+
+ def remove_with_retry(rmfunc, path):
+ os.chmod(path, stat.S_IWRITE)
+ if win32:
+ win32api.SetFileAttributes(path, win32con.FILE_ATTRIBUTE_NORMAL)
+ try:
+ return rmfunc(path)
+ except EnvironmentError, e:
+ if e.errno != errno.EACCES:
+ raise
+ print 'Failed to delete %s: trying again' % repr(path)
+ time.sleep(0.1)
+ return rmfunc(path)
+ else:
+ def remove_with_retry(rmfunc, path):
+ if os.path.islink(path):
+ return os.remove(path)
+ else:
+ return rmfunc(path)
+
+ for root, dirs, files in os.walk(file_path, topdown=False):
+ # For POSIX: making the directory writable guarantees removability.
+ # Windows will ignore the non-read-only bits in the chmod value.
+ os.chmod(root, 0770)
+ for name in files:
+ remove_with_retry(os.remove, os.path.join(root, name))
+ for name in dirs:
+ remove_with_retry(os.rmdir, os.path.join(root, name))
+
+ remove_with_retry(os.rmdir, file_path)
#
# Wrappers around platform_utils