Commit 6b52a54b authored by Tamer Tas's avatar Tamer Tas Committed by Commit Bot

[testrunner] generalize test loader to accept multiple extensions

testrunner assumes that each test suite has a single extension for base tests.
".mjs" extension can be used for ECMAScript modules in addition to the standard
extension ".js" we use for the base tests.

This CL generalizes the {TestLoader} to accept multiple extensions for
a single test suite.

R=mathias@chromium.org
TBR=machenbach@chromium.org
CC=​gsathya@chromium.org

Bug: v8:9395
Change-Id: Ibc155f4963472fe9f989458cd839f3642ffbddea
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1675961Reviewed-by: 's avatarMathias Bynens <mathias@chromium.org>
Reviewed-by: 's avatarTamer Tas <tmrts@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Auto-Submit: Tamer Tas <tmrts@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62356}
parent 9d4772db
......@@ -16,8 +16,8 @@ META_TIMEOUT_REGEXP = re.compile(r"META:\s*timeout=(.*)")
class TestLoader(testsuite.JSTestLoader):
@property
def extension(self):
return ANY_JS
def extensions(self):
return [ANY_JS]
class TestSuite(testsuite.TestSuite):
......
......@@ -154,11 +154,18 @@ class GenericTestLoader(TestLoader):
return [self.test_root]
@property
def extension(self):
return ""
def extensions(self):
return []
def __find_extension(self, filename):
for extension in self.extensions:
if filename.endswith(extension):
return extension
return False
def _should_filter_by_name(self, filename):
if not filename.endswith(self.extension):
if not self.__find_extension(filename):
return True
for suffix in self.excluded_suffixes:
......@@ -171,10 +178,11 @@ class GenericTestLoader(TestLoader):
return False
def _filename_to_testname(self, filename):
if not self.extension:
extension = self.__find_extension(filename)
if not extension:
return filename
return filename[:-len(self.extension)]
return filename[:-len(extension)]
def _to_relpath(self, abspath, test_root):
return os.path.relpath(abspath, test_root)
......@@ -197,8 +205,8 @@ class GenericTestLoader(TestLoader):
class JSTestLoader(GenericTestLoader):
@property
def extension(self):
return ".js"
def extensions(self):
return [".js", ".mjs"]
class TestGenerator(object):
......
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