Commit 3f6d0579 authored by Robert Ma's avatar Robert Ma Committed by Commit Bot

[blinkpy] Correctly roundtrip WebDriver test names

Regardless of with or without subtest names

TBR=lpz

Bug: 1000441
Change-Id: I9aa9c773e796b07e4447c6b107f38bea692048a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783109Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692873}
parent 52fa28a7
......@@ -1780,22 +1780,32 @@ class Port(object):
raise TestRunException(exit_codes.SYS_DEPS_EXIT_STATUS, message)
return result
def split_webdriver_test_name(self, test_name):
@staticmethod
def split_webdriver_test_name(test_name):
"""Splits a WebDriver test name into a filename and a subtest name and
returns both of them. E.g.
abd::foo.html -> (abd, foo.html)
test.py>>foo.html -> (test.py, foo.html)
test.py -> (test.py, None)
"""
separator_index = test_name.find(self.WEBDRIVER_SUBTEST_SEPARATOR)
separator_index = test_name.find(Port.WEBDRIVER_SUBTEST_SEPARATOR)
if separator_index == -1:
return test_name
return (test_name, None)
webdriver_test_name = test_name[:separator_index]
separator_len = len(self.WEBDRIVER_SUBTEST_SEPARATOR)
separator_len = len(Port.WEBDRIVER_SUBTEST_SEPARATOR)
subtest_suffix = test_name[separator_index + separator_len:]
return (webdriver_test_name, subtest_suffix)
def add_webdriver_subtest_suffix(self, test_name, subtest_name):
return test_name + self.WEBDRIVER_SUBTEST_SEPARATOR + subtest_name
@staticmethod
def add_webdriver_subtest_suffix(test_name, subtest_name):
"""Appends a subtest name to a WebDriver test name. E.g.
(test.py, foo.html) -> test.py>>foo.html
(test.py, None) -> test.py
"""
if subtest_name:
return test_name + Port.WEBDRIVER_SUBTEST_SEPARATOR + subtest_name
return test_name
class VirtualTestSuite(object):
......
......@@ -970,23 +970,18 @@ class PortTest(LoggingTestCase):
self.assertTrue(port.skips_test('failures/expected/image.html'))
def test_split_webdriver_test_name(self):
port = self.make_port()
webdriver_expectation_name = "tests/accept_alert/accept.py>>foo"
(wb_test, subtest) = port.split_webdriver_test_name(webdriver_expectation_name)
self.assertEqual(wb_test, "tests/accept_alert/accept.py")
self.assertEqual(subtest, "foo")
self.assertEqual(
Port.split_webdriver_test_name("tests/accept_alert/accept.py>>foo"),
("tests/accept_alert/accept.py", "foo"))
self.assertEqual(
Port.split_webdriver_test_name("tests/accept_alert/accept.py"),
("tests/accept_alert/accept.py", None))
def test_add_webdriver_subtest_suffix(self):
port = self.make_port()
wb_test_name = "abd"
sub_test_name = "bar"
full_webdriver_name = port.add_webdriver_subtest_suffix(wb_test_name, sub_test_name)
self.assertEqual(full_webdriver_name, "abd>>bar")
self.assertEqual(
Port.add_webdriver_subtest_suffix("abd", "bar"), "abd>>bar")
self.assertEqual(
Port.add_webdriver_subtest_suffix("abd", None), "abd")
def test_add_webdriver_subtest_suffix(self):
port = self.make_port()
......
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