ingydotnet / inline-pm

Write Perl subroutines in other programming languages
http://search.cpan.org/dist/Inline/
19 stars 16 forks source link

Tests t/03errors.t and t/09perl5lib.t fails on Windows 10: 'inc\bin\testml-cpan' is not recognized as an internal or external command #79

Open hakonhagland opened 4 years ago

hakonhagland commented 4 years ago

I am trying to install Inline on Windows 10 with Strawberry Perl version 5.30.1:

>gmake test
"C:\Strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/000-require-modules.t .. ok
t/01usages.t ............. ok
t/02config.t ............. ok
t/03errors.t ............. 'inc\bin\testml-cpan' is not recognized as an internal or external command,
operable program or batch file.
t/03errors.t ............. No subtests run
t/04create.t ............. ok
t/05files.t .............. Skipping - couldn't load the Inline::Files module
t/05files.t .............. ok
t/06rewrite_config.t ..... ok
t/07rewrite2_config.t .... ok
t/08unicode.t ............ ok
t/09perl5lib.t ........... 'inc\bin\testml-cpan' is not recognized as an internal or external command,
operable program or batch file.
t/09perl5lib.t ........... No subtests run
t/author-pod-syntax.t .... skipped: these tests are for testing by the author

Test Summary Report
-------------------
t/03errors.t           (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
t/09perl5lib.t         (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
Files=11, Tests=23,  6 wallclock secs ( 0.06 usr +  0.08 sys =  0.14 CPU)
Result: FAIL
Failed 2/11 test programs. 0/23 subtests failed.
gmake: *** [Makefile:873: test_dynamic] Error 255
hakonhagland commented 4 years ago

It seems that the shebang in t\03errors.t is not interpreted: #!inc\bin\testml-cpan. I can run the test fine like this:

>perl -Mblib ./inc/bin/testml-cpan t/03errors.t
ok 1 - Bad first parameter
ok 2 - Bad first parameter
ok 3 - Bad shortcut
ok 4 - Bad shortcut
ok 5 - Bad shortcut
ok 6 - Bad shortcut
ok 7 - Bad config option
1..7
sisyphus commented 4 years ago

No problems for me on Windows 7, but I suspect the difference has more to do with our respective shells and/or our PATHEXT environment variables. Does your PATHEXT include .CMD ? And what shell are you using ? (I'm using cmd.exe.)

I think the error message you're seeing (namely "'inc\bin\testml-cpan' is not recognized as an internal or external command") indicates that the shebang line is being interpreted correctly. It's just that "inc\bin\testml-cpan.cmd" is not being recognized as a valid command on your box - though it's fine for me in the cmd.exe shell.

So I think that changing the shebang line in the 2 affected test files from "#!inc\bin\testml-cpan" to "#!./inc/bin/testml-cpan" or "#!inc/bin/testml-cpan" will work for you. Can you confirm that ?

Unfortunately, neither of those 2 alternatives will work for me because my cmd.exe shell insists upon the use of backslashes in the command. I'm hopeful that we'll be able to find some portable way of meeting the desired aim, once we establish what's going on. For example, your workaround of "perl -Mblib ./inc/bin/testml-cpan t/03errors.t" is also quite acceptable to my cmd.exe shell

Cheers, Rob

On Thu, Aug 13, 2020 at 2:25 PM Håkon Hægland notifications@github.com wrote:

It seems that the shebang in t\03errors.t is not interpreted:

!inc\bin\testml-cpan. I can run the test fine like this:

perl -Mblib ./inc/bin/testml-cpan t/03errors.t ok 1 - Bad first parameter ok 2 - Bad first parameter ok 3 - Bad shortcut ok 4 - Bad shortcut ok 5 - Bad shortcut ok 6 - Bad shortcut ok 7 - Bad config option 1..7

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ingydotnet/inline-pm/issues/79#issuecomment-673247363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAR3PBMC63AWGMQ7EYP34DSANTK3ANCNFSM4P5YBG6A .

hakonhagland commented 4 years ago

@sisyphus I can confirm that .CMD was missing from my %PATHEXT% environment variable. So this now works:

>set PATHEXT=.exe;.bat;.pl;.PL;.cmd
>gmake test
"C:\Strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/000-require-modules.t .. ok
t/01usages.t ............. ok
t/02config.t ............. ok
t/03errors.t ............. ok
t/04create.t ............. ok
t/05files.t .............. Skipping - couldn't load the Inline::Files module
t/05files.t .............. ok
t/06rewrite_config.t ..... ok
t/07rewrite2_config.t .... ok
t/08unicode.t ............ ok
t/09perl5lib.t ........... ok
t/author-pod-syntax.t .... skipped: these tests are for testing by the author
All tests successful.
Files=11, Tests=33,  9 wallclock secs ( 0.08 usr +  0.01 sys =  0.09 CPU)
Result: PASS

Note I did not change the shebang, so it is still #!inc\bin\testml-cpan . As I understand, Windows do not use Shebang, but instead the shebang is interpreted by perl, according to perldoc perlrun:

If the #! line does not contain the word "perl" nor the word "indir", the program named after the #! is executed instead of the Perl interpreter. This is slightly bizarre, but it helps people on machines that don't do #! , because they can tell a program that their SHELL is /usr/bin/perl, and Perl will then dispatch the program to the correct interpreter for them.

So this will execute the CMD script inc\bin\testml-cpan.CMD which contains a single line:

if exist "%~dpn0" perl %0 %*

which is expanded to something like (for the file t/03errors.t as processed by gmake test):

if exist "C:\Users\hakon\perl\Inline-0.86\inc\bin\testml-cpan" perl inc\bin\testml-cpan t/03errors.t

Unfortunately I cannot remember why I removed .CMD from PATHEXT long time ago.

I am not sure if the Makefile should check if the .CMD is in %PATHEXT% or we simply ignore the possibility that it could be missing since it should be in %PATHEXT% by default, according to this post..

sisyphus commented 4 years ago

On Thu, Aug 13, 2020 at 11:44 PM Håkon Hægland notifications@github.com wrote:

I am not sure if the Makefile should check if the .CMD is in %PATHEXT% or we simply ignore the possibility that it could be missing since it should in %PATHEXT% by default, according to this https://superuser.com/q/1027078/278134 post..

Well ... the Makefile.PL could just as easily have called the file 'inc/bin/testml-cpan.bat' - which is probably a better choice of extension, as I would think it highly unlikely that '.bat' will be missing from the PATHEXT of a system that's running perl. I'm assuming that all of those batch files that we see in perl/bin on Windows like cpan.bat, perldoc.bat, h2xs.bat, are hard-coded to '.bat' and would not be given a different extension if '.bat' was missing from PATHEXT. I also assume that you still have '.bat' in PATHEXT. (If not, there's an awful lot of utilities in Strawberry Perl that you're unable to use.)

Anyway, that's what my recommendation would be - in the Makefile.PL, replace:

my $file = 'inc/bin/testml-cpan.cmd'; with my $file = 'inc/bin/testml-cpan.bat';

I notice that the Makefile.PL "was automatically generated by 'inc/bin/testml-cpan.cmd';Dist::Zilla::Plugin::MakeMaker v6.012", so I don't know how easy it would be for that automated process to put that change in place.

Cheers, Rob