Diff
Modified: trunk/Tools/ChangeLog (279111 => 279112)
--- trunk/Tools/ChangeLog 2021-06-22 10:58:19 UTC (rev 279111)
+++ trunk/Tools/ChangeLog 2021-06-22 12:50:08 UTC (rev 279112)
@@ -1,3 +1,30 @@
+2021-06-22 Kimmo Kinnunen <[email protected]>
+
+ Test runner parses the names of value parametrised GTEST tests wrong
+ https://bugs.webkit.org/show_bug.cgi?id=227207
+
+ Reviewed by Jonathan Bedard.
+
+ Fix the parsing of test names.
+ * Scripts/webkitpy/api_tests/manager_unittest.py:
+ Add a test for the parsing.
+
+ * Scripts/webkitpy/api_tests/manager.py:
+ (Manager._test_list_from_output):
+ Fix the test name parsing.
+ The name is printed as:
+ ValueParametrizedTestsSupported/DogGreen # GetParam() = (Dog, Green)
+
+ * TestWebKitAPI/Test.h:
+ (TestWebKitAPI::TestParametersToStringFormatter::operator() const):
+ Add a general-purpose formatter for all value-parametrized tests
+ to use.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/Misc/TestRunnerTests.cpp: Added.
+ (TestWebKitAPI::TEST_P):
+ Add a value-parametrized test testing the test runner.
+
2021-06-21 Chris Dumez <[email protected]>
[WK2] Don't process-swap on navigations within the same non-HTTP(s) protocol
Modified: trunk/Tools/Scripts/webkitpy/api_tests/manager.py (279111 => 279112)
--- trunk/Tools/Scripts/webkitpy/api_tests/manager.py 2021-06-22 10:58:19 UTC (rev 279111)
+++ trunk/Tools/Scripts/webkitpy/api_tests/manager.py 2021-06-22 12:50:08 UTC (rev 279112)
@@ -55,6 +55,7 @@
result = []
current_test_suite = None
for line in output.split('\n'):
+ line = line.split("#")[0] # Value-parametrized tests contain #.
striped_line = line.lstrip().rstrip()
if not striped_line:
continue
Added: trunk/Tools/Scripts/webkitpy/api_tests/manager_unittest.py (0 => 279112)
--- trunk/Tools/Scripts/webkitpy/api_tests/manager_unittest.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/api_tests/manager_unittest.py 2021-06-22 12:50:08 UTC (rev 279112)
@@ -0,0 +1,53 @@
+# Copyright (C) 2021 Apple Inc. All rights reserved.
+#
+# 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.
+
+"""Unit tests for manager.py."""
+
+import unittest
+
+from webkitpy.api_tests.manager import Manager
+
+
+class ManagerTest(unittest.TestCase):
+ def test_test_list_from_output(self):
+ gtest_list_tests_output = """WKWebViewDisableSelection.
+ DoubleClickDoesNotSelectWhenTextInteractionsAreDisabled
+ DragDoesNotSelectWhenTextInteractionsAreDisabled
+Misc/ValueParametrizedTest.
+ ValueParametrizedTestsSupported/CatRed # GetParam() = (Cat, Red)
+ ValueParametrizedTestsSupported/CatGreen # GetParam() = (Cat, Green)
+ ValueParametrizedTestsSupported/DogRed # GetParam() = (Dog, Red)
+ ValueParametrizedTestsSupported/DogGreen # GetParam() = (Dog, Green)
+A.
+ B
+"""
+ expected_tests = [
+ "WKWebViewDisableSelection.DoubleClickDoesNotSelectWhenTextInteractionsAreDisabled",
+ "WKWebViewDisableSelection.DragDoesNotSelectWhenTextInteractionsAreDisabled",
+ "Misc/ValueParametrizedTest.ValueParametrizedTestsSupported/CatRed",
+ "Misc/ValueParametrizedTest.ValueParametrizedTestsSupported/CatGreen",
+ "Misc/ValueParametrizedTest.ValueParametrizedTestsSupported/DogRed",
+ "Misc/ValueParametrizedTest.ValueParametrizedTestsSupported/DogGreen",
+ "A.B",
+ ]
+ got_tests = Manager._test_list_from_output(gtest_list_tests_output)
+ self.assertEqual(expected_tests, got_tests)
Modified: trunk/Tools/TestWebKitAPI/Test.h (279111 => 279112)
--- trunk/Tools/TestWebKitAPI/Test.h 2021-06-22 10:58:19 UTC (rev 279111)
+++ trunk/Tools/TestWebKitAPI/Test.h 2021-06-22 12:50:08 UTC (rev 279112)
@@ -27,6 +27,7 @@
#define Test_h
#include <type_traits>
+#include <wtf/ASCIICType.h>
namespace TestWebKitAPI {
@@ -53,6 +54,23 @@
#define EXPECT_STRONG_ENUM_EQ(expected, actual) \
EXPECT_PRED_FORMAT2(TestWebKitAPI::assertStrongEnum, expected, actual)
+// Test parameter formatter for the parameter-generated part of the
+// name of value-parametrized tests.
+// Clients should implement `void PrintTo(TheParameterType value, ::std::ostream* o)`
+// in the same namespace as the TheParameterType.
+struct TestParametersToStringFormatter {
+ template <class ParamType>
+ std::string operator()(const testing::TestParamInfo<ParamType> &info) const
+ {
+ std::string name = testing::PrintToStringParamName()(info);
+ std::string sanitized;
+ for (const char c : name) {
+ if (isASCIIAlphanumeric(c))
+ sanitized += c;
+ }
+ return sanitized;
+ }
+};
} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (279111 => 279112)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-06-22 10:58:19 UTC (rev 279111)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-06-22 12:50:08 UTC (rev 279112)
@@ -592,6 +592,7 @@
7AEAD4811E20122700416EFE /* CrossPartitionFileSchemeAccess.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */; };
7B18417C2673860200ED4F8D /* ImageBufferTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B18417B2673860200ED4F8D /* ImageBufferTests.cpp */; };
7B2739F32632AB640040F182 /* ThreadAssertionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B2739F22632AB640040F182 /* ThreadAssertionsTest.cpp */; };
+ 7B774906267CCE72009873B4 /* TestRunnerTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B774904267CCE68009873B4 /* TestRunnerTests.cpp */; };
7B7D096A2519F8F90017A078 /* WebGLNoCrashOnOtherThreadAccess.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7B7D09692519F8F90017A078 /* WebGLNoCrashOnOtherThreadAccess.mm */; };
7C1AF7951E8DCBAB002645B9 /* PrepareForMoveToWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C1AF7931E8DCBAB002645B9 /* PrepareForMoveToWindow.mm */; };
7C3965061CDD74F90094DBB8 /* ColorTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3965051CDD74F90094DBB8 /* ColorTests.cpp */; };
@@ -2462,6 +2463,7 @@
7AEAD47D1E20114E00416EFE /* CrossPartitionFileSchemeAccess.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = CrossPartitionFileSchemeAccess.html; path = Tests/mac/CrossPartitionFileSchemeAccess.html; sourceTree = SOURCE_ROOT; };
7B18417B2673860200ED4F8D /* ImageBufferTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBufferTests.cpp; sourceTree = "<group>"; };
7B2739F22632AB640040F182 /* ThreadAssertionsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadAssertionsTest.cpp; sourceTree = "<group>"; };
+ 7B774904267CCE68009873B4 /* TestRunnerTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestRunnerTests.cpp; sourceTree = "<group>"; };
7B7D09692519F8F90017A078 /* WebGLNoCrashOnOtherThreadAccess.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGLNoCrashOnOtherThreadAccess.mm; sourceTree = "<group>"; };
7C1AF7931E8DCBAB002645B9 /* PrepareForMoveToWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrepareForMoveToWindow.mm; sourceTree = "<group>"; };
7C3965051CDD74F90094DBB8 /* ColorTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorTests.cpp; sourceTree = "<group>"; };
@@ -3861,6 +3863,14 @@
path = ios;
sourceTree = "<group>";
};
+ 7B774903267CCE38009873B4 /* Misc */ = {
+ isa = PBXGroup;
+ children = (
+ 7B774904267CCE68009873B4 /* TestRunnerTests.cpp */,
+ );
+ path = Misc;
+ sourceTree = "<group>";
+ };
7C83E0281D0A5CDF00FEBCF3 /* Frameworks */ = {
isa = PBXGroup;
children = (
@@ -4673,6 +4683,7 @@
7560917619259C59009EF06E /* ios */,
14CC42E024B8D7E700E64F48 /* _javascript_Core */,
C07E6CAD13FD67650038B22B /* mac */,
+ 7B774903267CCE38009873B4 /* Misc */,
C08587F913FEC39B001EF4E5 /* TestWebKitAPI */,
440A1D3614A01000008A66F2 /* WebCore */,
BC9096411255616000083756 /* WebKit */,
@@ -5775,6 +5786,7 @@
F45E15762112CE6200307E82 /* TestInputDelegate.mm in Sources */,
F45D3891215A7B4B002A2979 /* TestInspectorBar.mm in Sources */,
516281252325C18000BB7E42 /* TestPDFDocument.mm in Sources */,
+ 7B774906267CCE72009873B4 /* TestRunnerTests.cpp in Sources */,
5774AA6821FBBF7800AF2A1B /* TestSOAuthorization.mm in Sources */,
F4CD74C920FDB49600DE3794 /* TestURLSchemeHandler.mm in Sources */,
F4517B672054C49500C26721 /* TestWKWebViewController.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/Misc/TestRunnerTests.cpp (0 => 279112)
--- trunk/Tools/TestWebKitAPI/Tests/Misc/TestRunnerTests.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/Misc/TestRunnerTests.cpp 2021-06-22 12:50:08 UTC (rev 279112)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include "Test.h" // NOLINT
+
+namespace TestWebKitAPI {
+
+namespace {
+
+enum class TestEnum1 {
+ Cat, Dog
+};
+
+enum class TestEnum2 {
+ Red, Green
+};
+
+void PrintTo(TestEnum1 value, ::std::ostream* o)
+{
+ if (value == TestEnum1::Cat)
+ *o << "Cat";
+ else if (value == TestEnum1::Dog)
+ *o << "Dog";
+ else
+ *o << "Unknown";
+}
+
+void PrintTo(TestEnum2 value, ::std::ostream* o)
+{
+ if (value == TestEnum2::Red)
+ *o << "Red";
+ else if (value == TestEnum2::Green)
+ *o << "Green";
+ else
+ *o << "Unknown";
+}
+
+class ValueParametrizedTest : public testing::TestWithParam<std::tuple<TestEnum1, TestEnum2>> {
+public:
+ TestEnum1 enum1() const { return std::get<0>(GetParam()); }
+ TestEnum2 enum2() const { return std::get<1>(GetParam()); }
+};
+
+}
+
+// Tests that WebKitTestRunner supports value-parametrized tests.
+// See: https://github.com/google/googletest/blob/master/docs/advanced.md#value-parameterized-tests
+// At the time of writing the test runner python script couldn't parse the
+// results of --gtest_list_tests.
+TEST_P(ValueParametrizedTest, ValueParametrizedTestsSupported)
+{
+ EXPECT_TRUE(true);
+}
+
+INSTANTIATE_TEST_SUITE_P(Misc,
+ ValueParametrizedTest,
+ testing::Combine(
+ testing::Values(TestEnum1::Cat, TestEnum1::Dog),
+ testing::Values(TestEnum2::Red, TestEnum2::Green)),
+ TestParametersToStringFormatter());
+
+} // namespace TestWebKitAPI