[test] Fix resource-fetching logic for imported files

Path names in import/export statements are relative to the file they are in.

This fixes the logic and unblocks using the messages test suite on Android,
which has cases importing files from mjsunit, which import more files from
there.

Bug: chromium:866862
Change-Id: I8d2ff645f69b67fbdaf4a622d06308e55298b0ce
Reviewed-on: https://chromium-review.googlesource.com/1206570
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55643}
This commit is contained in:
Michael Achenbach 2018-09-05 11:38:39 +02:00 committed by Commit Bot
parent c433112cca
commit beb7778d87

View File

@ -323,13 +323,11 @@ class D8TestCase(TestCase):
# Files in load statements are relative to base dir.
add_path(match.group(1))
for match in MODULE_RESOURCES_PATTERN_1.finditer(source):
# Imported files are side by side with the test case.
add_path(os.path.join(
self.suite.root, os.path.dirname(self.path), match.group(1)))
# Imported files are relative to the file importing them.
add_path(os.path.join(os.path.dirname(file), match.group(1)))
for match in MODULE_RESOURCES_PATTERN_2.finditer(source):
# Imported files are side by side with the test case.
add_path(os.path.join(
self.suite.root, os.path.dirname(self.path), match.group(1)))
# Imported files are relative to the file importing them.
add_path(os.path.join(os.path.dirname(file), match.group(1)))
return result
def _get_resources(self):