Title: [253371] trunk/Tools
Revision
253371
Author
jbed...@apple.com
Date
2019-12-11 07:13:16 -0800 (Wed, 11 Dec 2019)

Log Message

Add test-lldb-webkit
https://bugs.webkit.org/show_bug.cgi?id=187916

Reviewed by Stephanie Lewis.

* Scripts/test-lldb-webkit: Added.
(NoAction): Argparse action which support --<variable> and --no-<variable>.
(LldbTester): Wrapper around webkitpy's Tester class.
(LldbTester.parse_args): Specialized argparse for lldb tests.
(LldbTester.run): Setup environment and build lldb test runner.
(main):
* Scripts/webkitpy/test/main.py:
(main): Remove lldb testing code.
(Tester._parse_args): Ditto.
(Tester.run): Ditto.
(Tester._run_tests): Ditto.
(Tester._test_names): Ditto.
(_supports_building_and_running_lldb_tests): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (253370 => 253371)


--- trunk/Tools/ChangeLog	2019-12-11 14:37:25 UTC (rev 253370)
+++ trunk/Tools/ChangeLog	2019-12-11 15:13:16 UTC (rev 253371)
@@ -1,3 +1,24 @@
+2019-12-11  Jonathan Bedard  <jbed...@apple.com>
+
+        Add test-lldb-webkit
+        https://bugs.webkit.org/show_bug.cgi?id=187916
+
+        Reviewed by Stephanie Lewis.
+
+        * Scripts/test-lldb-webkit: Added.
+        (NoAction): Argparse action which support --<variable> and --no-<variable>.
+        (LldbTester): Wrapper around webkitpy's Tester class.
+        (LldbTester.parse_args): Specialized argparse for lldb tests.
+        (LldbTester.run): Setup environment and build lldb test runner.
+        (main):
+        * Scripts/webkitpy/test/main.py:
+        (main): Remove lldb testing code.
+        (Tester._parse_args): Ditto.
+        (Tester.run): Ditto.
+        (Tester._run_tests): Ditto.
+        (Tester._test_names): Ditto.
+        (_supports_building_and_running_lldb_tests): Deleted.
+
 2019-12-10  Per Arne Vollan  <pvol...@apple.com>
 
         Fix API test failure after r253351

Added: trunk/Tools/Scripts/test-lldb-webkit (0 => 253371)


--- trunk/Tools/Scripts/test-lldb-webkit	                        (rev 0)
+++ trunk/Tools/Scripts/test-lldb-webkit	2019-12-11 15:13:16 UTC (rev 253371)
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+# Copyright (c) 2019 Apple Inc. 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 argparse
+import os
+import sys
+import time
+
+from webkitpy.common.host import Host
+from webkitpy.common.system.executive import ScriptError
+from webkitpy.port.config import Config
+from webkitpy.test.main import Tester
+
+EXCEPTIONAL_EXIT_STATUS = -1
+
+
+class NoAction(argparse.Action):
+    def __init__(self, option_strings, dest, **kwargs):
+        super(NoAction, self).__init__(option_strings, dest, nargs=0, **kwargs)
+
+    def __call__(self, parser, namespace, values, option_string):
+        setattr(namespace, self.dest, False if option_string.startswith('--no') else True)
+
+
+class LldbTester(Tester):
+
+    def parse_args(self):
+        parser = argparse.ArgumentParser(description='A script which tests WebKit\'s lldb macros and integration')
+        parser.add_argument('--build', '--no-build',
+                            dest='build', action=""
+                            default=None, help='Enable or disable calling build-lldbwebkittester before running the test (enabled by default). This will build the lldb test runner, bmalloc and WTF.')
+        parser.add_argument('--root',
+                            dest='root', action='',
+                            default=None, help='Path to a directory containing the binaries needed to run tests.')
+        parser.add_argument('-v', '--verbose', action='',
+                            default=0, help='Verbose output (specify once for individual test results, twice for debug messages)')
+        parser.add_argument('-t', '--timing', action='',
+                            default=False, help='Display per-test execution time (implies --verbose)')
+        parser.add_argument('-q', '--quiet', action='',
+                            default=False, help='Run quietly (errors, warnings, and progress only)')
+        parser.add_argument('-p', '--pass-through', action='', default=False,
+                            help='Be debugger friendly by passing captured output through to the system')
+        parser.add_argument('--debug', const='debug',
+                            dest='configuration', action='',
+                            default=None, help='Alias for configuration=debug.')
+        parser.add_argument('--release', const='release',
+                            dest='configuration', action='',
+                            default=None, help='Alias for configuration=release.')
+        parser.add_argument('--configuration',
+                            dest='configuration', action='',
+                            default=None, help='Set configuration (Debug/Release/ASan/ect.) to build and test the lldb test runner with.')
+        parser.add_argument('names', nargs='*',
+                            default=None, help='Name (or names) of test, or test suite, to be run. lldb_webkit_unittest.TestSummaryProviders and dump_class_layout_unittest.TestDumpClassLayout are two examples')
+        return parser.parse_args()
+
+    def run(self, host=None, webkit_root=None):
+        host = host or Host()
+        self._options = self.parse_args()
+        self.printer.configure(self._options)
+        self.finder.clean_trees()
+
+        names = self.finder.find_names(self._options.names or [], True)
+        if not names:
+            _log.error('No tests to run')
+            return False
+
+        config = Config(host.executive, self.finder.filesystem)
+        configuration_to_use = self._options.configuration or config.default_configuration()
+        self.upload_style = configuration_to_use.lower()
+
+        if (not self._options.root and self._options.build is None) or self._options.build:
+            self.printer.write_update('Building lldbWebKitTester ...')
+            build_lldbwebkittester = self.finder.filesystem.join(webkit_root, 'Tools', 'Scripts', 'build-lldbwebkittester')
+            try:
+                host.executive.run_and_throw_if_fail(
+                    [build_lldbwebkittester, config.flag_for_configuration(configuration_to_use)],
+                    quiet=(not bool(self._options.verbose)),
+                )
+            except ScriptError as e:
+                _log.error(e.message_with_output(output_limit=None))
+                return False
+
+        os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE'] = str(self.finder.filesystem.join(config.build_directory(configuration_to_use), 'lldbWebKitTester'))
+        if not self.finder.filesystem.exists(os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE']):
+            _log.error('Failed to find lldbWebKitTester.')
+            return False
+
+        return self._run_tests(names)
+
+
+def main():
+    tester = LldbTester()
+    host = Host()
+    lldb_python_directory = host.path_to_lldb_python_directory()
+    if not host.filesystem.isdir(lldb_python_directory):
+        tester.parse_args()
+        if not lldb_python_directory:
+            print('lldb tests are only supported on macOS with XCode installed')
+        else:
+            print('Could not find {}, derived from running `xcrun lldb --python-path`'.format(lldb_python_directory))
+        return 1
+
+    up = host.filesystem.dirname
+    webkit_root = up(up(up(host.filesystem.abspath(__file__))))
+
+    if lldb_python_directory not in sys.path:
+        sys.path.append(lldb_python_directory)
+    tester.add_tree(host.filesystem.join(webkit_root, 'Tools', 'lldb'))
+
+    return not tester.run(host=host, webkit_root=webkit_root)
+
+
+if __name__ == '__main__':
+    sys.exit(main())
Property changes on: trunk/Tools/Scripts/test-lldb-webkit
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/Tools/Scripts/webkitpy/test/main.py (253370 => 253371)


--- trunk/Tools/Scripts/webkitpy/test/main.py	2019-12-11 14:37:25 UTC (rev 253370)
+++ trunk/Tools/Scripts/webkitpy/test/main.py	2019-12-11 15:13:16 UTC (rev 253371)
@@ -41,7 +41,6 @@
 from webkitpy.common.system.filesystem import FileSystem
 from webkitpy.common.host import Host
 from webkitpy.common.unicode_compatibility import StringIO
-from webkitpy.port.config import Config
 from webkitpy.test.finder import Finder
 from webkitpy.test.printer import Printer
 from webkitpy.test.runner import Runner, unit_test_name
@@ -68,19 +67,6 @@
     if not (sys.platform.startswith('win') or sys.platform == 'cygwin'):
         tester.add_tree(os.path.join(_webkit_root, 'Source', 'WebKit', 'Scripts'), 'webkit')
 
-    lldb_python_directory = _host.path_to_lldb_python_directory()
-    if not _supports_building_and_running_lldb_tests():
-        _log.info("Skipping lldb_webkit tests; not yet supported on macOS Catalina.")
-        will_run_lldb_webkit_tests = False
-    elif not os.path.isdir(lldb_python_directory):
-        _log.info("Skipping lldb_webkit tests; could not find path to lldb.py '{}'.".format(lldb_python_directory))
-        will_run_lldb_webkit_tests = False
-    else:
-        if lldb_python_directory not in sys.path:
-            sys.path.append(lldb_python_directory)
-        tester.add_tree(os.path.join(_webkit_root, 'Tools', 'lldb'))
-        will_run_lldb_webkit_tests = True
-
     tester.skip(('webkitpy.common.checkout.scm.scm_unittest',), 'are really, really, slow', 31818)
     if sys.platform.startswith('win'):
         tester.skip(('webkitpy.common.checkout', 'webkitpy.common.config', 'webkitpy.tool'), 'fail horribly on win32', 54526)
@@ -98,18 +84,9 @@
     else:
         _log.info('Skipping QueueStatusServer tests; the Google AppEngine Python SDK is not installed.')
 
-    return not tester.run(will_run_lldb_webkit_tests=will_run_lldb_webkit_tests)
+    return not tester.run()
 
 
-def _supports_building_and_running_lldb_tests():
-    # FIXME: Remove when test-lldb is in its own script
-    # https://bugs.webkit.org/show_bug.cgi?id=187916
-    build_version = _host.platform.build_version()
-    if build_version is None:
-        return False
-    return True
-
-
 def _print_results_as_json(stream, all_test_names, failures, errors):
     def result_dict_from_tuple(result_tuple):
         return {'name': result_tuple[0], 'result': result_tuple[1]}
@@ -127,6 +104,7 @@
         self.finder = Finder(filesystem or FileSystem())
         self.printer = Printer(sys.stderr)
         self._options = None
+        self.upload_style = 'release'
 
     def add_tree(self, top_directory, starting_subdirectory=None):
         self.finder.add_tree(top_directory, starting_subdirectory)
@@ -137,14 +115,6 @@
     def _parse_args(self, argv=None):
         parser = optparse.OptionParser(usage='usage: %prog [options] [args...]')
 
-        #  Configuration options only effect the building of lldbWebKitTester.
-        configuration_group = optparse.OptionGroup(parser, 'Configuration options')
-        configuration_group.add_option('--debug', action='', const='Debug', dest="configuration",
-            help='Set the configuration to Debug')
-        configuration_group.add_option('--release', action='', const='Release', dest="configuration",
-            help='Set the configuration to Release')
-        parser.add_option_group(configuration_group)
-
         upload_group = optparse.OptionGroup(parser, 'Upload Options')
         upload_group.add_options(upload_options())
         parser.add_option_group(upload_group)
@@ -176,7 +146,7 @@
 
         return parser.parse_args(argv)
 
-    def run(self, will_run_lldb_webkit_tests=False):
+    def run(self):
         self._options, args = self._parse_args()
         self.printer.configure(self._options)
 
@@ -187,9 +157,9 @@
             _log.error('No tests to run')
             return False
 
-        return self._run_tests(names, will_run_lldb_webkit_tests)
+        return self._run_tests(names)
 
-    def _run_tests(self, names, will_run_lldb_webkit_tests):
+    def _run_tests(self, names):
         # Make sure PYTHONPATH is set up properly.
         sys.path = self.finder.additional_paths(sys.path) + sys.path
 
@@ -200,23 +170,8 @@
         autoinstall_everything()
 
         start_time = time.time()
-        config = Config(_host.executive, self.finder.filesystem)
-        configuration_to_use = self._options.configuration or config.default_configuration()
 
-        if will_run_lldb_webkit_tests:
-            self.printer.write_update('Building lldbWebKitTester ...')
-            build_lldbwebkittester = self.finder.filesystem.join(_webkit_root, 'Tools', 'Scripts', 'build-lldbwebkittester')
-            try:
-                _host.executive.run_and_throw_if_fail([build_lldbwebkittester, config.flag_for_configuration(configuration_to_use)], quiet=(not bool(self._options.verbose)))
-            except ScriptError as e:
-                _log.error(e.message_with_output(output_limit=None))
-                return False
-            os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE'] = str(self.finder.filesystem.join(config.build_directory(configuration_to_use), 'lldbWebKitTester'))
-            if not self.finder.filesystem.exists(os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE']):
-                _log.error('Failed to find lldbWebKitTester.')
-                return False
-
-        if self._options.coverage:
+        if getattr(self._options, 'coverage', False):
             _log.warning("Checking code coverage, so running things serially")
             self._options.child_processes = 1
 
@@ -241,26 +196,26 @@
         self.printer.num_tests = len(parallel_tests) + len(serial_tests)
         start = time.time()
         test_runner = Runner(self.printer, loader)
-        test_runner.run(parallel_tests, self._options.child_processes)
+        test_runner.run(parallel_tests, getattr(self._options, 'child_processes', 1))
         test_runner.run(serial_tests, 1)
         end_time = time.time()
 
         self.printer.print_result(time.time() - start)
 
-        if self._options.json:
+        if getattr(self._options, 'json', False):
             _print_results_as_json(sys.stdout, itertools.chain(parallel_tests, serial_tests), test_runner.failures, test_runner.errors)
 
-        if self._options.json_file_name:
+        if getattr(self._options, 'json_file_name', None):
             self._options.json_file_name = os.path.abspath(self._options.json_file_name)
             with open(self._options.json_file_name, 'w') as json_file:
                 _print_results_as_json(json_file, itertools.chain(parallel_tests, serial_tests), test_runner.failures, test_runner.errors)
 
-        if self._options.coverage:
+        if getattr(self._options, 'coverage', False):
             cov.stop()
             cov.save()
 
         failed_uploads = 0
-        if self._options.report_urls:
+        if getattr(self._options, 'report_urls', None):
             self.printer.meter.writeln('\n')
             self.printer.write_update('Preparing upload data ...')
 
@@ -278,7 +233,7 @@
                     platform=_host.platform.os_name,
                     version=str(_host.platform.os_version),
                     version_name=_host.platform.os_version_name(),
-                    style='asan' if config.asan else configuration_to_use.lower(),
+                    style=self.upload_style,
                     sdk=_host.platform.build_version(),
                     flavor=self._options.result_report_flavor,
                 ),
@@ -300,7 +255,7 @@
                 failed_uploads = failed_uploads if upload.upload(url, log_line_func=self.printer.meter.writeln) else (failed_uploads + 1)
             self.printer.meter.writeln('Uploads completed!')
 
-        if self._options.coverage:
+        if getattr(self._options, 'coverage', False):
             cov.report(show_missing=False)
 
         return not self.printer.num_errors and not self.printer.num_failures and not failed_uploads
@@ -322,7 +277,7 @@
     def _test_names(self, loader, names):
         parallel_test_method_prefixes = ['test_']
         serial_test_method_prefixes = ['serial_test_']
-        if self._options.integration_tests:
+        if getattr(self._options, 'integration_tests', None):
             parallel_test_method_prefixes.append('integration_test_')
             serial_test_method_prefixes.append('serial_integration_test_')
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to