Commit 5a4e394f authored by Scott Lee's avatar Scott Lee Committed by Chromium LUCI CQ

[web_tests] unvirtualize location.fileName if does not exist.

Visit https://crbug.com/1163553#c12 for the context.


Bug: 1163553
Change-Id: Ib9ae405f1bfeb2bff552836cc83101d88d330ab6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611572
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarChan Li <chanli@chromium.org>
Reviewed-by: default avatarNodir Turakulov <nodir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843135}
parent b4641e8a
......@@ -187,9 +187,13 @@ class TestResultSink(object):
if self.is_closed:
raise TestResultSinkClosed('sink() cannot be called after close()')
# The structure and member definitions of this dict can be found at
# https://chromium.googlesource.com/infra/luci/luci-go/+/refs/heads/master/resultdb/proto/sink/v1/test_result.proto
loc_file_name = '//%s%s' % (RELATIVE_WEB_TESTS, result.test_name)
# fileName refers to the real file path instead of the test path
# that might be virtualized.
path = (self._port.get_file_path_for_wpt_test(result.test_name)
or self._port.name_for_test(result.test_name))
if self._port.host.filesystem.sep != '/':
path = path.replace(self._port.host.filesystem.sep, '/')
loc_fn = '//%s%s' % (RELATIVE_WEB_TESTS, path)
summaries, artifacts = self._artifacts(result)
r = {
'artifacts': artifacts,
......@@ -204,13 +208,12 @@ class TestResultSink(object):
'testId': result.test_name,
'testMetadata': {
'name': result.test_name,
# location is where the test is defined. It is used to find
# the associated component/team/os information in flakiness
# and disabled-test dashboards.
'location': {
'repo': 'https://chromium.googlesource.com/chromium/src',
'fileName': loc_file_name,
'fileName': loc_fn,
# skip: 'line'
},
},
......
......@@ -17,12 +17,15 @@ from blinkpy.web_tests.controllers.test_result_sink import CreateTestResultSink
from blinkpy.web_tests.controllers.test_result_sink import TestResultSink
from blinkpy.web_tests.models import test_results
from blinkpy.web_tests.models.typ_types import ResultType
from blinkpy.web_tests.port.test import add_manifest_to_mock_filesystem
from blinkpy.web_tests.port.test import TestPort
from blinkpy.web_tests.port.test import WEB_TEST_DIR
class TestResultSinkTestBase(unittest.TestCase):
def setUp(self):
super(TestResultSinkTestBase, self).setUpClass()
self.port = MockHost().port_factory.get()
self.port = TestPort(MockHost())
def luci_context(self, **section_values):
if not section_values:
......@@ -189,3 +192,37 @@ class TestResultSinkMessage(TestResultSinkTestBase):
# The artifact tags should be sorted by the artifact names.
['command', 'crash_log', 'stderr'],
)
def assertFilename(self, test_name, expected_filename):
sent_data = self.sink(True, test_results.TestResult(test_name))
self.assertEqual(sent_data['testMetadata']['location']['fileName'],
'//' + RELATIVE_WEB_TESTS + expected_filename)
def test_location_filename(self):
self.assertFilename('real/test.html', 'real/test.html')
# TestPort.virtual_test_suites() has a set of hard-coded virtualized
# tests, and a test name must start with one of the virtual prefixes
# and base in order for it to be recognized as a virtual test.
self.assertFilename(
'virtual/virtual_passes/passes/does_not_exist.html',
'passes/does_not_exist.html')
self.port.host.filesystem.write_text_file(
self.port.host.filesystem.join(WEB_TEST_DIR, 'virtual',
'virtual_passes', 'passes',
'exists.html'),
'body',
)
self.assertFilename('virtual/virtual_passes/passes/exists.html',
'virtual/virtual_passes/passes/exists.html')
def test_wpt_location_filename(self):
add_manifest_to_mock_filesystem(self.port)
self.assertFilename(
'external/wpt/html/parse.html?run_type=uri',
'external/wpt/html/parse.html',
)
self.assertFilename(
'virtual/virtual_wpt/external/wpt/dom/ranges/Range-attributes.html',
'external/wpt/dom/ranges/Range-attributes.html',
)
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