Diff
Modified: trunk/Tools/ChangeLog (122535 => 122536)
--- trunk/Tools/ChangeLog 2012-07-13 01:53:17 UTC (rev 122535)
+++ trunk/Tools/ChangeLog 2012-07-13 02:01:09 UTC (rev 122536)
@@ -1,3 +1,18 @@
+2012-07-12 Dirk Pranke <dpra...@chromium.org>
+
+ test-webkitpy: rename test_finder to finder
+ https://bugs.webkit.org/show_bug.cgi?id=91175
+
+ Reviewed by Adam Barth.
+
+ Rename test_finder -> finder, TestFinder -> Finder to remove
+ some of the stutter in the names.
+
+ * Scripts/webkitpy/test/finder.py: Renamed from Tools/Scripts/webkitpy/test/test_finder.py.
+ * Scripts/webkitpy/test/finder_unittest.py: Renamed from Tools/Scripts/webkitpy/test/test_finder_unittest.py.
+ * Scripts/webkitpy/test/main.py:
+ (Tester.__init__):
+
2012-07-12 Adam Barth <aba...@webkit.org>
CommitQueue is confused about what port it is using
Copied: trunk/Tools/Scripts/webkitpy/test/finder.py (from rev 122535, trunk/Tools/Scripts/webkitpy/test/test_finder.py) (0 => 122536)
--- trunk/Tools/Scripts/webkitpy/test/finder.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/test/finder.py 2012-07-13 02:01:09 UTC (rev 122536)
@@ -0,0 +1,180 @@
+# Copyright (C) 2012 Google, Inc.
+# Copyright (C) 2010 Chris Jerdonek (cjerdo...@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.
+
+"""this module is responsible for finding python tests."""
+
+import logging
+import re
+import sys
+
+
+_log = logging.getLogger(__name__)
+
+
+class TestDirectoryTree(object):
+ def __init__(self, filesystem, top_directory, starting_subdirectory):
+ self.filesystem = filesystem
+ self.top_directory = filesystem.realpath(top_directory)
+ self.search_directory = self.top_directory
+ self.top_package = ''
+ if starting_subdirectory:
+ self.top_package = starting_subdirectory.replace(filesystem.sep, '.') + '.'
+ self.search_directory = filesystem.join(self.top_directory, starting_subdirectory)
+
+ def find_modules(self, suffixes, sub_directory=None):
+ if sub_directory:
+ search_directory = self.filesystem.join(self.top_directory, sub_directory)
+ else:
+ search_directory = self.search_directory
+
+ def file_filter(filesystem, dirname, basename):
+ return any(basename.endswith(suffix) for suffix in suffixes)
+
+ filenames = self.filesystem.files_under(search_directory, file_filter=file_filter)
+ return [self.to_module(filename) for filename in filenames]
+
+ def to_module(self, path):
+ return path.replace(self.top_directory + self.filesystem.sep, '').replace(self.filesystem.sep, '.')[:-3]
+
+ def subpath(self, path):
+ """Returns the relative path from the top of the tree to the path, or None if the path is not under the top of the tree."""
+ realpath = self.filesystem.realpath(self.filesystem.join(self.top_directory, path))
+ if realpath.startswith(self.top_directory + self.filesystem.sep):
+ return realpath.replace(self.top_directory + self.filesystem.sep, '')
+ return None
+
+ def clean(self):
+ """Delete all .pyc files in the tree that have no matching .py file."""
+ _log.debug("Cleaning orphaned *.pyc files from: %s" % self.search_directory)
+ filenames = self.filesystem.files_under(self.search_directory)
+ for filename in filenames:
+ if filename.endswith(".pyc") and filename[:-1] not in filenames:
+ _log.info("Deleting orphan *.pyc file: %s" % filename)
+ self.filesystem.remove(filename)
+
+
+class Finder(object):
+ def __init__(self, filesystem):
+ self.filesystem = filesystem
+ self.trees = []
+
+ def add_tree(self, top_directory, starting_subdirectory=None):
+ self.trees.append(TestDirectoryTree(self.filesystem, top_directory, starting_subdirectory))
+
+ def additional_paths(self, paths):
+ return [tree.top_directory for tree in self.trees if tree.top_directory not in paths]
+
+ def clean_trees(self):
+ for tree in self.trees:
+ tree.clean()
+
+ def is_module(self, name):
+ relpath = name.replace('.', self.filesystem.sep) + '.py'
+ return any(self.filesystem.exists(self.filesystem.join(tree.top_directory, relpath)) for tree in self.trees)
+
+ def is_dotted_name(self, name):
+ return re.match(r'[a-zA-Z.][a-zA-Z0-9_.]*', name)
+
+ def to_module(self, path):
+ for tree in self.trees:
+ if path.startswith(tree.top_directory):
+ return tree.to_module(path)
+ return None
+
+ def find_names(self, args, skip_integrationtests, find_all):
+ suffixes = ['_unittest.py']
+ if not skip_integrationtests:
+ suffixes.append('_integrationtest.py')
+
+ if args:
+ names = []
+ for arg in args:
+ names.extend(self._find_names_for_arg(arg, suffixes))
+ return names
+
+ return self._default_names(suffixes, find_all)
+
+ def _find_names_for_arg(self, arg, suffixes):
+ realpath = self.filesystem.realpath(arg)
+ if self.filesystem.exists(realpath):
+ names = self._find_in_trees(realpath, suffixes)
+ if not names:
+ _log.error("%s is not in one of the test trees." % arg)
+ return names
+
+ # See if it's a python package in a tree (or a relative path from the top of a tree).
+ names = self._find_in_trees(arg.replace('.', self.filesystem.sep), suffixes)
+ if names:
+ return names
+
+ if self.is_dotted_name(arg):
+ # The name may not exist, but that's okay; we'll find out later.
+ return [arg]
+
+ _log.error("%s is not a python name or an existing file or directory." % arg)
+ return []
+
+ def _find_in_trees(self, path, suffixes):
+ for tree in self.trees:
+ relpath = tree.subpath(path)
+ if not relpath:
+ continue
+ if self.filesystem.isfile(path):
+ return [tree.to_module(path)]
+ else:
+ return tree.find_modules(suffixes, path)
+ return []
+
+ def _default_names(self, suffixes, find_all):
+ modules = []
+ for tree in self.trees:
+ modules.extend(tree.find_modules(suffixes))
+ modules.sort()
+
+ for module in modules:
+ _log.debug("Found: %s" % module)
+
+ # FIXME: Figure out how to move this to test-webkitpy in order to to make this file more generic.
+ if not find_all:
+ slow_tests = ('webkitpy.common.checkout.scm.scm_unittest',)
+ self._exclude(modules, slow_tests, 'are really, really slow', 31818)
+
+ if sys.platform == 'win32':
+ win32_blacklist = ('webkitpy.common.checkout',
+ 'webkitpy.common.config',
+ 'webkitpy.tool')
+ self._exclude(modules, win32_blacklist, 'fail horribly on win32', 54526)
+
+ return modules
+
+ def _exclude(self, modules, module_prefixes, reason, bugid):
+ _log.info('Skipping tests in the following modules or packages because they %s:' % reason)
+ for prefix in module_prefixes:
+ _log.info(' %s' % prefix)
+ modules_to_exclude = filter(lambda m: m.startswith(prefix), modules)
+ for m in modules_to_exclude:
+ if len(modules_to_exclude) > 1:
+ _log.debug(' %s' % m)
+ modules.remove(m)
+ _log.info(' (https://bugs.webkit.org/show_bug.cgi?id=%d; use --all to include)' % bugid)
+ _log.info('')
Copied: trunk/Tools/Scripts/webkitpy/test/finder_unittest.py (from rev 122535, trunk/Tools/Scripts/webkitpy/test/test_finder_unittest.py) (0 => 122536)
--- trunk/Tools/Scripts/webkitpy/test/finder_unittest.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/test/finder_unittest.py 2012-07-13 02:01:09 UTC (rev 122536)
@@ -0,0 +1,134 @@
+# Copyright (C) 2012 Google, Inc.
+#
+# 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.
+
+import logging
+import unittest
+
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+from webkitpy.common.system.outputcapture import OutputCapture
+from webkitpy.test.finder import Finder
+
+
+class FinderTest(unittest.TestCase):
+ def setUp(self):
+ files = {
+ '/foo/bar/baz.py': '',
+ '/foo/bar/baz_unittest.py': '',
+ '/foo2/bar2/baz2.py': '',
+ '/foo2/bar2/baz2.pyc': '',
+ '/foo2/bar2/baz2_integrationtest.py': '',
+ '/foo2/bar2/missing.pyc': '',
+ '/tmp/another_unittest.py': '',
+ }
+ self.fs = MockFileSystem(files)
+ self.finder = Finder(self.fs)
+ self.finder.add_tree('/foo', 'bar')
+ self.finder.add_tree('/foo2')
+
+ # Here we have to jump through a hoop to make sure test-webkitpy doesn't log
+ # any messages from these tests :(.
+ self.root_logger = logging.getLogger()
+ self.log_handler = None
+ for h in self.root_logger.handlers:
+ if getattr(h, 'name', None) == 'webkitpy.test.main':
+ self.log_handler = h
+ break
+ if self.log_handler:
+ self.log_level = self.log_handler.level
+ self.log_handler.level = logging.CRITICAL
+
+ def tearDown(self):
+ if self.log_handler:
+ self.log_handler.setLevel(self.log_level)
+
+ def test_additional_system_paths(self):
+ self.assertEquals(self.finder.additional_paths(['/usr']),
+ ['/foo', '/foo2'])
+
+ def test_is_module(self):
+ self.assertTrue(self.finder.is_module('bar.baz'))
+ self.assertTrue(self.finder.is_module('bar2.baz2'))
+ self.assertTrue(self.finder.is_module('bar2.baz2_integrationtest'))
+
+ # Missing the proper namespace.
+ self.assertFalse(self.finder.is_module('baz'))
+
+ def test_to_module(self):
+ self.assertEquals(self.finder.to_module('/foo/test.py'), 'test')
+ self.assertEquals(self.finder.to_module('/foo/bar/test.py'), 'bar.test')
+ self.assertEquals(self.finder.to_module('/foo/bar/pytest.py'), 'bar.pytest')
+
+ def test_clean(self):
+ self.assertTrue(self.fs.exists('/foo2/bar2/missing.pyc'))
+ self.finder.clean_trees()
+ self.assertFalse(self.fs.exists('/foo2/bar2/missing.pyc'))
+
+ def check_names(self, names, expected_names, skip_integrationtests=False, find_all=False):
+ self.assertEquals(self.finder.find_names(names, skip_integrationtests, find_all),
+ expected_names)
+
+ def test_default_names(self):
+ self.check_names([], ['bar.baz_unittest', 'bar2.baz2_integrationtest'])
+ self.check_names([], ['bar.baz_unittest'], skip_integrationtests=True, find_all=True)
+ self.check_names([], ['bar.baz_unittest'], skip_integrationtests=True, find_all=False)
+
+ # Should return the names given it, even if they don't exist.
+ self.check_names(['foobar'], ['foobar'], skip_integrationtests=True, find_all=False)
+
+ def test_paths(self):
+ self.fs.chdir('/foo/bar')
+ self.check_names(['baz_unittest.py'], ['bar.baz_unittest'])
+ self.check_names(['./baz_unittest.py'], ['bar.baz_unittest'])
+ self.check_names(['/foo/bar/baz_unittest.py'], ['bar.baz_unittest'])
+ self.check_names(['.'], ['bar.baz_unittest'])
+ self.check_names(['../../foo2/bar2'], ['bar2.baz2_integrationtest'])
+
+ self.fs.chdir('/')
+ self.check_names(['bar'], ['bar.baz_unittest'])
+ self.check_names(['/foo/bar/'], ['bar.baz_unittest'])
+
+ # This works 'by accident' since it maps onto a package.
+ self.check_names(['bar/'], ['bar.baz_unittest'])
+
+ # This should log an error, since it's outside the trees.
+ oc = OutputCapture()
+ oc.set_log_level(logging.ERROR)
+ oc.capture_output()
+ try:
+ self.check_names(['/tmp/another_unittest.py'], [])
+ finally:
+ _, _, logs = oc.restore_output()
+ self.assertTrue('another_unittest.py' in logs)
+
+ # Paths that don't exist are errors.
+ oc.capture_output()
+ try:
+ self.check_names(['/foo/bar/notexist_unittest.py'], [])
+ finally:
+ _, _, logs = oc.restore_output()
+ self.assertTrue('notexist_unittest.py' in logs)
+
+ # Names that don't exist are caught later, at load time.
+ self.check_names(['bar.notexist_unittest'], ['bar.notexist_unittest'])
+
+if __name__ == '__main__':
+ unittest.main()
Modified: trunk/Tools/Scripts/webkitpy/test/main.py (122535 => 122536)
--- trunk/Tools/Scripts/webkitpy/test/main.py 2012-07-13 01:53:17 UTC (rev 122535)
+++ trunk/Tools/Scripts/webkitpy/test/main.py 2012-07-13 02:01:09 UTC (rev 122536)
@@ -33,7 +33,7 @@
from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.system import outputcapture
-from webkitpy.test.test_finder import TestFinder
+from webkitpy.test.finder import Finder
from webkitpy.test.runner import TestRunner
_log = logging.getLogger(__name__)
@@ -41,7 +41,7 @@
class Tester(object):
def __init__(self, filesystem=None):
- self.finder = TestFinder(filesystem or FileSystem())
+ self.finder = Finder(filesystem or FileSystem())
self.stream = sys.stderr
def add_tree(self, top_directory, starting_subdirectory=None):
Deleted: trunk/Tools/Scripts/webkitpy/test/test_finder.py (122535 => 122536)
--- trunk/Tools/Scripts/webkitpy/test/test_finder.py 2012-07-13 01:53:17 UTC (rev 122535)
+++ trunk/Tools/Scripts/webkitpy/test/test_finder.py 2012-07-13 02:01:09 UTC (rev 122536)
@@ -1,181 +0,0 @@
-# Copyright (C) 2012 Google, Inc.
-# Copyright (C) 2010 Chris Jerdonek (cjerdo...@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.
-
-"""this module is responsible for finding python tests."""
-
-import logging
-import re
-import sys
-
-
-_log = logging.getLogger(__name__)
-
-
-class TestDirectoryTree(object):
- def __init__(self, filesystem, top_directory, starting_subdirectory):
- self.filesystem = filesystem
- self.top_directory = filesystem.realpath(top_directory)
- self.search_directory = self.top_directory
- self.top_package = ''
- if starting_subdirectory:
- self.top_package = starting_subdirectory.replace(filesystem.sep, '.') + '.'
- self.search_directory = filesystem.join(self.top_directory, starting_subdirectory)
-
- def find_modules(self, suffixes, sub_directory=None):
- if sub_directory:
- search_directory = self.filesystem.join(self.top_directory, sub_directory)
- else:
- search_directory = self.search_directory
-
- def file_filter(filesystem, dirname, basename):
- return any(basename.endswith(suffix) for suffix in suffixes)
-
- filenames = self.filesystem.files_under(search_directory, file_filter=file_filter)
- return [self.to_module(filename) for filename in filenames]
-
- def to_module(self, path):
- return path.replace(self.top_directory + self.filesystem.sep, '').replace(self.filesystem.sep, '.')[:-3]
-
- def subpath(self, path):
- """Returns the relative path from the top of the tree to the path, or None if the path is not under the top of the tree."""
- realpath = self.filesystem.realpath(self.filesystem.join(self.top_directory, path))
- if realpath.startswith(self.top_directory + self.filesystem.sep):
- return realpath.replace(self.top_directory + self.filesystem.sep, '')
- return None
-
-
- def clean(self):
- """Delete all .pyc files in the tree that have no matching .py file."""
- _log.debug("Cleaning orphaned *.pyc files from: %s" % self.search_directory)
- filenames = self.filesystem.files_under(self.search_directory)
- for filename in filenames:
- if filename.endswith(".pyc") and filename[:-1] not in filenames:
- _log.info("Deleting orphan *.pyc file: %s" % filename)
- self.filesystem.remove(filename)
-
-
-class TestFinder(object):
- def __init__(self, filesystem):
- self.filesystem = filesystem
- self.trees = []
-
- def add_tree(self, top_directory, starting_subdirectory=None):
- self.trees.append(TestDirectoryTree(self.filesystem, top_directory, starting_subdirectory))
-
- def additional_paths(self, paths):
- return [tree.top_directory for tree in self.trees if tree.top_directory not in paths]
-
- def clean_trees(self):
- for tree in self.trees:
- tree.clean()
-
- def is_module(self, name):
- relpath = name.replace('.', self.filesystem.sep) + '.py'
- return any(self.filesystem.exists(self.filesystem.join(tree.top_directory, relpath)) for tree in self.trees)
-
- def is_dotted_name(self, name):
- return re.match(r'[a-zA-Z.][a-zA-Z0-9_.]*', name)
-
- def to_module(self, path):
- for tree in self.trees:
- if path.startswith(tree.top_directory):
- return tree.to_module(path)
- return None
-
- def find_names(self, args, skip_integrationtests, find_all):
- suffixes = ['_unittest.py']
- if not skip_integrationtests:
- suffixes.append('_integrationtest.py')
-
- if args:
- names = []
- for arg in args:
- names.extend(self._find_names_for_arg(arg, suffixes))
- return names
-
- return self._default_names(suffixes, find_all)
-
- def _find_names_for_arg(self, arg, suffixes):
- realpath = self.filesystem.realpath(arg)
- if self.filesystem.exists(realpath):
- names = self._find_in_trees(realpath, suffixes)
- if not names:
- _log.error("%s is not in one of the test trees." % arg)
- return names
-
- # See if it's a python package in a tree (or a relative path from the top of a tree).
- names = self._find_in_trees(arg.replace('.', self.filesystem.sep), suffixes)
- if names:
- return names
-
- if self.is_dotted_name(arg):
- # The name may not exist, but that's okay; we'll find out later.
- return [arg]
-
- _log.error("%s is not a python name or an existing file or directory." % arg)
- return []
-
- def _find_in_trees(self, path, suffixes):
- for tree in self.trees:
- relpath = tree.subpath(path)
- if not relpath:
- continue
- if self.filesystem.isfile(path):
- return [tree.to_module(path)]
- else:
- return tree.find_modules(suffixes, path)
- return []
-
- def _default_names(self, suffixes, find_all):
- modules = []
- for tree in self.trees:
- modules.extend(tree.find_modules(suffixes))
- modules.sort()
-
- for module in modules:
- _log.debug("Found: %s" % module)
-
- # FIXME: Figure out how to move this to test-webkitpy in order to to make this file more generic.
- if not find_all:
- slow_tests = ('webkitpy.common.checkout.scm.scm_unittest',)
- self._exclude(modules, slow_tests, 'are really, really slow', 31818)
-
- if sys.platform == 'win32':
- win32_blacklist = ('webkitpy.common.checkout',
- 'webkitpy.common.config',
- 'webkitpy.tool')
- self._exclude(modules, win32_blacklist, 'fail horribly on win32', 54526)
-
- return modules
-
- def _exclude(self, modules, module_prefixes, reason, bugid):
- _log.info('Skipping tests in the following modules or packages because they %s:' % reason)
- for prefix in module_prefixes:
- _log.info(' %s' % prefix)
- modules_to_exclude = filter(lambda m: m.startswith(prefix), modules)
- for m in modules_to_exclude:
- if len(modules_to_exclude) > 1:
- _log.debug(' %s' % m)
- modules.remove(m)
- _log.info(' (https://bugs.webkit.org/show_bug.cgi?id=%d; use --all to include)' % bugid)
- _log.info('')
Deleted: trunk/Tools/Scripts/webkitpy/test/test_finder_unittest.py (122535 => 122536)
--- trunk/Tools/Scripts/webkitpy/test/test_finder_unittest.py 2012-07-13 01:53:17 UTC (rev 122535)
+++ trunk/Tools/Scripts/webkitpy/test/test_finder_unittest.py 2012-07-13 02:01:09 UTC (rev 122536)
@@ -1,134 +0,0 @@
-# Copyright (C) 2012 Google, Inc.
-#
-# 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.
-
-import logging
-import unittest
-
-from webkitpy.common.system.filesystem_mock import MockFileSystem
-from webkitpy.common.system.outputcapture import OutputCapture
-from webkitpy.test.test_finder import TestFinder
-
-
-class TestFinderTest(unittest.TestCase):
- def setUp(self):
- files = {
- '/foo/bar/baz.py': '',
- '/foo/bar/baz_unittest.py': '',
- '/foo2/bar2/baz2.py': '',
- '/foo2/bar2/baz2.pyc': '',
- '/foo2/bar2/baz2_integrationtest.py': '',
- '/foo2/bar2/missing.pyc': '',
- '/tmp/another_unittest.py': '',
- }
- self.fs = MockFileSystem(files)
- self.finder = TestFinder(self.fs)
- self.finder.add_tree('/foo', 'bar')
- self.finder.add_tree('/foo2')
-
- # Here we have to jump through a hoop to make sure test-webkitpy doesn't log
- # any messages from these tests :(.
- self.root_logger = logging.getLogger()
- self.log_handler = None
- for h in self.root_logger.handlers:
- if getattr(h, 'name', None) == 'webkitpy.test.main':
- self.log_handler = h
- break
- if self.log_handler:
- self.log_level = self.log_handler.level
- self.log_handler.level = logging.CRITICAL
-
- def tearDown(self):
- if self.log_handler:
- self.log_handler.setLevel(self.log_level)
-
- def test_additional_system_paths(self):
- self.assertEquals(self.finder.additional_paths(['/usr']),
- ['/foo', '/foo2'])
-
- def test_is_module(self):
- self.assertTrue(self.finder.is_module('bar.baz'))
- self.assertTrue(self.finder.is_module('bar2.baz2'))
- self.assertTrue(self.finder.is_module('bar2.baz2_integrationtest'))
-
- # Missing the proper namespace.
- self.assertFalse(self.finder.is_module('baz'))
-
- def test_to_module(self):
- self.assertEquals(self.finder.to_module('/foo/test.py'), 'test')
- self.assertEquals(self.finder.to_module('/foo/bar/test.py'), 'bar.test')
- self.assertEquals(self.finder.to_module('/foo/bar/pytest.py'), 'bar.pytest')
-
- def test_clean(self):
- self.assertTrue(self.fs.exists('/foo2/bar2/missing.pyc'))
- self.finder.clean_trees()
- self.assertFalse(self.fs.exists('/foo2/bar2/missing.pyc'))
-
- def check_names(self, names, expected_names, skip_integrationtests=False, find_all=False):
- self.assertEquals(self.finder.find_names(names, skip_integrationtests, find_all),
- expected_names)
-
- def test_default_names(self):
- self.check_names([], ['bar.baz_unittest', 'bar2.baz2_integrationtest'])
- self.check_names([], ['bar.baz_unittest'], skip_integrationtests=True, find_all=True)
- self.check_names([], ['bar.baz_unittest'], skip_integrationtests=True, find_all=False)
-
- # Should return the names given it, even if they don't exist.
- self.check_names(['foobar'], ['foobar'], skip_integrationtests=True, find_all=False)
-
- def test_paths(self):
- self.fs.chdir('/foo/bar')
- self.check_names(['baz_unittest.py'], ['bar.baz_unittest'])
- self.check_names(['./baz_unittest.py'], ['bar.baz_unittest'])
- self.check_names(['/foo/bar/baz_unittest.py'], ['bar.baz_unittest'])
- self.check_names(['.'], ['bar.baz_unittest'])
- self.check_names(['../../foo2/bar2'], ['bar2.baz2_integrationtest'])
-
- self.fs.chdir('/')
- self.check_names(['bar'], ['bar.baz_unittest'])
- self.check_names(['/foo/bar/'], ['bar.baz_unittest'])
-
- # This works 'by accident' since it maps onto a package.
- self.check_names(['bar/'], ['bar.baz_unittest'])
-
- # This should log an error, since it's outside the trees.
- oc = OutputCapture()
- oc.set_log_level(logging.ERROR)
- oc.capture_output()
- try:
- self.check_names(['/tmp/another_unittest.py'], [])
- finally:
- _, _, logs = oc.restore_output()
- self.assertTrue('another_unittest.py' in logs)
-
- # Paths that don't exist are errors.
- oc.capture_output()
- try:
- self.check_names(['/foo/bar/notexist_unittest.py'], [])
- finally:
- _, _, logs = oc.restore_output()
- self.assertTrue('notexist_unittest.py' in logs)
-
- # Names that don't exist are caught later, at load time.
- self.check_names(['bar.notexist_unittest'], ['bar.notexist_unittest'])
-
-if __name__ == '__main__':
- unittest.main()