[test] Deduplicate parsing source file flags.

Bug: v8:6917
Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I12d62e28b8e22820d4358d0166fa5db5e09b8bc3
Reviewed-on: https://chromium-review.googlesource.com/819630
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50033}
This commit is contained in:
Michal Majewski 2017-12-12 13:29:36 +01:00 committed by Commit Bot
parent 222076d927
commit 4f4654a013
7 changed files with 20 additions and 32 deletions

View File

@ -9,7 +9,6 @@ from testrunner.local import testsuite
from testrunner.objects import testcase
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE)
class DebuggerTestSuite(testsuite.TestSuite):
@ -40,9 +39,7 @@ class DebuggerTestSuite(testsuite.TestSuite):
context.mode_flags
)
source = self.GetSourceForTest(testcase)
flags_match = re.findall(FLAGS_PATTERN, source)
for match in flags_match:
flags += match.strip().split()
flags += self._parse_source_flags(testcase, source)
files_list = [] # List of file names to append to command arguments.
files_match = FILES_PATTERN.search(source);

View File

@ -4,14 +4,11 @@
import itertools
import os
import re
import shlex
from testrunner.local import testsuite
from testrunner.local import utils
from testrunner.objects import testcase
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
PROTOCOL_TEST_JS = "protocol-test.js"
EXPECTED_SUFFIX = "-expected.txt"
RESOURCES_FOLDER = "resources"
@ -42,11 +39,8 @@ class InspectorProtocolTestSuite(testsuite.TestSuite):
return 'inspector-test'
def GetParametersForTestCase(self, testcase, context):
source = self.GetSourceForTest(testcase)
flags = testcase.flags + context.mode_flags
flags_match = re.findall(FLAGS_PATTERN, source)
for match in flags_match:
flags += shlex.split(match.strip())
flags += self._parse_source_flags(testcase)
files = [
os.path.join(self.root, PROTOCOL_TEST_JS),
os.path.join(self.root, testcase.path + self.suffix()),

View File

@ -26,13 +26,10 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import re
from testrunner.local import testsuite
from testrunner.objects import testcase
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
class IntlTestSuite(testsuite.TestSuite):
def __init__(self, name, root):
@ -57,11 +54,8 @@ class IntlTestSuite(testsuite.TestSuite):
return tests
def GetParametersForTestCase(self, testcase, context):
source = self.GetSourceForTest(testcase)
flags = testcase.flags + ["--allow-natives-syntax"] + context.mode_flags
flags_match = re.findall(FLAGS_PATTERN, source)
for match in flags_match:
flags += match.strip().split()
flags += self._parse_source_flags(testcase)
files = []
files.append(os.path.join(self.root, "assert.js"))

View File

@ -34,7 +34,6 @@ from testrunner.local import utils
from testrunner.objects import testcase
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
INVALID_FLAGS = ["--enable-slow-asserts"]
MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE)
@ -70,9 +69,7 @@ class MessageTestSuite(testsuite.TestSuite):
files.append("--module")
files.append(os.path.join(self.root, testcase.path + ".js"))
flags = testcase.flags + context.mode_flags
flags_match = re.findall(FLAGS_PATTERN, source)
for match in flags_match:
flags += match.strip().split()
flags += self._parse_source_flags(testcase, source)
flags = [x for x in flags if x not in INVALID_FLAGS]
return files, flags, {}

View File

@ -31,7 +31,6 @@ import re
from testrunner.local import testsuite
from testrunner.objects import testcase
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
ENV_PATTERN = re.compile(r"//\s+Environment Variables:(.*)")
SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
@ -66,9 +65,7 @@ class MjsunitTestSuite(testsuite.TestSuite):
flags = testcase.flags + context.mode_flags
env = self._get_env(source)
flags_match = re.findall(FLAGS_PATTERN, source)
for match in flags_match:
flags += match.strip().split()
flags += self._parse_source_flags(testcase, source)
files_list = [] # List of file names to append to command arguments.
files_match = FILES_PATTERN.search(source);

View File

@ -32,7 +32,6 @@ import re
from testrunner.local import testsuite
from testrunner.objects import testcase
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
@ -65,9 +64,7 @@ class WebkitTestSuite(testsuite.TestSuite):
def GetParametersForTestCase(self, testcase, context):
source = self.GetSourceForTest(testcase)
flags = testcase.flags + context.mode_flags
flags_match = re.findall(FLAGS_PATTERN, source)
for match in flags_match:
flags += match.strip().split()
flags += self._parse_source_flags(testcase, source)
files_list = [] # List of file names to append to command arguments.
files_match = FILES_PATTERN.search(source);

View File

@ -29,17 +29,20 @@
import fnmatch
import imp
import os
import re
import shlex
from . import command
from . import statusfile
from . import utils
from ..objects import testcase
from variants import ALL_VARIANTS, ALL_VARIANT_FLAGS, FAST_VARIANT_FLAGS
FAST_VARIANTS = set(["default", "turbofan"])
STANDARD_VARIANT = set(["default"])
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
class VariantGenerator(object):
def __init__(self, suite, variants):
@ -69,7 +72,7 @@ class VariantGenerator(object):
class TestSuite(object):
@staticmethod
def LoadTestSuite(root):
def LoadTestSuite(root, global_init=True):
name = root.split(os.path.sep)[-1]
f = None
try:
@ -345,6 +348,15 @@ class TestSuite(object):
"""Returns a tuple of (files, flags, env) for this test case."""
raise NotImplementedError
def _parse_source_flags(self, test, source=None):
if not source:
source = self.GetSourceForTest(test)
flags = []
for match in re.findall(FLAGS_PATTERN, source):
flags += shlex.split(match.strip())
return flags
def GetSourceForTest(self, testcase):
return "(no source available)"