Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the App-Cmd CPAN distribution.

Report information
The Basics
Id: 73901
Status: resolved
Priority: 0/
Queue: App-Cmd

People
Owner: Nobody in particular
Requestors: DOUGDUDE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.314
Fixed in: (no value)



Subject: t/capture-ext.t fails on Win32
The t/capture-ext.t test fails in Win32 (and, really, any system which does not have an external "echo" program). Technically running system('echo', 'Hello World') does work on Win32, but IPC::Cmd looks for the program named echo, which does not exist. system() is make to retry failed commands within the cmd.exe shell on Win32, thus allowing echo to work. My suggestion for fixing the test is to change the test to just also accept the valid output "Program 'echo' not found" for the hello command. I have attached what I think may be a solution.
Subject: 0001-t-capture-ext.t-should-handle-valid-error-output.patch
From f03ce6b5fed7f99b0436c410ba4bbe2ad830a1bd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson <doug@somethingdoug.com> Date: Wed, 11 Jan 2012 10:58:13 -0500 Subject: [PATCH] t/capture-ext.t should handle valid error output. --- t/capture-ext.t | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/t/capture-ext.t b/t/capture-ext.t index 82daf32..a6466bb 100644 --- a/t/capture-ext.t +++ b/t/capture-ext.t @@ -16,5 +16,9 @@ isa_ok($app, 'Test::MyCmd'); my $return = test_app('Test::MyCmd', [ qw(hello) ]); -like( $return->output, qr/Hello World/, "Captured external subcommand output" ); +if (defined $return->error) { + like( $return->error, qr/Program 'echo' not found/, "Captured external subcommand output - no echo" ); +} else { + like( $return->output, qr/Hello World/, "Captured external subcommand output" ); +} -- 1.7.6.msysgit.0
It seems that can_run function in Module::Install has a problem. In t\lib\Test\MyCmd\Command\hello.pm file, the below line doesn't return command name as true value. my $echo = can_run("echo"); can_run function can't catch window cmd.exe's internal command. Show quoted text
>perl -Minc::Module::Install -E "say can_run('notepad') ? 'yes':'no'"
yes Show quoted text
>perl -Minc::Module::Install -E "say can_run('dir') ? 'yes':'no'"
no Show quoted text
>perl -Minc::Module::Install -E "say can_run('echo') ? 'yes':'no'"
no Is this Module::Install module problem ? On Wed Jan 11 11:01:17 2012, DOUGDUDE wrote: Show quoted text
> The t/capture-ext.t test fails in Win32 (and, really, any system which > does not have an external "echo" program). Technically running > system('echo', 'Hello World') does work on Win32, but IPC::Cmd looks for > the program named echo, which does not exist. system() is make to retry > failed commands within the cmd.exe shell on Win32, thus allowing echo to > work. > > My suggestion for fixing the test is to change the test to just also > accept the valid output "Program 'echo' not found" for the hello > command. I have attached what I think may be a solution.
On Sat Jan 14 00:57:55 2012, AERO wrote: Show quoted text
> It seems that can_run function in Module::Install has a problem. > In t\lib\Test\MyCmd\Command\hello.pm file, the below line doesn't return > command name as true value. > my $echo = can_run("echo"); > > can_run function can't catch window cmd.exe's internal command. >
> >perl -Minc::Module::Install -E "say can_run('notepad') ? 'yes':'no'"
> yes
> >perl -Minc::Module::Install -E "say can_run('dir') ? 'yes':'no'"
> no
> >perl -Minc::Module::Install -E "say can_run('echo') ? 'yes':'no'"
> no > > Is this Module::Install module problem ? >
can_run is imported from IPC::Cmd, not from Module::Install. IMO it is not a problem with IPC::Cmd's can_run. It is documented that can_run is a universal replacement for using which. Since Win32 does not have a binary named echo in the PATH by default, can_run correctly returns undef. I think this is appropriate and would affect any system that does not have a program named echo in the PATH at the time the test suite is run. I think the test should be altered to accept that running the hello can correctly output an error that echo was not found.
I believe this was fixed by 0.315 -- rjbs