Changeset 263625 in webkit


Ignore:
Timestamp:
Jun 27, 2020 10:00:49 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Migrate run-minibrowser to webkitpy
https://bugs.webkit.org/show_bug.cgi?id=213431

Patch by Philippe Normand <pnormand@igalia.com> on 2020-06-27
Reviewed by Jonathan Bedard.

The perl version was renamed to old-run-minibrowser and remains used by the Mac ports.
run-minibrowser is now a Python script hooking into webkitpy and the Port infrastructure.
Both WPE and GTK ports will now use the pure python implementation.

  • Scripts/old-run-minibrowser: Copied from Tools/Scripts/run-minibrowser.
  • Scripts/run-minibrowser:
  • Scripts/webkitpy/minibrowser/run_minibrowser.py: Added.

(main):
(parse_args):

  • Scripts/webkitpy/port/base.py:

(Port.run_minibrowser_arguments):
(Port):
(Port.run_minibrowser):

  • Scripts/webkitpy/port/darwin.py:

(DarwinPort.environment_for_api_tests):
(DarwinPort):
(DarwinPort.run_minibrowser_arguments):

  • Scripts/webkitpy/port/gtk.py:

(GtkPort.show_results_html_file):
(GtkPort.configuration_for_upload):
(GtkPort):
(GtkPort.run_minibrowser):

  • Scripts/webkitpy/port/wpe.py:

(WPEPort.show_results_html_file):
(WPEPort.configuration_for_upload):
(WPEPort):
(WPEPort.run_minibrowser):

Location:
trunk/Tools
Files:
3 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r263616 r263625  
     12020-06-27  Philippe Normand  <pnormand@igalia.com>
     2
     3        Migrate run-minibrowser to webkitpy
     4        https://bugs.webkit.org/show_bug.cgi?id=213431
     5
     6        Reviewed by Jonathan Bedard.
     7
     8        The perl version was renamed to old-run-minibrowser and remains used by the Mac ports.
     9        run-minibrowser is now a Python script hooking into webkitpy and the Port infrastructure.
     10        Both WPE and GTK ports will now use the pure python implementation.
     11
     12        * Scripts/old-run-minibrowser: Copied from Tools/Scripts/run-minibrowser.
     13        * Scripts/run-minibrowser:
     14        * Scripts/webkitpy/minibrowser/run_minibrowser.py: Added.
     15        (main):
     16        (parse_args):
     17        * Scripts/webkitpy/port/base.py:
     18        (Port.run_minibrowser_arguments):
     19        (Port):
     20        (Port.run_minibrowser):
     21        * Scripts/webkitpy/port/darwin.py:
     22        (DarwinPort.environment_for_api_tests):
     23        (DarwinPort):
     24        (DarwinPort.run_minibrowser_arguments):
     25        * Scripts/webkitpy/port/gtk.py:
     26        (GtkPort.show_results_html_file):
     27        (GtkPort.configuration_for_upload):
     28        (GtkPort):
     29        (GtkPort.run_minibrowser):
     30        * Scripts/webkitpy/port/wpe.py:
     31        (WPEPort.show_results_html_file):
     32        (WPEPort.configuration_for_upload):
     33        (WPEPort):
     34        (WPEPort.run_minibrowser):
     35
    1362020-06-27  Stephan Szabo  <stephan.szabo@sony.com>
    237
  • trunk/Tools/Scripts/old-run-minibrowser

    r263624 r263625  
    3333use strict;
    3434use warnings;
    35 use File::Spec::Functions qw/catdir/;
    3635use FindBin;
    3736use lib $FindBin::Bin;
    3837use webkitdirs;
    3938
    40 my $launcherName;
    41 my $launcherPath;
    42 my @jhbuildWrapper;
    43 
    4439prohibitUnknownPort();
    4540setConfiguration();
    4641
    47 if (isGtk() || isWPE()) {
    48     my @command = (File::Spec->catfile(sourceDir(), "Tools", "Scripts", "run-minibrowser"));
    49     runInFlatpakIfAvailable(@command);
    50 
    51     # Check to see that all the frameworks are built.
    52     checkFrameworks();
    53 
    54     $launcherPath = catdir(productDir(), "bin", "MiniBrowser");
    55     die "Can't find $launcherPath" unless -x $launcherPath;
    56     @jhbuildWrapper = wrapperPrefixIfNeeded();
    57     print "Starting MiniBrowser.\n";
    58     exec @jhbuildWrapper, $launcherPath, @ARGV or die;
    59 } elsif (isAppleCocoaWebKit()) {
     42if (isAppleCocoaWebKit()) {
    6043    printHelpAndExitForRunAndDebugWebKitAppIfNeeded();
    6144    exit exitStatus(runMiniBrowser());
  • trunk/Tools/Scripts/run-minibrowser

    r258626 r263625  
    1 #!/usr/bin/env perl
     1#!/usr/bin/env python
     2# Copyright (C) 2020 Igalia S.L.
     3#
     4# This program is free software; you can redistribute it and/or
     5# modify it under the terms of the GNU Lesser General Public
     6# License as published by the Free Software Foundation; either
     7# version 2.1 of the License, or (at your option) any later version.
     8#
     9# This program is distributed in the hope that it will be useful,
     10# but WITHOUT ANY WARRANTY; without even the implied warranty of
     11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12# Lesser General Public License for more details.
     13#
     14# You should have received a copy of the GNU Lesser General Public
     15# License along with this program; if not, write to the
     16# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
     17# Boston, MA 02110-1301, USA.
    218
    3 # Copyright (C) 2005, 2007, 2013 Apple Inc. All rights reserved.
    4 # Copyright (C) 2007 Staikos Computing Services, Inc.  <info@staikos.net>
     19"""Wrapper around webkitpy/minibrowser/run_webkit_app.py"""
     20import os
     21import sys
     22from webkitpy.minibrowser import run_webkit_app
    523
    6 #
    7 # Redistribution and use in source and binary forms, with or without
    8 # modification, are permitted provided that the following conditions
    9 # are met:
    10 #
    11 # 1.  Redistributions of source code must retain the above copyright
    12 #     notice, this list of conditions and the following disclaimer.
    13 # 2.  Redistributions in binary form must reproduce the above copyright
    14 #     notice, this list of conditions and the following disclaimer in the
    15 #     documentation and/or other materials provided with the distribution.
    16 # 3.  Neither the name of Apple Inc. ("Apple") nor the names of
    17 #     its contributors may be used to endorse or promote products derived
    18 #     from this software without specific prior written permission.
    19 #
    20 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
    21 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    22 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    23 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
    24 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    25 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    26 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    27 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    29 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24top_level_directory = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
     25if sys.platform.startswith('linux'):
     26    sys.path.insert(0, os.path.join(top_level_directory, 'Tools', 'flatpak'))
     27    import flatpakutils
     28    flatpakutils.run_in_sandbox_if_available(sys.argv)
    3029
    31 # Simplified "run" script for launching the WebKit2 MiniBrowser.
    32 
    33 use strict;
    34 use warnings;
    35 use File::Spec::Functions qw/catdir/;
    36 use FindBin;
    37 use lib $FindBin::Bin;
    38 use webkitdirs;
    39 
    40 my $launcherName;
    41 my $launcherPath;
    42 my @jhbuildWrapper;
    43 
    44 prohibitUnknownPort();
    45 setConfiguration();
    46 
    47 if (isGtk() || isWPE()) {
    48     my @command = (File::Spec->catfile(sourceDir(), "Tools", "Scripts", "run-minibrowser"));
    49     runInFlatpakIfAvailable(@command);
    50 
    51     # Check to see that all the frameworks are built.
    52     checkFrameworks();
    53 
    54     $launcherPath = catdir(productDir(), "bin", "MiniBrowser");
    55     die "Can't find $launcherPath" unless -x $launcherPath;
    56     @jhbuildWrapper = wrapperPrefixIfNeeded();
    57     print "Starting MiniBrowser.\n";
    58     exec @jhbuildWrapper, $launcherPath, @ARGV or die;
    59 } elsif (isAppleCocoaWebKit()) {
    60     printHelpAndExitForRunAndDebugWebKitAppIfNeeded();
    61     exit exitStatus(runMiniBrowser());
    62 } else {
    63     die "Unsupported platform."
    64 }
     30run_webkit_app.main(sys.argv[1:])
  • trunk/Tools/Scripts/webkitpy/port/base.py

    r263610 r263625  
    3131test infrastructure (the Port and Driver classes)."""
    3232
     33import argparse
    3334import difflib
    3435import json
     
    790791
    791792    def set_option_default(self, name, default_value):
    792         return self._options.ensure_value(name, default_value)
     793        if isinstance(self._options, argparse.Namespace):
     794            if not hasattr(self._options, name):
     795                setattr(self._options, name, default_value)
     796                return True
     797        else:
     798            return self._options.ensure_value(name, default_value)
    793799
    794800    @memoized
     
    13621368        return self._build_path('ImageDiff')
    13631369
     1370    def run_minibrowser(self, args):
     1371        # FIXME: Migrate to webkitpy based run-minibrowser. https://bugs.webkit.org/show_bug.cgi?id=213464
     1372        return self._run_script(["old-run-minibrowser", ] + args)
     1373
    13641374    @memoized
    13651375    def _path_to_image_diff(self):
  • trunk/Tools/Scripts/webkitpy/port/gtk.py

    r261383 r263625  
    232232
    233233    def show_results_html_file(self, results_filename):
    234         self._run_script("run-minibrowser", [path.abspath_to_uri(self.host.platform, results_filename)])
     234        self.run_minibrowser([path.abspath_to_uri(self.host.platform, results_filename)])
    235235
    236236    def check_sys_deps(self):
     
    261261        configuration['version_name'] = self._display_server.capitalize() if self._display_server else 'Xvfb'
    262262        return configuration
     263
     264    def run_minibrowser(self, args):
     265        miniBrowser = self._build_path('bin', 'MiniBrowser')
     266        if not self._filesystem.isfile(miniBrowser):
     267            print("%s not found... Did you run build-webkit?" % miniBrowser)
     268            return 1
     269        command = [miniBrowser]
     270        if self._should_use_jhbuild():
     271            command = self._jhbuild_wrapper + command
     272        return self._executive.run_command(command + args, cwd=self.webkit_base())
  • trunk/Tools/Scripts/webkitpy/port/gtk_unittest.py

    r261383 r263625  
    7070        port = self.make_port()
    7171        port._executive = MockExecutive(should_log=True)
    72         expected_logs = "MOCK run_command: ['Tools/Scripts/run-minibrowser', '--release', '--gtk', 'file://test.html'], cwd=/mock-checkout\n"
     72        port._filesystem = MockFileSystem({
     73            "/mock-build/bin/MiniBrowser": ""
     74        })
     75        expected_logs = "MOCK run_command: ['/mock-build/bin/MiniBrowser', 'file://test.html'], cwd=/mock-checkout\n"
    7376        OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_logs=expected_logs)
    7477
  • trunk/Tools/Scripts/webkitpy/port/wpe.py

    r263261 r263625  
    9494
    9595    def show_results_html_file(self, results_filename):
    96         self._run_script("run-minibrowser", [path.abspath_to_uri(self.host.platform, results_filename)])
     96        self.run_minibrowser([path.abspath_to_uri(self.host.platform, results_filename)])
    9797
    9898    def check_sys_deps(self):
     
    135135        configuration['platform'] = 'WPE'
    136136        return configuration
     137
     138    def run_minibrowser(self, args):
     139        miniBrowser = self._build_path('bin', 'MiniBrowser')
     140        if not self._filesystem.isfile(miniBrowser):
     141            print("%s not found... Did you run build-webkit?" % miniBrowser)
     142            return 1
     143        command = [miniBrowser]
     144        if self._should_use_jhbuild():
     145            command = self._jhbuild_wrapper + command
     146        return self._executive.run_command(command + args, cwd=self.webkit_base())
Note: See TracChangeset for help on using the changeset viewer.