# HG changeset patch # User Maxim Dounin # Date 1223655819 -14400 # Node ID 8f1519472ece74e7b32e2cefd5c05d1bfd6d2af3 # Parent fb94a224fef255eac6369ef47fa9b71d6782c751 Tests: unbreak and extend has() functionality. diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -44,10 +44,26 @@ sub DESTROY { } sub has { - my ($self, $feature, %options) = @_; + my ($self, $feature) = @_; + + my %regex = ( + mail => '--with-mail', + rewrite => '(?s)^(?!.*--without-http_rewrite_module)', + static => '(?s)^(?!.*--without-http_static_module)', + ); + Test::More::plan(skip_all => "$feature not compiled in") - unless `$NGINX -V 2>&1` =~ $feature; - Test::More::plan($options{plan}) if defined $options{plan}; + unless `$NGINX -V 2>&1` =~ $regex{$feature}; + + return $self; +} + +sub plan { + my ($self, $plan) = @_; + + Test::More::plan(tests => $plan); + + return $self; } sub run { diff --git a/smtp-greeting-delay.t b/smtp-greeting-delay.t --- a/smtp-greeting-delay.t +++ b/smtp-greeting-delay.t @@ -23,7 +23,7 @@ use Test::Nginx::SMTP; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('mail', plan => 2) +my $t = Test::Nginx->new()->has('mail')->plan(2) ->write_file_expand('nginx.conf', <<'EOF')->run(); master_process off; diff --git a/smtp.t b/smtp.t --- a/smtp.t +++ b/smtp.t @@ -26,7 +26,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; my $t = Test::Nginx->new() - ->has('mail', plan => 26) + ->has('mail')->plan(26) ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) ->write_file_expand('nginx.conf', <<'EOF')->run(); diff --git a/ssi-include-big.t b/ssi-include-big.t --- a/ssi-include-big.t +++ b/ssi-include-big.t @@ -9,7 +9,7 @@ use warnings; use strict; -use Test::More tests => 3; +use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new(); +my $t = Test::Nginx->has('rewrite')->plan(3)->new(); $t->write_file_expand('nginx.conf', <<'EOF');