# HG changeset patch # User Maxim Dounin # Date 1261832777 -10800 # Node ID 8ac1faaddd2c847b3d93cb03d2119689f7451ded # Parent 598b758c68a9d9e3e44b2e4e7a0ee02e3c0a2876 Tests: better handle various configure arguments. diff --git a/autoindex.t b/autoindex.t --- a/autoindex.t +++ b/autoindex.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->plan(4) +my $t = Test::Nginx->new()->has(qw/http autoindex/)->plan(4) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/expect-100-continue.t b/expect-100-continue.t --- a/expect-100-continue.t +++ b/expect-100-continue.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->plan(2); +my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(2); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/fastcgi.t b/fastcgi.t --- a/fastcgi.t +++ b/fastcgi.t @@ -24,7 +24,7 @@ select STDOUT; $| = 1; eval { require FCGI; }; plan(skip_all => 'FCGI not installed') if $@; -my $t = Test::Nginx->new()->has('fastcgi')->plan(4) +my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(4) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/gzip.t b/gzip.t --- a/gzip.t +++ b/gzip.t @@ -21,7 +21,7 @@ use Test::Nginx qw/ :DEFAULT :gzip /; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('gzip')->plan(8); +my $t = Test::Nginx->new()->has(qw/http proxy gzip/)->plan(8); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/http-location.t b/http-location.t --- a/http-location.t +++ b/http-location.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('rewrite')->plan(8) +my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(8) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/http-server-name.t b/http-server-name.t --- a/http-server-name.t +++ b/http-server-name.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('rewrite')->plan(9) +my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(9) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/imap.t b/imap.t --- a/imap.t +++ b/imap.t @@ -29,7 +29,7 @@ select STDOUT; $| = 1; local $SIG{PIPE} = 'IGNORE'; my $t = Test::Nginx->new() - ->has('mail')->plan(8) + ->has(qw/mail imap http rewrite/)->plan(8) ->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon) ->write_file_expand('nginx.conf', <<'EOF')->run(); diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -51,11 +51,13 @@ sub DESTROY { } } -sub has($) { - my ($self, $feature) = @_; +sub has($;) { + my ($self, @features) = @_; - Test::More::plan(skip_all => "$feature not compiled in") - unless $self->has_module($feature); + foreach my $feature (@features) { + Test::More::plan(skip_all => "$feature not compiled in") + unless $self->has_module($feature); + } return $self; } @@ -64,14 +66,41 @@ sub has_module($) { my ($self, $feature) = @_; my %regex = ( - mail => '--with-mail', + mail => '--with-mail(?!\S)', flv => '--with-http_flv_module', perl => '--with-http_perl_module', + charset => '(?s)^(?!.*--without-http_charset_module)', + gzip => '(?s)^(?!.*--without-http_gzip_module)', + ssi => '(?s)^(?!.*--without-http_ssi_module)', + userid => '(?s)^(?!.*--without-http_userid_module)', + access => '(?s)^(?!.*--without-http_access_module)', + auth_basic + => '(?s)^(?!.*--without-http_auth_basic_module)', + autoindex + => '(?s)^(?!.*--without-http_autoindex_module)', + geo => '(?s)^(?!.*--without-http_geo_module)', + map => '(?s)^(?!.*--without-http_map_module)', + referer => '(?s)^(?!.*--without-http_referer_module)', rewrite => '(?s)^(?!.*--without-http_rewrite_module)', - gzip => '(?s)^(?!.*--without-http_gzip_module)', + proxy => '(?s)^(?!.*--without-http_proxy_module)', + fastcgi => '(?s)^(?!.*--without-http_fastcgi_module)', + memcached + => '(?s)^(?!.*--without-http_memcached_module)', + limit_zone + => '(?s)^(?!.*--without-http_limit_zone_module)', + limit_req + => '(?s)^(?!.*--without-http_limit_req_module)', + empty_gif + => '(?s)^(?!.*--without-http_empty_gif_module)', + browser => '(?s)^(?!.*--without-http_browser_module)', + upstream_ip_hash + => '(?s)^(?!.*--without-http_upstream_ip_hash_module)', + http => '(?s)^(?!.*--without-http(?!\S))', cache => '(?s)^(?!.*--without-http-cache)', - fastcgi => '(?s)^(?!.*--without-http_fastcgi_module)', - proxy => '(?s)^(?!.*--without-http_proxy_module)', + pop3 => '(?s)^(?!.*--without-mail_pop3_module)', + imap => '(?s)^(?!.*--without-mail_imap_module)', + smtp => '(?s)^(?!.*--without-mail_smtp_module)', + pcre => '(?s)^(?!.*--without-pcre)', ); my $re = $regex{$feature}; diff --git a/limit-req.t b/limit-req.t --- a/limit-req.t +++ b/limit-req.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->plan(5); +my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(5); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/memcached.t b/memcached.t --- a/memcached.t +++ b/memcached.t @@ -24,7 +24,8 @@ select STDOUT; $| = 1; eval { require Cache::Memcached; }; plan(skip_all => 'Cache::Memcached not installed') if $@; -my $t = Test::Nginx->new()->has('rewrite')->has_daemon('memcached')->plan(4) +my $t = Test::Nginx->new()->has(qw/http rewrite memcached/) + ->has_daemon('memcached')->plan(4) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/not-modified.t b/not-modified.t --- a/not-modified.t +++ b/not-modified.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->plan(4) +my $t = Test::Nginx->new()->has('http')->plan(4) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/perl-gzip.t b/perl-gzip.t --- a/perl-gzip.t +++ b/perl-gzip.t @@ -24,7 +24,7 @@ select STDOUT; $| = 1; eval { require IO::Compress::Gzip; }; Test::More::plan(skip_all => "IO::Compress::Gzip not found") if $@; -my $t = Test::Nginx->new()->has('perl')->has('gzip')->plan(2) +my $t = Test::Nginx->new()->has(qw/http perl gzip/)->plan(2) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/perl.t b/perl.t --- a/perl.t +++ b/perl.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('perl')->has('rewrite')->plan(1) +my $t = Test::Nginx->new()->has(qw/http perl rewrite/)->plan(1) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/pop3.t b/pop3.t --- a/pop3.t +++ b/pop3.t @@ -29,7 +29,7 @@ select STDOUT; $| = 1; local $SIG{PIPE} = 'IGNORE'; my $t = Test::Nginx->new() - ->has('mail')->plan(8) + ->has(qw/mail pop3 http rewrite/)->plan(8) ->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon) ->write_file_expand('nginx.conf', <<'EOF')->run(); diff --git a/proxy-cache.t b/proxy-cache.t --- a/proxy-cache.t +++ b/proxy-cache.t @@ -21,9 +21,8 @@ use Test::Nginx qw/ :DEFAULT :gzip /; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('gzip')->has('cache')->plan(9); - -$t->write_file_expand('nginx.conf', <<'EOF'); +my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(9) + ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/proxy-chunked.t b/proxy-chunked.t --- a/proxy-chunked.t +++ b/proxy-chunked.t @@ -13,7 +13,7 @@ use warnings; use strict; -use Test::More tests => 3; +use Test::More; use IO::Select; @@ -27,7 +27,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new(); +my $t = Test::Nginx->new()->has(qw/http proxy ssi/)->plan(3); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/proxy-noclose.t b/proxy-noclose.t --- a/proxy-noclose.t +++ b/proxy-noclose.t @@ -18,7 +18,7 @@ use warnings; use strict; -use Test::More tests => 4; +use Test::More; use IO::Select; @@ -32,7 +32,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new(); +my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(4); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/proxy-store.t b/proxy-store.t --- a/proxy-store.t +++ b/proxy-store.t @@ -9,7 +9,7 @@ use warnings; use strict; -use Test::More tests => 7; +use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } @@ -23,7 +23,7 @@ select STDOUT; $| = 1; my $t = Test::Nginx->new(); -$t->write_file_expand('nginx.conf', <<'EOF'); +$t->write_file_expand('nginx.conf', <<'EOF')->has(qw/http proxy ssi/)->plan(7); %%TEST_GLOBALS%% diff --git a/proxy-xar.t b/proxy-xar.t --- a/proxy-xar.t +++ b/proxy-xar.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('rewrite')->plan(8); +my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(8); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/proxy.t b/proxy.t --- a/proxy.t +++ b/proxy.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->new()->has(qw/http proxy/)->plan(3); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/random-index.t b/random-index.t --- a/random-index.t +++ b/random-index.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('--with-http_random_index_module')->plan(1) +my $t = Test::Nginx->new()->has(qw/http random_index/)->plan(1) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/range-flv.t b/range-flv.t --- a/range-flv.t +++ b/range-flv.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('flv')->plan(12); +my $t = Test::Nginx->new()->has(qw/http flv/)->plan(12); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/range.t b/range.t --- a/range.t +++ b/range.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->plan(25); +my $t = Test::Nginx->new()->has(qw/http charset/)->plan(25); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/rewrite.t b/rewrite.t --- a/rewrite.t +++ b/rewrite.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('rewrite')->plan(5) +my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(5) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% diff --git a/smtp-greeting-delay.t b/smtp-greeting-delay.t --- a/smtp-greeting-delay.t +++ b/smtp-greeting-delay.t @@ -20,7 +20,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(qw/mail smtp http/)->plan(2) ->write_file_expand('nginx.conf', <<'EOF')->run(); %%TEST_GLOBALS%% diff --git a/smtp-xclient.t b/smtp-xclient.t --- a/smtp-xclient.t +++ b/smtp-xclient.t @@ -25,7 +25,7 @@ select STDOUT; $| = 1; local $SIG{PIPE} = 'IGNORE'; -my $t = Test::Nginx->new()->has('mail')->plan(6) +my $t = Test::Nginx->new()->has(qw/mail smtp http/)->plan(6) ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) ->write_file_expand('nginx.conf', <<'EOF')->run(); diff --git a/smtp.t b/smtp.t --- a/smtp.t +++ b/smtp.t @@ -28,7 +28,7 @@ select STDOUT; $| = 1; local $SIG{PIPE} = 'IGNORE'; my $t = Test::Nginx->new() - ->has('mail')->plan(25) + ->has(qw/mail smtp http rewrite/)->plan(25) ->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 @@ -21,7 +21,7 @@ use Test::Nginx qw/ :DEFAULT :gzip /; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('rewrite')->has('gzip')->plan(8); +my $t = Test::Nginx->new()->has(qw/http ssi rewrite gzip proxy/)->plan(8); $t->write_file_expand('nginx.conf', <<'EOF'); diff --git a/ssi.t b/ssi.t --- a/ssi.t +++ b/ssi.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has('cache')->plan(16); +my $t = Test::Nginx->new()->has(qw/http ssi cache proxy/)->plan(16); $t->write_file_expand('nginx.conf', <<'EOF');