Commit bbc8e412 authored by's avatar
Browse files

2011-06-29 Brent Fulgham <>

        Unreviewed build correction.

        * DumpRenderTree/win/ImageDiffWinCairoCommon.vsprops:
        Link against zlib1.dll, not the static zlib.lib.

git-svn-id: 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 05181568
......@@ -5,6 +5,28 @@
* DumpRenderTree/win/ImageDiffWinCairoCommon.vsprops:
Link against zlib1.dll, not the static zlib.lib.
2011-06-29 Eric Seidel <>
Reviewed by Adam Barth.
Make port/ mockable for easier unit testing
Right now leaks real system paths for
webkit_base_dir due to using __file__. This patch
adds a wrapper around __file__ so that
we don't have to jump through hoops in
to avoid leaking local paths to the unit test results.
There are probably many more places where we should now
use filesystem.path_for_module, but starting with just this one.
* Scripts/webkitpy/common/system/
* Scripts/webkitpy/common/system/
* Scripts/webkitpy/layout_tests/port/
* Scripts/webkitpy/layout_tests/port/
* Scripts/webkitpy/tool/commands/
2011-06-29 Eric Seidel <>
Reviewed by Adam Barth.
......@@ -36,6 +36,7 @@ import exceptions
import glob
import os
import shutil
import sys
import tempfile
import time
......@@ -57,6 +58,11 @@ class FileSystem(object):
def abspath(self, path):
return os.path.abspath(path)
def path_to_module(self, module_name):
"""A wrapper for all calls to __file__ to allow easy unit testing."""
# FIXME: This is the only use of sys in this file. It's possible this function should move elsewhere.
return sys.modules[module_name].__file__ # __file__ is always an absolute path.
def expanduser(self, path):
return os.path.expanduser(path)
......@@ -79,6 +79,9 @@ class MockFileSystem(object):
return home_directory
return home_directory + self.sep + parts[1]
def path_to_module(self, module_name):
return "/mock/Tools/Scripts/webkitpy/%s" % module_name
def chdir(self, path):
path = self.normpath(path)
if not self.isdir(path):
......@@ -118,8 +118,8 @@ class Config(object):
# This code will also work if there is no SCM system at all.
if not self._webkit_base_dir:
abspath = self._filesystem.abspath(__file__)
self._webkit_base_dir = abspath[0:abspath.find('Tools') - 1]
config_module_path = self._filesystem.path_to_module(self.__module__)
self._webkit_base_dir = abspath[0:config_module_path.find('Tools') - 1]
return self._webkit_base_dir
def script_path(self, script_name):
......@@ -27,7 +27,7 @@
import unittest
from webkitpy.common.system import filesystem_mock
from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.layout_tests.port.webkit import WebKitPort
......@@ -43,12 +43,10 @@ class TestWebKitPort(WebKitPort):
self.symbol_list = symbol_list
self.feature_list = feature_list
self.expectations_file = expectations_file
self.skips_file = skips_file
executive = executive or MockExecutive(should_log=False)
filesystem = filesystem or filesystem_mock.MockFileSystem()
filesystem = filesystem or MockFileSystem()
user = user or MockUser()
WebKitPort.__init__(self, executive=executive, filesystem=filesystem, user=MockUser(), **kwargs)
WebKitPort.__init__(self, port_name="testwebkitport", executive=executive, filesystem=filesystem, user=MockUser(), **kwargs)
def _runtime_feature_list(self):
return self.feature_list
......@@ -62,16 +60,6 @@ class TestWebKitPort(WebKitPort):
def _tests_for_disabled_features(self):
return ["accessibility", ]
def path_to_test_expectations_file(self):
if self.expectations_file:
return self.expectations_file
return WebKitPort.path_to_test_expectations_file(self)
def _skipped_file_paths(self):
if self.skips_file:
return [self.skips_file]
return []
class WebKitPortTest(port_testcase.PortTestCase):
def port_maker(self, platform):
......@@ -105,12 +93,11 @@ class WebKitPortTest(port_testcase.PortTestCase):
# Check that we read both the expectations file and anything in a
# Skipped file, and that we include the feature and platform checks.
files = {
'/tmp/test_expectations.txt': 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n',
'/tmp/Skipped': 'fast/html/keygen.html',
'/mock/LayoutTests/platform/testwebkitport/test_expectations.txt': 'BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL\n',
'/mock/LayoutTests/platform/testwebkitport/Skipped': 'fast/html/keygen.html',
mock_fs = filesystem_mock.MockFileSystem(files)
port = TestWebKitPort(expectations_file='/tmp/test_expectations.txt',
skips_file='/tmp/Skipped', filesystem=mock_fs)
mock_fs = MockFileSystem(files)
port = TestWebKitPort(filesystem=mock_fs)
"""BUG_TESTEXPECTATIONS SKIP : fast/html/article-element.html = FAIL
BUG_SKIPPED SKIP : fast/html/keygen.html = FAIL
......@@ -274,13 +274,13 @@ class GetBaselinesTest(unittest.TestCase):
expected_baselines={'base': {'.txt': True}})
def _assertBaselines(self, test_files, test_name, expected_baselines):
actual_baselines = rebaselineserver._get_test_baselines(
test_name, get_test_config(test_files))
actual_baselines = rebaselineserver._get_test_baselines(test_name, get_test_config(test_files))
self.assertEqual(expected_baselines, actual_baselines)
def get_test_config(test_files=[], result_files=[]):
layout_tests_directory = base.Port().layout_tests_dir()
# We could grab this from port.layout_tests_dir(), but instantiating a fully mocked port is a pain.
layout_tests_directory = "/mock/LayoutTests"
results_directory = '/WebKitBuild/Debug/layout-test-results'
mock_filesystem = filesystem_mock.MockFileSystem()
for file in test_files:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment