Permalink
Browse files

fixed to cannot detection at /usr/sbin/sendmail or /usr/lib/sendmail

  • Loading branch information...
1 parent 8b9e2b4 commit 37a0faef69df807065621a89b42c335687b4a96d @yappo committed Jun 24, 2009
Showing with 24 additions and 3 deletions.
  1. +2 −2 lib/Email/Send/Sendmail.pm
  2. +22 −1 t/sendmail.t
@@ -25,8 +25,8 @@ sub _find_sendmail {
my $sendmail;
for my $dir (
File::Spec->path,
- File::Spec->catfile('', qw(usr sbin sendmail)),
- File::Spec->catfile('', qw(usr lib sendmail)),
+ File::Spec->catfile('', qw(usr sbin)),
+ File::Spec->catfile('', qw(usr lib)),
) {
if ( -x "$dir/sendmail" ) {
$sendmail = "$dir/sendmail";
View
@@ -1,4 +1,4 @@
-use Test::More tests => 11;
+use Test::More tests => 12;
use strict;
$^W = 1;
@@ -14,7 +14,12 @@ Subject: This should never show up in my inbox
blah blah blah
EOF
+SKIP:
{
+ skip 'Can run unless sendmail is at /usr/sbin/sendmail or /usr/lib/sendmail', 3
+ if -x '/usr/sbin/sendmail'
+ || -x '/usr/lib/sendmail';
+
local $ENV{PATH} = '';
ok( Email::Send::Sendmail->is_available, 'Email::Send always is available' );
my $msg = Email::Send::Sendmail->is_available;
@@ -24,6 +29,22 @@ EOF
ok( ! defined $path, 'no sendmail found because we have no path' );
}
+SKIP:
+{
+ skip 'Cannot run unless sendmail is at /usr/sbin/sendmail or /usr/lib/sendmail', 1
+ unless -x '/usr/sbin/sendmail'
+ || -x '/usr/lib/sendmail';
+
+ local $ENV{PATH} = '';
+ $ENV{PATH} =~ tr/:/;/ if $^O =~ /Win/;
+ my $path = Email::Send::Sendmail->_find_sendmail;
+ if (-x '/usr/sbin/sendmail') {
+ is( $path, '/usr/sbin/sendmail', 'found sendmail in /usr/sbin' );
+ } else {
+ is( $path, '/usr/lib/sendmail', 'found sendmail in /usr/lib' );
+ }
+}
+
{
local $Email::Send::Sendmail::SENDMAIL = 'testing';
ok( Email::Send::Sendmail->is_available, 'Email::Send is available with $SENDMAIL set' );

0 comments on commit 37a0fae

Please sign in to comment.