diff options
Diffstat (limited to 'Tools/Scripts/webkitpy/common')
26 files changed, 55 insertions, 245 deletions
diff --git a/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py b/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py index 0221bcee9..db4a55b06 100644 --- a/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py +++ b/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py @@ -26,8 +26,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - import codecs import os import tempfile diff --git a/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py b/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py index 3b0943247..78d25cb31 100644 --- a/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py +++ b/Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py @@ -26,8 +26,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - import codecs import os import shutil diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/git.py b/Tools/Scripts/webkitpy/common/checkout/scm/git.py index 866b24cc4..ab96b8fa7 100644 --- a/Tools/Scripts/webkitpy/common/checkout/scm/git.py +++ b/Tools/Scripts/webkitpy/common/checkout/scm/git.py @@ -34,7 +34,6 @@ import re from webkitpy.common.memoized import memoized from webkitpy.common.system.deprecated_logging import log from webkitpy.common.system.executive import Executive, ScriptError -from webkitpy.common.system import ospath from .commitmessage import CommitMessage from .scm import AuthenticationError, SCM, commit_error_handler @@ -229,9 +228,9 @@ class Git(SCM, SVNRepository): def display_name(self): return "git" - def head_svn_revision(self): + def svn_revision(self, path): _log.debug('Running git.head_svn_revision... (Temporary logging message)') - git_log = self.run(['git', 'log', '-25']) + git_log = self.run(['git', 'log', '-25', path]) match = re.search("^\s*git-svn-id:.*@(?P<svn_revision>\d+)\ ", git_log, re.MULTILINE) if not match: return "" diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/scm.py b/Tools/Scripts/webkitpy/common/checkout/scm/scm.py index 4b581b17f..432d6ca99 100644 --- a/Tools/Scripts/webkitpy/common/checkout/scm/scm.py +++ b/Tools/Scripts/webkitpy/common/checkout/scm/scm.py @@ -182,6 +182,9 @@ class SCM: self._subclass_must_implement() def head_svn_revision(self): + return self.svn_revision(self.checkout_root) + + def svn_revision(self, path): self._subclass_must_implement() def create_patch(self, git_commit=None, changed_files=None): diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py b/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py index 78af67c98..f203cfa1a 100644 --- a/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py +++ b/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py @@ -68,6 +68,9 @@ class MockSCM(object): def head_svn_revision(self): return 1234 + def svn_revision(self, path): + return 5678 + def create_patch(self, git_commit, changed_files=None): return "Patch1" diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py b/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py index 209bd3510..b835cdf67 100644 --- a/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py +++ b/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py @@ -28,8 +28,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - import atexit import base64 import codecs diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/svn.py b/Tools/Scripts/webkitpy/common/checkout/scm/svn.py index 3f583a7d3..edeee30ae 100644 --- a/Tools/Scripts/webkitpy/common/checkout/scm/svn.py +++ b/Tools/Scripts/webkitpy/common/checkout/scm/svn.py @@ -36,7 +36,6 @@ import sys from webkitpy.common.memoized import memoized from webkitpy.common.system.deprecated_logging import log from webkitpy.common.system.executive import Executive, ScriptError -from webkitpy.common.system import ospath from .scm import AuthenticationError, SCM, commit_error_handler @@ -237,8 +236,8 @@ class SVN(SCM, SVNRepository): def display_name(self): return "svn" - def head_svn_revision(self): - return self.value_from_svn_info(self.checkout_root, 'Revision') + def svn_revision(self, path): + return self.value_from_svn_info(path, 'Revision') # FIXME: This method should be on Checkout. def create_patch(self, git_commit=None, changed_files=None): diff --git a/Tools/Scripts/webkitpy/common/config/committers.py b/Tools/Scripts/webkitpy/common/config/committers.py index 6e7399ecb..43a9c68c1 100644 --- a/Tools/Scripts/webkitpy/common/config/committers.py +++ b/Tools/Scripts/webkitpy/common/config/committers.py @@ -199,7 +199,6 @@ committers_unable_to_review = [ Committer("Chris Evans", ["cevans@google.com", "cevans@chromium.org"]), Committer("Chris Guillory", ["ctguil@chromium.org", "chris.guillory@google.com"], "ctguil"), Committer("Chris Petersen", "cpetersen@apple.com", "cpetersen"), - Committer("Chris Rogers", "crogers@google.com", "crogers"), Committer("Christian Dywan", ["christian@twotoasts.de", "christian@webkit.org", "christian@lanedo.com"]), Committer("Collin Jackson", "collinj@webkit.org", "collinjackson"), Committer("Cris Neckar", "cdn@chromium.org", "cneckar"), @@ -295,7 +294,6 @@ committers_unable_to_review = [ Committer("Maxime Britto", ["maxime.britto@gmail.com", "britto@apple.com"]), Committer("Maxime Simon", ["simon.maxime@gmail.com", "maxime.simon@webkit.org"], "maxime.simon"), Committer("Michael Nordman", "michaeln@google.com", "michaeln"), - Committer("Michael Saboff", "msaboff@apple.com"), Committer("Michelangelo De Simone", "michelangelo@webkit.org", "michelangelo"), Committer("Mihnea Ovidenie", "mihnea@adobe.com", "mihnea"), Committer("Mike Belshe", ["mbelshe@chromium.org", "mike@belshe.com"]), @@ -395,6 +393,7 @@ reviewers_list = [ Reviewer("Chris Marrin", "cmarrin@apple.com", "cmarrin"), Reviewer("Chris Fleizach", "cfleizach@apple.com", "cfleizach"), Reviewer("Chris Jerdonek", "cjerdonek@webkit.org", "cjerdonek"), + Reviewer("Chris Rogers", "crogers@google.com", "crogers"), Reviewer(u"Csaba Osztrogon\u00e1c", "ossy@webkit.org", "ossy"), Reviewer("Dan Bernstein", ["mitz@webkit.org", "mitz@apple.com"], "mitzpettel"), Reviewer("Daniel Bates", ["dbates@webkit.org", "dbates@rim.com"], "dydz"), @@ -444,6 +443,7 @@ reviewers_list = [ Reviewer("Maciej Stachowiak", "mjs@apple.com", "othermaciej"), Reviewer("Mark Rowe", "mrowe@apple.com", "bdash"), Reviewer("Martin Robinson", ["mrobinson@webkit.org", "mrobinson@igalia.com", "martin.james.robinson@gmail.com"], "mrobinson"), + Reviewer("Michael Saboff", "msaboff@apple.com", "msaboff"), Reviewer("Mihai Parparita", "mihaip@chromium.org", "mihaip"), Reviewer("Nate Chapin", "japhet@chromium.org", ["japhet", "natechapin"]), Reviewer("Nikolas Zimmermann", ["zimmermann@kde.org", "zimmermann@physik.rwth-aachen.de", "zimmermann@webkit.org", "nzimmermann@rim.com"], "wildfox"), diff --git a/Tools/Scripts/webkitpy/common/net/buildbot/buildbot.py b/Tools/Scripts/webkitpy/common/net/buildbot/buildbot.py index e84fcbffd..1cb2bddf9 100644 --- a/Tools/Scripts/webkitpy/common/net/buildbot/buildbot.py +++ b/Tools/Scripts/webkitpy/common/net/buildbot/buildbot.py @@ -25,15 +25,8 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# WebKit's Python module for interacting with WebKit's buildbot - -try: - import json -except ImportError: - # python 2.5 compatibility - import webkitpy.thirdparty.simplejson as json +import json import operator import re import urllib diff --git a/Tools/Scripts/webkitpy/common/net/credentials_unittest.py b/Tools/Scripts/webkitpy/common/net/credentials_unittest.py index 59048591f..2ab160c88 100644 --- a/Tools/Scripts/webkitpy/common/net/credentials_unittest.py +++ b/Tools/Scripts/webkitpy/common/net/credentials_unittest.py @@ -26,8 +26,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - import os import tempfile import unittest diff --git a/Tools/Scripts/webkitpy/common/net/file_uploader.py b/Tools/Scripts/webkitpy/common/net/file_uploader.py index aa3488bbf..339045e6a 100644 --- a/Tools/Scripts/webkitpy/common/net/file_uploader.py +++ b/Tools/Scripts/webkitpy/common/net/file_uploader.py @@ -27,8 +27,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - import codecs import mimetypes import socket diff --git a/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py b/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py index 6120713eb..99e8528de 100644 --- a/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py +++ b/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py @@ -27,11 +27,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -try: - import json -except ImportError: - # python 2.5 compatibility - import webkitpy.thirdparty.simplejson as json +import json from webkitpy.common.memoized import memoized from webkitpy.common.system.deprecated_logging import log diff --git a/Tools/Scripts/webkitpy/common/newstringio_unittest.py b/Tools/Scripts/webkitpy/common/newstringio_unittest.py index 5755c9814..1ee2fb91f 100644 --- a/Tools/Scripts/webkitpy/common/newstringio_unittest.py +++ b/Tools/Scripts/webkitpy/common/newstringio_unittest.py @@ -29,8 +29,6 @@ """Unit tests for newstringio module.""" -from __future__ import with_statement - import unittest import newstringio diff --git a/Tools/Scripts/webkitpy/common/system/autoinstall.py b/Tools/Scripts/webkitpy/common/system/autoinstall.py index 4ffcccc64..a928db63a 100755 --- a/Tools/Scripts/webkitpy/common/system/autoinstall.py +++ b/Tools/Scripts/webkitpy/common/system/autoinstall.py @@ -31,8 +31,6 @@ """Support for automatically downloading Python packages from an URL.""" -from __future__ import with_statement - import codecs import logging import new @@ -261,43 +259,6 @@ class AutoInstaller(object): return target_path - # This is a replacement for ZipFile.extractall(), which is - # available in Python 2.6 but not in earlier versions. - def _extract_all(self, zip_file, target_dir): - self._log_transfer("Extracting zip file...", zip_file, target_dir) - - # This is helpful for debugging purposes. - _log.debug("Listing zip file contents...") - for name in zip_file.namelist(): - _log.debug(' * "%s"' % name) - - for name in zip_file.namelist(): - path = os.path.join(target_dir, name) - self._log_transfer("Extracting...", name, path) - - if not os.path.basename(path): - # Then the path ends in a slash, so it is a directory. - self._create_directory(path) - continue - # Otherwise, it is a file. - - try: - # We open this file w/o encoding, as we're reading/writing - # the raw byte-stream from the zip file. - outfile = open(path, 'wb') - except IOError, err: - # Not all zip files seem to list the directories explicitly, - # so try again after creating the containing directory. - _log.debug("Got IOError: retrying after creating directory...") - dir = os.path.dirname(path) - self._create_directory(dir) - outfile = open(path, 'wb') - - try: - outfile.write(zip_file.read(name)) - finally: - outfile.close() - def _unzip(self, path, scratch_dir): # zipfile.extractall() extracts to a path without the # trailing ".zip". @@ -315,7 +276,7 @@ class AutoInstaller(object): raise Exception(message) try: - self._extract_all(zip_file, scratch_dir) + zip_file.extractall(scratch_dir) finally: zip_file.close() diff --git a/Tools/Scripts/webkitpy/common/system/crashlogs.py b/Tools/Scripts/webkitpy/common/system/crashlogs.py index 06b0d12d7..a6b6575f6 100644 --- a/Tools/Scripts/webkitpy/common/system/crashlogs.py +++ b/Tools/Scripts/webkitpy/common/system/crashlogs.py @@ -26,8 +26,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - import os import re import sys diff --git a/Tools/Scripts/webkitpy/common/system/deprecated_logging.py b/Tools/Scripts/webkitpy/common/system/deprecated_logging.py index 9e6b5298f..137535438 100644 --- a/Tools/Scripts/webkitpy/common/system/deprecated_logging.py +++ b/Tools/Scripts/webkitpy/common/system/deprecated_logging.py @@ -41,7 +41,7 @@ def log(string): def error(string): log("ERROR: %s" % string) - exit(1) + sys.exit(1) # Simple class to split output between multiple destinations diff --git a/Tools/Scripts/webkitpy/common/system/fileset.py b/Tools/Scripts/webkitpy/common/system/fileset.py index 598c1c595..57e9a284e 100644 --- a/Tools/Scripts/webkitpy/common/system/fileset.py +++ b/Tools/Scripts/webkitpy/common/system/fileset.py @@ -21,8 +21,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - from webkitpy.common.system.filesystem import FileSystem diff --git a/Tools/Scripts/webkitpy/common/system/filesystem.py b/Tools/Scripts/webkitpy/common/system/filesystem.py index 7de41a424..60b680c06 100644 --- a/Tools/Scripts/webkitpy/common/system/filesystem.py +++ b/Tools/Scripts/webkitpy/common/system/filesystem.py @@ -28,8 +28,6 @@ """Wrapper object for the file system / source tree.""" -from __future__ import with_statement - import codecs import errno import exceptions @@ -41,8 +39,6 @@ import sys import tempfile import time -from webkitpy.common.system import ospath - class FileSystem(object): """FileSystem interface for webkitpy. @@ -229,7 +225,7 @@ class FileSystem(object): return hashlib.sha1(contents).hexdigest() def relpath(self, path, start='.'): - return ospath.relpath(path, start) + return os.path.relpath(path, start) class _WindowsError(exceptions.OSError): """Fake exception for Linux and Mac.""" diff --git a/Tools/Scripts/webkitpy/common/system/filesystem_mock.py b/Tools/Scripts/webkitpy/common/system/filesystem_mock.py index e91d6682a..6e106dd83 100644 --- a/Tools/Scripts/webkitpy/common/system/filesystem_mock.py +++ b/Tools/Scripts/webkitpy/common/system/filesystem_mock.py @@ -33,7 +33,6 @@ import os import re from webkitpy.common.system import path -from webkitpy.common.system import ospath class MockFileSystem(object): @@ -180,7 +179,7 @@ class MockFileSystem(object): # to a different thread and potentially modifying the dict in # mid-iteration. files = self.files.keys()[:] - result = any(f.startswith(path) for f in files) + result = any(f.startswith(path) and len(self.split(f)[0]) >= len(path) for f in files) if result: self.dirs.add(path) return result @@ -303,7 +302,33 @@ class MockFileSystem(object): return hashlib.sha1(contents).hexdigest() def relpath(self, path, start='.'): - return ospath.relpath(path, start, self.abspath, self.sep) + # Since os.path.relpath() calls os.path.normpath() + # (see http://docs.python.org/library/os.path.html#os.path.abspath ) + # it also removes trailing slashes and converts forward and backward + # slashes to the preferred slash os.sep. + start = self.abspath(start) + 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. + + rel_path = path[len(start):] + + if not rel_path: + # Then the paths are the same. + pass + elif rel_path[0] == self.sep: + # It is probably sufficient to remove just the first character + # since os.path.normpath() collapses separators, but we use + # lstrip() just to be sure. + rel_path = rel_path.lstrip(self.sep) + else: + # We are in the case typified by the following example: + # path = "/tmp/foobar", start = "/tmp/foo" -> rel_path = "bar" + return None + + return rel_path def remove(self, path): if self.files[path] is None: diff --git a/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py b/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py index c24344c76..4859f7294 100644 --- a/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py +++ b/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py @@ -31,8 +31,6 @@ # important; without it, Python will choke while trying to parse the file, # since it includes non-ASCII characters. -from __future__ import with_statement - import os import stat import sys diff --git a/Tools/Scripts/webkitpy/common/system/ospath.py b/Tools/Scripts/webkitpy/common/system/ospath.py deleted file mode 100644 index 2504645c0..000000000 --- a/Tools/Scripts/webkitpy/common/system/ospath.py +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Contains a substitute for Python 2.6's os.path.relpath().""" - -import os - - -# This function is a replacement for os.path.relpath(), which is only -# available in Python 2.6: -# -# http://docs.python.org/library/os.path.html#os.path.relpath -# -# It should behave essentially the same as os.path.relpath(), except for -# returning None on paths not contained in abs_start_path. -def relpath(path, start_path, os_path_abspath=None, sep=None): - """Return a path relative to the given start path, or None. - - Returns None if the path is not contained in the directory start_path. - - Args: - path: An absolute or relative path to convert to a relative path. - start_path: The path relative to which the given path should be - converted. - os_path_abspath: A replacement function for unit testing. This - function should strip trailing slashes just like - os.path.abspath(). Defaults to os.path.abspath. - sep: Path separator. Defaults to os.path.sep - - """ - if os_path_abspath is None: - os_path_abspath = os.path.abspath - sep = sep or os.sep - - # Since os_path_abspath() calls os.path.normpath()-- - # - # (see http://docs.python.org/library/os.path.html#os.path.abspath ) - # - # it also removes trailing slashes and converts forward and backward - # slashes to the preferred slash os.sep. - start_path = os_path_abspath(start_path) - path = os_path_abspath(path) - - if not path.lower().startswith(start_path.lower()): - # Then path is outside the directory given by start_path. - return None - - rel_path = path[len(start_path):] - - if not rel_path: - # Then the paths are the same. - pass - elif rel_path[0] == sep: - # It is probably sufficient to remove just the first character - # since os.path.normpath() collapses separators, but we use - # lstrip() just to be sure. - rel_path = rel_path.lstrip(sep) - else: - # We are in the case typified by the following example: - # - # start_path = "/tmp/foo" - # path = "/tmp/foobar" - # rel_path = "bar" - return None - - return rel_path diff --git a/Tools/Scripts/webkitpy/common/system/ospath_unittest.py b/Tools/Scripts/webkitpy/common/system/ospath_unittest.py deleted file mode 100644 index d84c2c64c..000000000 --- a/Tools/Scripts/webkitpy/common/system/ospath_unittest.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -"""Unit tests for ospath.py.""" - -import os -import unittest - -from webkitpy.common.system.ospath import relpath - - -# Make sure the tests in this class are platform independent. -class RelPathTest(unittest.TestCase): - - """Tests relpath().""" - - os_path_abspath = lambda self, path: path - - def _rel_path(self, path, abs_start_path): - return relpath(path, abs_start_path, self.os_path_abspath) - - def test_same_path(self): - rel_path = self._rel_path("WebKit", "WebKit") - self.assertEquals(rel_path, "") - - def test_long_rel_path(self): - start_path = "WebKit" - expected_rel_path = os.path.join("test", "Foo.txt") - path = os.path.join(start_path, expected_rel_path) - - rel_path = self._rel_path(path, start_path) - self.assertEquals(expected_rel_path, rel_path) - - def test_none_rel_path(self): - """Test _rel_path() with None return value.""" - start_path = "WebKit" - path = os.path.join("other_dir", "foo.txt") - - rel_path = self._rel_path(path, start_path) - self.assertTrue(rel_path is None) - - rel_path = self._rel_path("Tools", "WebKit") - self.assertTrue(rel_path is None) diff --git a/Tools/Scripts/webkitpy/common/system/outputcapture.py b/Tools/Scripts/webkitpy/common/system/outputcapture.py index cb6edbec7..66188c0cb 100644 --- a/Tools/Scripts/webkitpy/common/system/outputcapture.py +++ b/Tools/Scripts/webkitpy/common/system/outputcapture.py @@ -74,11 +74,14 @@ class OutputCapture(object): def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_stdout="", expected_stderr="", expected_exception=None, expected_logs=None): self.capture_output() - if expected_exception: - return_value = testcase.assertRaises(expected_exception, function, *args, **kwargs) - else: - return_value = function(*args, **kwargs) - (stdout_string, stderr_string, logs_string) = self.restore_output() + try: + if expected_exception: + return_value = testcase.assertRaises(expected_exception, function, *args, **kwargs) + else: + return_value = function(*args, **kwargs) + finally: + (stdout_string, stderr_string, logs_string) = self.restore_output() + testcase.assertEqual(stdout_string, expected_stdout) testcase.assertEqual(stderr_string, expected_stderr) if expected_logs is not None: diff --git a/Tools/Scripts/webkitpy/common/system/path.py b/Tools/Scripts/webkitpy/common/system/path.py index 09787d7e8..b7ad3723a 100644 --- a/Tools/Scripts/webkitpy/common/system/path.py +++ b/Tools/Scripts/webkitpy/common/system/path.py @@ -27,7 +27,6 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """generic routines to convert platform-specific paths to URIs.""" -from __future__ import with_statement import atexit import subprocess diff --git a/Tools/Scripts/webkitpy/common/thread/threadedmessagequeue.py b/Tools/Scripts/webkitpy/common/thread/threadedmessagequeue.py index 17b62773c..e43476764 100644 --- a/Tools/Scripts/webkitpy/common/thread/threadedmessagequeue.py +++ b/Tools/Scripts/webkitpy/common/thread/threadedmessagequeue.py @@ -26,8 +26,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import with_statement - import threading diff --git a/Tools/Scripts/webkitpy/common/version_check.py b/Tools/Scripts/webkitpy/common/version_check.py index 290623d32..6acc9b439 100644 --- a/Tools/Scripts/webkitpy/common/version_check.py +++ b/Tools/Scripts/webkitpy/common/version_check.py @@ -29,6 +29,6 @@ import sys -if sys.version < '2.5' or sys.version >= '2.8': - print >> sys.stderr, "Unsupported Python version: WebKit only supports 2.5.x - 2.7.x, and you're running %s." % sys.version.split()[0] +if sys.version < '2.6' or sys.version >= '2.8': + print >> sys.stderr, "Unsupported Python version: WebKit only supports 2.6.x - 2.7.x, and you're running %s." % sys.version.split()[0] sys.exit(1) |