in reply to Test::Cmd::Common and Test::More

You probably should use Test::Cmd if you want to integrate easily with Test::More and friends. In Test::Cmd::Common (to quote from the docs):

All methods throw exceptions and exit on failure

Since you want to detect failure rather than exit, use Test::Cmd instead. For example:

use strict; use warnings; use Test::More tests => 2; use Test::Cmd; my $cmd = Test::Cmd->new( prog => '/bin/ls /etc/motd' ); is $cmd->run, 0, 'ls ran okay'; is $cmd->stdout, "/etc/motd\n", 'and gave expected output';

Replies are listed 'Best First'.
Re: Re: Test::Cmd::Common and Test::More
by chromatic (Archbishop) on Jun 27, 2003 at 17:15 UTC

    You can also use Test::Exception to handle things that may or may not die. It's a handy module.

      It's a handy module

      Why thank you ;-)

      However, it's not appropriate here since Test::Cmd::Common doesn't die on test failure - it exits (see the documentation for the fail method for details.)

      T::C::C is a good fit for systems like Aegis, but not for Test::Harness folk.