Mercurial > hg > nginx-tests
changeset 28:8f1519472ece
Tests: unbreak and extend has() functionality.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 10 Oct 2008 20:23:39 +0400 |
parents | fb94a224fef2 |
children | 71ea39729fa0 |
files | lib/Test/Nginx.pm smtp-greeting-delay.t smtp.t ssi-include-big.t |
diffstat | 4 files changed, 23 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/Test/Nginx.pm Fri Oct 10 20:09:14 2008 +0400 +++ b/lib/Test/Nginx.pm Fri Oct 10 20:23:39 2008 +0400 @@ -44,10 +44,26 @@ } 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 {
--- a/smtp-greeting-delay.t Fri Oct 10 20:09:14 2008 +0400 +++ b/smtp-greeting-delay.t Fri Oct 10 20:23:39 2008 +0400 @@ -23,7 +23,7 @@ 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;
--- a/smtp.t Fri Oct 10 20:09:14 2008 +0400 +++ b/smtp.t Fri Oct 10 20:23:39 2008 +0400 @@ -26,7 +26,7 @@ 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();
--- a/ssi-include-big.t Fri Oct 10 20:09:14 2008 +0400 +++ b/ssi-include-big.t Fri Oct 10 20:23:39 2008 +0400 @@ -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 @@ 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');