Changeset 247808 in webkit


Ignore:
Timestamp:
Jul 24, 2019 7:00:37 PM (5 years ago)
Author:
Fujii Hironori
Message:

[webkitperl] runCommand doesn't work in Windows Perl
https://bugs.webkit.org/show_bug.cgi?id=199900

Reviewed by Don Olmstead.

runCommand was always failing implicit fork by using 'open' with
'-|' in Windows Perl. Explicitly specify the command to 'open' not
to do the implicit fork.

There is one more difference between Windows and Unix. 'open'
successes on Windows even for non existent command while it fails
on Unix. So, return the same error code on Unix as well as
Windows.

  • Scripts/VCSUtils.pm: Specified the command to 'open'.
  • Scripts/webkitperl/VCSUtils_unittest/runCommand.pl: 'echo'

command is not available on Windows. Use Perl ($X) instead.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r247804 r247808  
     12019-07-24  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [webkitperl] runCommand doesn't work in Windows Perl
     4        https://bugs.webkit.org/show_bug.cgi?id=199900
     5
     6        Reviewed by Don Olmstead.
     7
     8        runCommand was always failing implicit fork by using 'open' with
     9        '-|' in Windows Perl. Explicitly specify the command to 'open' not
     10        to do the implicit fork.
     11
     12        There is one more difference between Windows and Unix. 'open'
     13        successes on Windows even for non existent command while it fails
     14        on Unix. So, return the same error code on Unix as well as
     15        Windows.
     16
     17        * Scripts/VCSUtils.pm: Specified the command to 'open'.
     18        * Scripts/webkitperl/VCSUtils_unittest/runCommand.pl: 'echo'
     19        command is not available on Windows. Use Perl ($^X) instead.
     20
    1212019-07-24  Priyanka Agarwal  <pagarwal999@apple.com>
    222
  • trunk/Tools/Scripts/VCSUtils.pm

    r235733 r247808  
    23992399sub runCommand(@)
    24002400{
    2401     my @args = @_;
    2402     my $pid = open(CHILD, "-|");
    2403     if (!defined($pid)) {
    2404         die "Failed to fork(): $!";
    2405     }
    2406     if ($pid) {
    2407         # Parent process
    2408         my $childStdout;
    2409         while (<CHILD>) {
    2410             $childStdout .= $_;
    2411         }
    2412         close(CHILD);
    2413         my %childOutput;
    2414         $childOutput{exitStatus} = exitStatus($?);
    2415         $childOutput{stdout} = $childStdout if $childStdout;
    2416         return \%childOutput;
    2417     }
    2418     # Child process
    24192401    # FIXME: Consider further hardening of this function, including sanitizing the environment.
    2420     exec { $args[0] } @args or die "Failed to exec(): $!";
     2402    my $ok = open(CHILD, "-|", @_);
     2403    if (!$ok) {
     2404        return { exitStatus => 1 };
     2405    }
     2406    my $childStdout;
     2407    while (<CHILD>) {
     2408        $childStdout .= $_;
     2409    }
     2410    close(CHILD);
     2411    my %childOutput;
     2412    $childOutput{exitStatus} = exitStatus($?);
     2413    $childOutput{stdout} = $childStdout if $childStdout;
     2414    return \%childOutput;
    24212415}
    24222416
  • trunk/Tools/Scripts/webkitperl/VCSUtils_unittest/runCommand.pl

    r226395 r247808  
    3131use VCSUtils;
    3232
    33 use constant ENOENT => 2; # See <errno.h>
    34 
    3533# The array of test cases.
    3634my @testCaseHashRefs = (
     
    3836    # New test
    3937    testName => "Simple",
    40     inputArgs => ["echo", "hello"],
     38    inputArgs => [$^X, "-e", "print \@ARGV", "hello"],
    4139    expectedReturn => {
    4240        exitStatus => 0,
    43         stdout => "hello\n"
     41        stdout => "hello"
    4442    }
    4543},
     
    4745    # New test
    4846    testName => "Multiple commands",
    49     inputArgs => ["echo", "first-command;echo second-command"],
     47    inputArgs => [$^X, "-e", "print \@ARGV", "first-command;echo second-command"],
    5048    expectedReturn => {
    5149        exitStatus => 0,
    52         stdout => "first-command;echo second-command\n"
     50        stdout => "first-command;echo second-command"
    5351    }
    5452},
     
    5856    inputArgs => ["/usr/bin/non-existent-command"],
    5957    expectedReturn => {
    60         exitStatus => ENOENT
     58        exitStatus => 1
    6159    }
    6260}
Note: See TracChangeset for help on using the changeset viewer.