From 7aa41c6e6f35d1646cbf054fa0e7aab4a6ce8d45 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Wed, 27 Mar 2019 10:32:10 -0400 Subject: [PATCH] deps: V8: un-cherry-pick bd019bd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [testrunner] delete ancient junit compatible format support Testrunner has ancient support for JUnit compatible XML output. This CL removes this old feature. R=mstarzinger@chromium.org,jgruber@chromium.org,jkummerow@chromium.org CC=​machenbach@chromium.org Bug: v8:8728 Change-Id: I7e1beb011dbaec3aa1a27398a5c52abdd778eaf0 Reviewed-on: https://chromium-review.googlesource.com/c/1430065 Reviewed-by: Jakob Gruber Reviewed-by: Michael Starzinger Commit-Queue: Tamer Tas Cr-Commit-Position: refs/heads/master@{#59045} Refs: https://github.com/v8/v8/commit/bd019bdb725cebaa34327634d73936cd7003d17c Backport-PR-URL: https://github.com/nodejs/node/pull/33376 PR-URL: https://github.com/nodejs/node/pull/32831 Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Jiawen Geng Reviewed-By: Colin Ihrig --- common.gypi | 2 +- deps/v8/tools/testrunner/base_runner.py | 6 +++ .../v8/tools/testrunner/local/junit_output.py | 49 +++++++++++++++++++ deps/v8/tools/testrunner/testproc/progress.py | 40 +++++++++++++++ 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 deps/v8/tools/testrunner/local/junit_output.py diff --git a/common.gypi b/common.gypi index 3acc71630d4fe6..1f0ece40398aeb 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.1', + 'v8_embedder_string': '-node.2', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/tools/testrunner/base_runner.py b/deps/v8/tools/testrunner/base_runner.py index 43cb639c83bbbb..c4036bb918e3a3 100644 --- a/deps/v8/tools/testrunner/base_runner.py +++ b/deps/v8/tools/testrunner/base_runner.py @@ -346,6 +346,9 @@ def _add_parser_default_options(self, parser): help="Path to a file for storing json results.") parser.add_option('--slow-tests-cutoff', type="int", default=100, help='Collect N slowest tests') + parser.add_option("--junitout", help="File name of the JUnit output") + parser.add_option("--junittestsuite", default="v8tests", + help="The testsuite name in the JUnit output file") parser.add_option("--exit-after-n-failures", type="int", default=100, help="Exit after the first N failures instead of " "running all tests. Pass 0 to disable this feature.") @@ -797,6 +800,9 @@ def _get_shard_info(self, options): def _create_progress_indicators(self, test_count, options): procs = [PROGRESS_INDICATORS[options.progress]()] + if options.junitout: + procs.append(progress.JUnitTestProgressIndicator(options.junitout, + options.junittestsuite)) if options.json_test_results: procs.append(progress.JsonTestProgressIndicator( self.framework_name, diff --git a/deps/v8/tools/testrunner/local/junit_output.py b/deps/v8/tools/testrunner/local/junit_output.py new file mode 100644 index 00000000000000..52f31ec422a69b --- /dev/null +++ b/deps/v8/tools/testrunner/local/junit_output.py @@ -0,0 +1,49 @@ +# Copyright 2013 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +import xml.etree.ElementTree as xml + + +class JUnitTestOutput: + def __init__(self, test_suite_name): + self.root = xml.Element("testsuite") + self.root.attrib["name"] = test_suite_name + + def HasRunTest(self, test_name, test_cmd, test_duration, test_failure): + testCaseElement = xml.Element("testcase") + testCaseElement.attrib["name"] = test_name + testCaseElement.attrib["cmd"] = test_cmd + testCaseElement.attrib["time"] = str(round(test_duration, 3)) + if len(test_failure): + failureElement = xml.Element("failure") + failureElement.text = test_failure + testCaseElement.append(failureElement) + self.root.append(testCaseElement) + + def FinishAndWrite(self, f): + xml.ElementTree(self.root).write(f, "UTF-8") diff --git a/deps/v8/tools/testrunner/testproc/progress.py b/deps/v8/tools/testrunner/testproc/progress.py index 3357eef76c0758..e9aff1770575fb 100644 --- a/deps/v8/tools/testrunner/testproc/progress.py +++ b/deps/v8/tools/testrunner/testproc/progress.py @@ -14,6 +14,7 @@ import time from . import base +from ..local import junit_output # Base dir of the build products for Release and Debug. @@ -316,6 +317,45 @@ def _clear_line(self, last_length): print(("\r" + (" " * last_length) + "\r"), end='') +class JUnitTestProgressIndicator(ProgressIndicator): + def __init__(self, junitout, junittestsuite): + super(JUnitTestProgressIndicator, self).__init__() + self._requirement = base.DROP_PASS_STDOUT + + self.outputter = junit_output.JUnitTestOutput(junittestsuite) + if junitout: + self.outfile = open(junitout, "w") + else: + self.outfile = sys.stdout + + def _on_result_for(self, test, result): + # TODO(majeski): Support for dummy/grouped results + fail_text = "" + output = result.output + if result.has_unexpected_output: + stdout = output.stdout.strip() + if len(stdout): + fail_text += "stdout:\n%s\n" % stdout + stderr = output.stderr.strip() + if len(stderr): + fail_text += "stderr:\n%s\n" % stderr + fail_text += "Command: %s" % result.cmd.to_string() + if output.HasCrashed(): + fail_text += "exit code: %d\n--- CRASHED ---" % output.exit_code + if output.HasTimedOut(): + fail_text += "--- TIMEOUT ---" + self.outputter.HasRunTest( + test_name=str(test), + test_cmd=result.cmd.to_string(relative=True), + test_duration=output.duration, + test_failure=fail_text) + + def finished(self): + self.outputter.FinishAndWrite(self.outfile) + if self.outfile != sys.stdout: + self.outfile.close() + + class JsonTestProgressIndicator(ProgressIndicator): def __init__(self, framework_name, arch, mode): super(JsonTestProgressIndicator, self).__init__()