According to the docs, "Test::Harness uses $^X to determine the perl binary to run the tests with." Meanwhile, it appears to simply concatenate it with the arguments and system() that string (or otherwise split on whitespace itself), because it things that the path up to the first space is the whole interpreter name![prompt]perl -MTest::Harness -e"runtests 'test1.perl'" test1.per...........'C:\Program' is not recognized as an internal or e +xternal command, operable program or batch file. test1.per...........dubious Test returned status 1 (wstat 256, 0x100) FAILED--1 test script could be run, alas--no output ever seen
Why do Perl tools have such problems with spaces? Haven't spaces (as well as control chars, and really anything except a slash) been legal on UNIX systems since the dawn of time?
In my own script, I reciently used $^X to launch another perl script and used the list form of system() with no problems. Perl knew that the first one was the program name, and how to quote or escape the argument strings properly on this platform.
So what's Test::Harness' problem? A quick search of the code shows:
or, to condense that, it turns intomy $cmd = ($ENV{'HARNESS_COMPILE_TEST'}) ? "./perl -I../lib ../utils/perlcc $test " . "-r 2>> ./compilelog |" : "$^X $s $test|"; $cmd = "MCR $cmd" if $^O eq 'VMS'; $fh->open($cmd) or print "can't run $test. $!\n";
The pipe-out form of open takes a single string, as on a command prompt shell, rather than multiple arguments. Perhaps the new list form of open in Perl 5.8 is to provide exactly this? Anyway, the script has to take charge of knowing how to quote/escape whatever all the contents of the command to run.open FH, "$^X $scriptname|"
That is fraught with system-specific details, so there should be something like File::Spec to hide that. Is there (yet)?
Second, this program makes no attempt to even try! Not only does it fall flat if the Perl path has spaces in it (on any platform), but the scriptname has the same problem. And it's not just spaces—any special characters used by the shell will mess it up, since they are not escaped.
I find it amusing that Test::Harness is not itself tested too see how it likes a standard Windows installation (typically C:\Program Files\... and ...\My Documents\...).
A quick edit to Test::Harness.pm involving
and it gets past that problem. Not as robust as it could be, though, since it doesn't handle Unicode names.my $interp_name= $^O eq 'MSWin32' ? Win32::GetShortPathName($^X) : $^X +;
—John
In reply to Test::Harness not working on my machine by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |