Bug 199900 - [webkitperl] runCommand doesn't work in Windows Perl
Summary: [webkitperl] runCommand doesn't work in Windows Perl
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-07-18 02:10 PDT by Fujii Hironori
Modified: 2019-07-24 19:03 PDT (History)
10 users (show)

See Also:


Attachments
Patch (3.83 KB, patch)
2019-07-18 03:05 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (3.83 KB, patch)
2019-07-18 04:09 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews116 for mac-highsierra (3.10 MB, application/zip)
2019-07-18 05:58 PDT, Build Bot
no flags Details
Patch (3.86 KB, patch)
2019-07-22 00:22 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (3.86 KB, patch)
2019-07-23 18:45 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2019-07-18 02:10:59 PDT
runCommand doesn't work in Windows Perl

https://build.webkit.org/builders/WinCairo%2064-bit%20WKL%20Release%20%28Tests%29/builds/4540

> Tools/Scripts/webkitperl/VCSUtils_unittest/removeEOL.pl ............................................ ok
> '-' is not recognized as an internal or external command,
> operable program or batch file.
> 
> #   Failed test 'runCommand(): Simple: comparing return value.'
> #   at Tools/Scripts/webkitperl/VCSUtils_unittest/runCommand.pl line 74.
> #     Structures begin differing at:
> #          $got->{stdout} = Does not exist
> #     $expected->{stdout} = 'hello
> #     '
> '-' is not recognized as an internal or external command,
> operable program or batch file.
> 
> #   Failed test 'runCommand(): Multiple commands: comparing return value.'
> #   at Tools/Scripts/webkitperl/VCSUtils_unittest/runCommand.pl line 74.
> #     Structures begin differing at:
> #          $got->{stdout} = Does not exist
> #     $expected->{stdout} = 'first-command;echo second-command
> #     '
> '-' is not recognized as an internal or external command,
> operable program or batch file.
> 
> #   Failed test 'runCommand(): Non-existent command: comparing return value.'
> #   at Tools/Scripts/webkitperl/VCSUtils_unittest/runCommand.pl line 74.
> #     Structures begin differing at:
> #          $got->{exitStatus} = '1'
> #     $expected->{exitStatus} = '2'
> # Looks like you failed 3 tests of 3.
> Tools/Scripts/webkitperl/VCSUtils_unittest/runCommand.pl ...........................................
Comment 1 Fujii Hironori 2019-07-18 03:05:14 PDT
Created attachment 374369 [details]
Patch
Comment 2 Daniel Bates 2019-07-18 03:37:23 PDT
Comment on attachment 374369 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=374369&action=review

> Tools/Scripts/VCSUtils.pm:-2419
> -    # FIXME: Consider further hardening of this function, including sanitizing the environment.

Isn't this FIXME still relevant?
Comment 3 Fujii Hironori 2019-07-18 04:04:07 PDT
Comment on attachment 374369 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=374369&action=review

>> Tools/Scripts/VCSUtils.pm:-2419
>> -    # FIXME: Consider further hardening of this function, including sanitizing the environment.
> 
> Isn't this FIXME still relevant?

Hmm, I don't know. OK, I will keep it.
Comment 4 Fujii Hironori 2019-07-18 04:09:51 PDT
Created attachment 374374 [details]
Patch
Comment 5 Build Bot 2019-07-18 05:58:21 PDT
Comment on attachment 374374 [details]
Patch

Attachment 374374 [details] did not pass mac-debug-ews (mac):
Output: https://webkit-queues.webkit.org/results/12765515

New failing tests:
storage/indexeddb/dont-wedge.html
Comment 6 Build Bot 2019-07-18 05:58:23 PDT
Created attachment 374379 [details]
Archive of layout-test-results from ews116 for mac-highsierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-highsierra  Platform: Mac OS X 10.13.6
Comment 7 Fujii Hironori 2019-07-22 00:22:07 PDT
Created attachment 374589 [details]
Patch
Comment 8 Fujii Hironori 2019-07-22 23:13:03 PDT
https://perldoc.perl.org/functions/open.html

In Windows, 'echo' is a internal command of 'cmd.exe'. So, there is no 'echo.exe'.
As the result, 'open' fails as 'No such file or directory' in "list form" of 'open'.
There are two ways to use 'echo' in Win32 Perl.
One is using three-argument form to execute the string in shell.
Another is explicitly using 'cmd' in "list form".

test.pl:

> use Data::Dumper;
> 
> my $ret = open(my $fh, "-|", "echo", "a", "b");
> my @out = <$fh>;
> print Dumper($ret, \@out, $!);
> 
> my $ret = open(my $fh, "-|", "echo a b");
> my @out = <$fh>;
> print Dumper($ret, \@out, $!);
> 
> my $ret = open(my $fh, "-|", "cmd", "/C", "echo", "a", "b");
> my @out = <$fh>;
> print Dumper($ret, \@out, $!);

Win32 Perl Output:

> $VAR1 = undef;
> $VAR2 = [];
> $VAR3 = 'No such file or directory';
> $VAR1 = 14764;
> $VAR2 = [
>           'a b
> '
>         ];
> $VAR3 = '';
> $VAR1 = 5668;
> $VAR2 = [
>           'a b
> '
>         ];
> $VAR3 = '';
Comment 9 Stephan Szabo 2019-07-23 15:20:56 PDT
Comment on attachment 374589 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=374589&action=review

> Tools/Scripts/webkitperl/VCSUtils_unittest/runCommand.pl:38
> +    inputArgs => ["perl", "-e", "print \@ARGV", "hello"],

Should we potentially use $^X here and below rather than always trying to search for perl in the path?
Comment 10 Fujii Hironori 2019-07-23 18:22:36 PDT
Comment on attachment 374589 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=374589&action=review

>> Tools/Scripts/webkitperl/VCSUtils_unittest/runCommand.pl:38
>> +    inputArgs => ["perl", "-e", "print \@ARGV", "hello"],
> 
> Should we potentially use $^X here and below rather than always trying to search for perl in the path?

Good idea. Will do so.
Comment 11 Fujii Hironori 2019-07-23 18:45:09 PDT
Created attachment 374750 [details]
Patch
Comment 12 Fujii Hironori 2019-07-24 19:01:10 PDT
Comment on attachment 374750 [details]
Patch

Clearing flags on attachment: 374750

Committed r247808: <https://trac.webkit.org/changeset/247808>
Comment 13 Fujii Hironori 2019-07-24 19:01:14 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Radar WebKit Bug Importer 2019-07-24 19:03:34 PDT
<rdar://problem/53523914>