summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/testcfg.py
diff options
context:
space:
mode:
authorMyles Borins <mylesborins@google.com>2018-04-10 21:39:51 -0400
committerJames M Snell <jasnell@gmail.com>2018-04-16 16:02:46 -0700
commit9daebb48d6f0ca63e72197a69e46c8ab43bc5d02 (patch)
tree8605276308c8b4e3597516961266bae1af57557a /deps/v8/test/mjsunit/testcfg.py
parent7d2814e7903155e61f244ae70721da1531cbcaec (diff)
downloadnode-new-9daebb48d6f0ca63e72197a69e46c8ab43bc5d02.tar.gz
deps: update V8 to 6.6.346.23
PR-URL: https://github.com/nodejs/node/pull/19201 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/test/mjsunit/testcfg.py')
-rw-r--r--deps/v8/test/mjsunit/testcfg.py191
1 files changed, 184 insertions, 7 deletions
diff --git a/deps/v8/test/mjsunit/testcfg.py b/deps/v8/test/mjsunit/testcfg.py
index bc9d69ff33..d31a189ba2 100644
--- a/deps/v8/test/mjsunit/testcfg.py
+++ b/deps/v8/test/mjsunit/testcfg.py
@@ -25,11 +25,15 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+from collections import OrderedDict
+import itertools
import os
import re
+from testrunner.local import statusfile
from testrunner.local import testsuite
from testrunner.objects import testcase
+from testrunner.outproc import base as outproc
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
ENV_PATTERN = re.compile(r"//\s+Environment Variables:(.*)")
@@ -37,9 +41,22 @@ SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE)
NO_HARNESS_PATTERN = re.compile(r"^// NO HARNESS$", flags=re.MULTILINE)
+# Flags known to misbehave when combining arbitrary mjsunit tests. Can also
+# be compiled regular expressions.
+COMBINE_TESTS_FLAGS_BLACKLIST = [
+ '--check-handle-count',
+ '--enable-tracing',
+ re.compile('--experimental.*'),
+ '--expose-trigger-failure',
+ re.compile('--harmony.*'),
+ '--mock-arraybuffer-allocator',
+ '--print-ast',
+ re.compile('--trace.*'),
+ '--wasm-lazy-compilation',
+]
class TestSuite(testsuite.TestSuite):
- def ListTests(self, context):
+ def ListTests(self):
tests = []
for dirname, dirs, files in os.walk(self.root, followlinks=True):
for dotted in [x for x in dirs if x.startswith('.')]:
@@ -47,7 +64,9 @@ class TestSuite(testsuite.TestSuite):
dirs.sort()
files.sort()
for filename in files:
- if filename.endswith(".js") and filename != "mjsunit.js":
+ if (filename.endswith(".js") and
+ filename != "mjsunit.js" and
+ filename != "mjsunit_suppressions.js"):
fullpath = os.path.join(dirname, filename)
relpath = fullpath[len(self.root) + 1 : -3]
testname = relpath.replace(os.path.sep, "/")
@@ -55,9 +74,15 @@ class TestSuite(testsuite.TestSuite):
tests.append(test)
return tests
+ def _test_combiner_class(self):
+ return TestCombiner
+
def _test_class(self):
return TestCase
+ def _suppressed_test_class(self):
+ return SuppressedTestCase
+
class TestCase(testcase.TestCase):
def __init__(self, *args, **kwargs):
@@ -111,12 +136,12 @@ class TestCase(testcase.TestCase):
def _get_source_flags(self):
return self._source_flags
- def _get_files_params(self, ctx):
+ def _get_files_params(self):
files = list(self._source_files)
- if not ctx.no_harness:
+ if not self._test_config.no_harness:
files += self._mjsunit_files
files += self._files_suffix
- if ctx.isolates:
+ if self._test_config.isolates:
files += ['--isolate'] + files
return files
@@ -128,5 +153,157 @@ class TestCase(testcase.TestCase):
return os.path.join(self.suite.root, self.path + self._get_suffix())
-def GetSuite(name, root):
- return TestSuite(name, root)
+class TestCombiner(testsuite.TestCombiner):
+ def get_group_key(self, test):
+ """Combine tests with the same set of flags.
+ Ignore:
+ 1. Some special cases where it's not obvious what to pass in the command.
+ 2. Tests with flags that can cause failure even inside try-catch wrapper.
+ 3. Tests that use async functions. Async functions can be scheduled after
+ exiting from try-catch wrapper and cause failure.
+ """
+ if (len(test._files_suffix) > 1 or
+ test._env or
+ not test._mjsunit_files or
+ test._source_files):
+ return None
+
+ source_flags = test._get_source_flags()
+ if ('--expose-trigger-failure' in source_flags or
+ '--throws' in source_flags):
+ return None
+
+ source_code = test.get_source()
+ # Maybe we could just update the tests to await all async functions they
+ # call?
+ if 'async' in source_code:
+ return None
+
+ # TODO(machenbach): Remove grouping if combining tests in a flag-independent
+ # way works well.
+ return 1
+
+ def _combined_test_class(self):
+ return CombinedTest
+
+
+class CombinedTest(testcase.TestCase):
+ """Behaves like normal mjsunit tests except:
+ 1. Expected outcome is always PASS
+ 2. Instead of one file there is a try-catch wrapper with all combined tests
+ passed as arguments.
+ """
+ def __init__(self, name, tests):
+ super(CombinedTest, self).__init__(tests[0].suite, '', name,
+ tests[0]._test_config)
+ self._tests = tests
+
+ def _prepare_outcomes(self, force_update=True):
+ self._statusfile_outcomes = outproc.OUTCOMES_PASS_OR_TIMEOUT
+ self.expected_outcomes = outproc.OUTCOMES_PASS_OR_TIMEOUT
+
+ def _get_shell_with_flags(self):
+ """In addition to standard set of shell flags it appends:
+ --disable-abortjs: %AbortJS can abort the test even inside
+ trycatch-wrapper, so we disable it.
+ --es-staging: We blacklist all harmony flags due to false positives,
+ but always pass the staging flag to cover the mature features.
+ --omit-quit: Calling quit() in JS would otherwise early terminate.
+ --quiet-load: suppress any stdout from load() function used by
+ trycatch-wrapper.
+ """
+ shell = 'd8'
+ shell_flags = [
+ '--test',
+ '--disable-abortjs',
+ '--es-staging',
+ '--omit-quit',
+ '--quiet-load',
+ ]
+ return shell, shell_flags
+
+ def _get_cmd_params(self):
+ return (
+ super(CombinedTest, self)._get_cmd_params() +
+ ['tools/testrunner/trycatch_loader.js', '--'] +
+ self._tests[0]._mjsunit_files +
+ ['--'] +
+ [t._files_suffix[0] for t in self._tests]
+ )
+
+ def _merge_flags(self, flags):
+ """Merges flags from a list of flags.
+
+ Flag values not starting with '-' are merged with the preceeding flag,
+ e.g. --foo 1 will become --foo=1. All other flags remain the same.
+
+ Returns: A generator of flags.
+ """
+ if not flags:
+ return
+ # Iterate over flag pairs. ['-'] is a sentinel value for the last iteration.
+ for flag1, flag2 in itertools.izip(flags, flags[1:] + ['-']):
+ if not flag2.startswith('-'):
+ assert '=' not in flag1
+ yield flag1 + '=' + flag2
+ elif flag1.startswith('-'):
+ yield flag1
+
+ def _is_flag_blacklisted(self, flag):
+ for item in COMBINE_TESTS_FLAGS_BLACKLIST:
+ if isinstance(item, basestring):
+ if item == flag:
+ return True
+ elif item.match(flag):
+ return True
+ return False
+
+ def _get_combined_flags(self, flags_gen):
+ """Combines all flags - dedupes, keeps order and filters some flags.
+
+ Args:
+ flags_gen: Generator for flag lists.
+ Returns: A list of flags.
+ """
+ merged_flags = self._merge_flags(list(itertools.chain(*flags_gen)))
+ unique_flags = OrderedDict((flag, True) for flag in merged_flags).keys()
+ return [
+ flag for flag in unique_flags
+ if not self._is_flag_blacklisted(flag)
+ ]
+
+ def _get_source_flags(self):
+ # Combine flags from all source files.
+ return self._get_combined_flags(
+ test._get_source_flags() for test in self._tests)
+
+ def _get_statusfile_flags(self):
+ # Combine flags from all status file entries.
+ return self._get_combined_flags(
+ test._get_statusfile_flags() for test in self._tests)
+
+
+class SuppressedTestCase(TestCase):
+ """The same as a standard mjsunit test case with all asserts as no-ops."""
+ def __init__(self, *args, **kwargs):
+ super(SuppressedTestCase, self).__init__(*args, **kwargs)
+ self._mjsunit_files.append(
+ os.path.join(self.suite.root, "mjsunit_suppressions.js"))
+
+ def _prepare_outcomes(self, *args, **kwargs):
+ super(SuppressedTestCase, self)._prepare_outcomes(*args, **kwargs)
+ # Skip tests expected to fail. We suppress all asserts anyways, but some
+ # tests are expected to fail with type errors or even dchecks, and we
+ # can't differentiate that.
+ if statusfile.FAIL in self._statusfile_outcomes:
+ self._statusfile_outcomes = [statusfile.SKIP]
+
+ def _get_extra_flags(self, *args, **kwargs):
+ return (
+ super(SuppressedTestCase, self)._get_extra_flags(*args, **kwargs) +
+ ['--disable-abortjs']
+ )
+
+
+def GetSuite(*args, **kwargs):
+ return TestSuite(*args, **kwargs)