Skip to content

Instantly share code, notes, and snippets.

@Smith1123
Created October 20, 2011 16:13
Show Gist options
  • Save Smith1123/1301553 to your computer and use it in GitHub Desktop.
Save Smith1123/1301553 to your computer and use it in GitHub Desktop.
Patch
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 4f3cd8d..61510bc 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,23 @@
+2011-10-20 Zsolt Fehér <feherzs@inf.u-szeged.hu>
+
+ [WK2] Enable pixel test on WK2 if expected.png exists
+ https://bugs.webkit.org/show_bug.cgi?id=70484
+
+ Reviewed by NOBODY (OOPS!).
+
+ * Scripts/webkitpy/layout_tests/controllers/single_test_runner.py:
+ * Scripts/webkitpy/layout_tests/models/test_input.py:
+ * Scripts/webkitpy/layout_tests/port/webkit.py:
+ * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::TestController):
+ (WTR::TestController::initialize):
+ (WTR::TestController::runTest):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::setIsWK2PixelTest):
+ * WebKitTestRunner/TestInvocation.h:
+
2011-10-20 Leandro Pereira <leandro@profusion.mobi>
[EFL] Unreviewed. Build fix after r97043.
diff --git a/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py b/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py
index ad4745c..18a2802 100644
--- a/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py
+++ b/Tools/Scripts/webkitpy/layout_tests/controllers/single_test_runner.py
@@ -54,6 +54,7 @@ class SingleTestRunner:
self._timeout = test_input.timeout
self._worker_name = worker_name
self._test_name = test_input.test_name
+ self._should_run_pixel_test = test_input.should_run_pixel_test
self._is_reftest = False
self._is_mismatch_reftest = False
@@ -95,6 +96,8 @@ class SingleTestRunner:
self._port.expected_audio(self._test_name))
def _should_fetch_expected_checksum(self):
+ if self._port.driver_name() == "WebKitTestRunner" and self._port.get_option('wk2_pixel_test'):
+ return self._should_run_pixel_test
return (self._options.pixel_tests and
not (self._options.new_baseline or self._options.reset_results))
@@ -109,6 +112,11 @@ class SingleTestRunner:
return DriverInput(self._test_name, self._timeout, image_hash)
def run(self):
+ if self._port.driver_name() == "WebKitTestRunner" and self._port.get_option('wk2_pixel_test'):
+ image = self._port.expected_image(self._test_name)
+ if image != None:
+ self._should_run_pixel_test = True
+ self._options.pixel_tests = True
if self._options.new_baseline or self._options.reset_results:
if self._is_reftest:
# Returns a dummy TestResult. We don't have to rebase for reftests.
diff --git a/Tools/Scripts/webkitpy/layout_tests/models/test_input.py b/Tools/Scripts/webkitpy/layout_tests/models/test_input.py
index d5602d6..18e4e42 100644
--- a/Tools/Scripts/webkitpy/layout_tests/models/test_input.py
+++ b/Tools/Scripts/webkitpy/layout_tests/models/test_input.py
@@ -32,13 +32,14 @@
class TestInput:
"""Groups information about a test for easy passing of data."""
- def __init__(self, test_name, timeout):
+ def __init__(self, test_name, timeout, should_run_pixel_test=False):
"""Holds the input parameters for a test.
Args:
test: name of test (not an absolute path!)
timeout: Timeout in msecs the driver should use while running the test
"""
self.test_name = test_name
+ self.should_run_pixel_test = should_run_pixel_test
self.timeout = timeout
def __repr__(self):
diff --git a/Tools/Scripts/webkitpy/layout_tests/port/webkit.py b/Tools/Scripts/webkitpy/layout_tests/port/webkit.py
index a83b496..e61e81b 100644
--- a/Tools/Scripts/webkitpy/layout_tests/port/webkit.py
+++ b/Tools/Scripts/webkitpy/layout_tests/port/webkit.py
@@ -450,6 +450,8 @@ class WebKitDriver(Driver):
cmd.append('--complex-text')
if self._port.get_option('threaded'):
cmd.append('--threaded')
+ if self._port.get_option('wk2_pixel_test'):
+ cmd.append('--wk2-pixel-test')
# FIXME: We need to pass --timeout=SECONDS to WebKitTestRunner for WebKit2.
cmd.extend(self._port.get_option('additional_drt_flag', []))
diff --git a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
index 7245f9b..49a927d 100755
--- a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
+++ b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
@@ -285,6 +285,8 @@ def parse_args(args=None):
optparse.make_option("--no-new-test-results", action="store_false",
dest="new_test_results", default=True,
help="Don't create new baselines when no expected results exist"),
+ optparse.make_option("--wk2-pixel-test", action="store_true",
+ dest="wk2_pixel_test", help="Enable pixel-to-pixel PNG comparisons on WebKit2"),
optparse.make_option("--skip-failing-tests", action="store_true",
default=False, help="Skip tests that are expected to fail. "
"Note: When using this option, you might miss new crashes "
diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp
index fac63cd..51d9c93 100644
--- a/Tools/WebKitTestRunner/TestController.cpp
+++ b/Tools/WebKitTestRunner/TestController.cpp
@@ -63,6 +63,7 @@ TestController& TestController::shared()
TestController::TestController(int argc, const char* argv[])
: m_dumpPixels(false)
+ , m_wk2PixelTest(false)
, m_verbose(false)
, m_printSeparators(false)
, m_usingServerMode(false)
@@ -249,6 +250,10 @@ void TestController::initialize(int argc, const char* argv[])
m_dumpPixels = true;
continue;
}
+ if (argument == "--wk2-pixel-test") {
+ m_wk2PixelTest = true;
+ continue;
+ }
if (argument == "--verbose") {
m_verbose = true;
continue;
@@ -478,7 +483,10 @@ bool TestController::runTest(const char* test)
m_currentInvocation = adoptPtr(new TestInvocation(pathOrURL));
if (m_dumpPixels)
- m_currentInvocation->setIsPixelTest(expectedPixelHash);
+ m_currentInvocation->setIsPixelTest(expectedPixelHash);
+
+ if (m_wk2PixelTest)
+ m_currentInvocation->setIsWK2PixelTest(expectedPixelHash);
m_currentInvocation->invoke();
m_currentInvocation.clear();
diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h
index d0d2151..90a90c1 100644
--- a/Tools/WebKitTestRunner/TestController.h
+++ b/Tools/WebKitTestRunner/TestController.h
@@ -104,6 +104,7 @@ private:
OwnPtr<TestInvocation> m_currentInvocation;
bool m_dumpPixels;
+ bool m_wk2PixelTest;
bool m_verbose;
bool m_printSeparators;
bool m_usingServerMode;
diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp
index 451d666..c3de349 100644
--- a/Tools/WebKitTestRunner/TestInvocation.cpp
+++ b/Tools/WebKitTestRunner/TestInvocation.cpp
@@ -109,6 +109,14 @@ void TestInvocation::setIsPixelTest(const std::string& expectedPixelHash)
m_expectedPixelHash = expectedPixelHash;
}
+void TestInvocation::setIsWK2PixelTest(const std::string& expectedPixelHash)
+{
+ if (!expectedPixelHash.length())
+ return;
+ m_dumpPixels = true;
+ m_expectedPixelHash = expectedPixelHash;
+}
+
static const unsigned w3cSVGWidth = 480;
static const unsigned w3cSVGHeight = 360;
static const unsigned normalWidth = 800;
diff --git a/Tools/WebKitTestRunner/TestInvocation.h b/Tools/WebKitTestRunner/TestInvocation.h
index 5ff7ea0..8bf0ff4 100644
--- a/Tools/WebKitTestRunner/TestInvocation.h
+++ b/Tools/WebKitTestRunner/TestInvocation.h
@@ -39,7 +39,8 @@ public:
~TestInvocation();
void setIsPixelTest(const std::string& expectedPixelHash);
-
+ void setIsWK2PixelTest(const std::string& expectedPixelHash);
+
void invoke();
void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
WKRetainPtr<WKTypeRef> didReceiveSynchronousMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment