Reviewed by Mihai Parparita.
new-run-webkit-tests: fix normalization of paths on windows when gathering files
r77434 introduced a bug that was causing the test expectations
for the GPU ports to not be treated properly. It turns out that
when we gathered the list of test files on Windows, we would
return paths of the form "c:\LayoutTests/fast/canvas", and the
mixture of backslashes and forward slashes was confusing things.
This patch normalizes all of the filenames returned from
test_files.find(), and adds better tests for this (fixing a
couple of other bugs found in the meantime).
https://bugs.webkit.org/show_bug.cgi?id=53720
* Scripts/webkitpy/layout_tests/port/test.py:
* Scripts/webkitpy/layout_tests/port/test_files.py:
* Scripts/webkitpy/layout_tests/port/test_files_unittest.py:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77550
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-03 Dirk Pranke <dpranke@chromium.org>
+
+ Reviewed by Mihai Parparita.
+
+ new-run-webkit-tests: fix normalization of paths on windows when gathering files
+
+ r77434 introduced a bug that was causing the test expectations
+ for the GPU ports to not be treated properly. It turns out that
+ when we gathered the list of test files on Windows, we would
+ return paths of the form "c:\LayoutTests/fast/canvas", and the
+ mixture of backslashes and forward slashes was confusing things.
+
+ This patch normalizes all of the filenames returned from
+ test_files.find(), and adds better tests for this (fixing a
+ couple of other bugs found in the meantime).
+
+ https://bugs.webkit.org/show_bug.cgi?id=53720
+
+ * Scripts/webkitpy/layout_tests/port/test.py:
+ * Scripts/webkitpy/layout_tests/port/test_files.py:
+ * Scripts/webkitpy/layout_tests/port/test_files_unittest.py:
+
2011-02-03 Adam Roben <aroben@apple.com>
Add links to Windows crash logs in results.html
WONTFIX SKIP : failures/expected/exception.html = CRASH
"""
+ # Add in a file should be ignored by test_files.find().
+ files[LAYOUT_TEST_DIR + 'userscripts/resources/iframe.html'] = 'iframe'
+
fs = filesystem_mock.MockFileSystem(files)
fs._tests = test_list
return fs
_skipped_directories = set(['.svn', '_svn', 'resources', 'script-tests'])
-def find(port, paths):
- """Finds the set of tests under port.layout_tests_dir().
+def find(port, paths=None):
+ """Finds the set of tests under a given list of sub-paths.
Args:
- paths: a list of command line paths relative to the layout_tests_dir()
- to limit the search to. glob patterns are ok.
+ paths: a list of path expressions relative to port.layout_tests_dir()
+ to search. Glob patterns are ok, as are path expressions with
+ forward slashes on Windows. If paths is empty, we look at
+ everything under the layout_tests_dir().
"""
+ paths = paths or ['*']
fs = port._filesystem
+ return normalized_find(fs, normalize(fs, port.layout_tests_dir(), paths))
+
+
+def normalize(fs, base_dir, paths):
+ return [fs.normpath(fs.join(base_dir, path)) for path in paths]
+
+
+def normalized_find(filesystem, paths):
+ """Finds the set of tests under the list of paths.
+
+ Args:
+ paths: a list of absolute path expressions to search.
+ Glob patterns are ok.
+ """
gather_start_time = time.time()
paths_to_walk = set()
- # if paths is empty, provide a pre-defined list.
- if paths:
- _log.debug("Gathering tests from: %s relative to %s" % (paths, port.layout_tests_dir()))
- for path in paths:
- # If there's an * in the name, assume it's a glob pattern.
- path = fs.join(port.layout_tests_dir(), path)
- if path.find('*') > -1:
- filenames = fs.glob(path)
- paths_to_walk.update(filenames)
- else:
- paths_to_walk.add(path)
- else:
- _log.debug("Gathering tests from: %s" % port.layout_tests_dir())
- paths_to_walk.add(port.layout_tests_dir())
+ for path in paths:
+ # If there's an * in the name, assume it's a glob pattern.
+ if path.find('*') > -1:
+ filenames = filesystem.glob(path)
+ paths_to_walk.update(filenames)
+ else:
+ paths_to_walk.add(path)
# FIXME: I'm not sure there's much point in this being a set. A list would
# probably be faster.
test_files = set()
for path in paths_to_walk:
- files = fs.files_under(path, _skipped_directories, _is_test_file)
+ files = filesystem.files_under(path, _skipped_directories, _is_test_file)
test_files.update(set(files))
gather_time = time.time() - gather_start_time
# (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 sys
import unittest
-import base
+from webkitpy.layout_tests.port import test
import test_files
-
class TestFilesTest(unittest.TestCase):
def test_find_no_paths_specified(self):
- port = base.Port()
+ port = test.TestPort()
layout_tests_dir = port.layout_tests_dir()
- port.layout_tests_dir = lambda: port._filesystem.join(layout_tests_dir,
- 'fast', 'html')
tests = test_files.find(port, [])
- self.assertNotEqual(tests, 0)
+ self.assertNotEqual(len(tests), 0)
def test_find_one_test(self):
- port = base.Port()
- # This is just a test picked at random but known to exist.
- tests = test_files.find(port, ['fast/html/keygen.html'])
+ port = test.TestPort()
+ tests = test_files.find(port, ['failures/expected/image.html'])
self.assertEqual(len(tests), 1)
def test_find_glob(self):
- port = base.Port()
- tests = test_files.find(port, ['fast/html/key*'])
- self.assertEqual(len(tests), 1)
+ port = test.TestPort()
+ tests = test_files.find(port, ['failures/expected/im*'])
+ self.assertEqual(len(tests), 2)
def test_find_with_skipped_directories(self):
- port = base.Port()
+ port = test.TestPort()
tests = port.tests('userscripts')
- self.assertTrue('userscripts/resources/frame1.html' not in tests)
+ self.assertTrue('userscripts/resources/iframe.html' not in tests)
def test_find_with_skipped_directories_2(self):
- port = base.Port()
+ port = test.TestPort()
tests = test_files.find(port, ['userscripts/resources'])
self.assertEqual(tests, set([]))
def test_is_test_file(self):
- port = base.Port()
+ port = test.TestPort()
fs = port._filesystem
self.assertTrue(test_files._is_test_file(fs, '', 'foo.html'))
self.assertTrue(test_files._is_test_file(fs, '', 'foo.shtml'))
self.assertFalse(test_files._is_test_file(fs, '', 'foo-expected-mismatch.html'))
+class MockWinFileSystem(object):
+ def join(self, *paths):
+ return '\\'.join(paths)
+
+ def normpath(self, path):
+ return path.replace('/', '\\')
+
+
+class TestWinNormalize(unittest.TestCase):
+ def assert_filesystem_normalizes(self, filesystem):
+ self.assertEquals(test_files.normalize(filesystem, "c:\\foo",
+ ['fast/html', 'fast/canvas/*', 'compositing/foo.html']),
+ ['c:\\foo\\fast\html', 'c:\\foo\\fast\canvas\*', 'c:\\foo\compositing\\foo.html'])
+
+ def test_mocked_win(self):
+ # This tests test_files.normalize, using portable behavior emulating
+ # what we think Windows is supposed to do. This test will run on all
+ # platforms.
+ self.assert_filesystem_normalizes(MockWinFileSystem())
+
+ def test_win(self):
+ # This tests the actual windows platform, to ensure we get the same
+ # results that we get in test_forward_subpath().
+ if sys.platform != 'win':
+ return
+ self.assert_filesystem_normalizes(FileSystem())
+
+
if __name__ == '__main__':
unittest.main()