Title: [189283] trunk/Tools
- Revision
- 189283
- Author
- [email protected]
- Date
- 2015-09-03 13:15:07 -0700 (Thu, 03 Sep 2015)
Log Message
[WK2] Allow tagging tests with metadata which needs to be known at web process creation time
https://bugs.webkit.org/show_bug.cgi?id=148723
Reviewed by Anders Carlsson.
* WebKitTestRunner/TestController.cpp:
(WTR::testPath):
(WTR::updateViewOptionsFromTestHeader):
(WTR::TestController::viewOptionsForTest):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (189282 => 189283)
--- trunk/Tools/ChangeLog 2015-09-03 20:12:17 UTC (rev 189282)
+++ trunk/Tools/ChangeLog 2015-09-03 20:15:07 UTC (rev 189283)
@@ -1,3 +1,15 @@
+2015-09-03 Myles C. Maxfield <[email protected]>
+
+ [WK2] Allow tagging tests with metadata which needs to be known at web process creation time
+ https://bugs.webkit.org/show_bug.cgi?id=148723
+
+ Reviewed by Anders Carlsson.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::testPath):
+ (WTR::updateViewOptionsFromTestHeader):
+ (WTR::TestController::viewOptionsForTest):
+
2015-09-03 Lucas Forschler <[email protected]>
Test commit.
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (189282 => 189283)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2015-09-03 20:12:17 UTC (rev 189282)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2015-09-03 20:15:07 UTC (rev 189283)
@@ -54,6 +54,7 @@
#include <algorithm>
#include <cstdio>
#include <ctype.h>
+#include <fstream>
#include <runtime/InitializeThreading.h>
#include <stdlib.h>
#include <string>
@@ -61,6 +62,7 @@
#include <wtf/RunLoop.h>
#include <wtf/TemporaryChange.h>
#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
#if PLATFORM(COCOA)
#include <WebKit/WKContextPrivateMac.h>
@@ -792,6 +794,57 @@
return false;
}
+static std::string testPath(const WKURLRef url)
+{
+ auto scheme = adoptWK(WKURLCopyScheme(url));
+ if (WKStringIsEqualToUTF8CStringIgnoringCase(scheme.get(), "file")) {
+ auto path = adoptWK(WKURLCopyPath(url));
+ auto buffer = std::vector<char>(WKStringGetMaximumUTF8CStringSize(path.get()));
+ auto length = WKStringGetUTF8CString(path.get(), buffer.data(), buffer.size());
+ return std::string(buffer.data(), length);
+ }
+ return std::string();
+}
+
+static void updateViewOptionsFromTestHeader(ViewOptions& viewOptions, const TestInvocation& test)
+{
+ std::string filename = testPath(test.url());
+ if (filename.empty())
+ return;
+
+ std::string options;
+ std::ifstream testFile(filename.data());
+ if (!testFile.good())
+ return;
+ getline(testFile, options);
+ std::string beginString("webkit-test-runner [ ");
+ std::string endString(" ]");
+ size_t beginLocation = options.find(beginString);
+ if (beginLocation == std::string::npos)
+ return;
+ size_t endLocation = options.find(endString, beginLocation);
+ if (endLocation == std::string::npos) {
+ LOG_ERROR("Could not find end of test header in %s", filename.c_str());
+ return;
+ }
+ std::string pairString = options.substr(beginLocation + beginString.size(), endLocation - (beginLocation + beginString.size()));
+ size_t pairStart = 0;
+ while (pairStart < pairString.size()) {
+ size_t pairEnd = pairString.find(" ", pairStart);
+ if (pairEnd == std::string::npos)
+ pairEnd = pairString.size();
+ size_t equalsLocation = pairString.find("=", pairStart);
+ if (equalsLocation == std::string::npos) {
+ LOG_ERROR("Malformed option in test header (could not find '=' character) in %s", filename.c_str());
+ break;
+ }
+ auto key = pairString.substr(pairStart, equalsLocation - pairStart);
+ auto value = pairString.substr(equalsLocation + 1, pairEnd - (equalsLocation + 1));
+ // Options processing to modify viewOptions goes here.
+ pairStart = pairEnd + 1;
+ }
+}
+
ViewOptions TestController::viewOptionsForTest(const TestInvocation& test) const
{
ViewOptions viewOptions;
@@ -800,6 +853,8 @@
viewOptions.shouldShowWebView = m_shouldShowWebView;
viewOptions.useFixedLayout = shouldUseFixedLayout(test);
+ updateViewOptionsFromTestHeader(viewOptions, test);
+
updatePlatformSpecificViewOptionsForTest(viewOptions, test);
return viewOptions;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes