Tests: better handle various configure arguments.
diff --git a/autoindex.t b/autoindex.t
index d5e638b..ee20890 100644
--- a/autoindex.t
+++ b/autoindex.t
@@ -21,7 +21,7 @@
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
index c05d58e..663dc78 100644
--- a/expect-100-continue.t
+++ b/expect-100-continue.t
@@ -21,7 +21,7 @@
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
index 8ee1cdc..3371d5b 100644
--- a/fastcgi.t
+++ b/fastcgi.t
@@ -24,7 +24,7 @@
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
index a6915fb..3faa0be 100644
--- a/gzip.t
+++ b/gzip.t
@@ -21,7 +21,7 @@
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
index 6898f44..cb887f3 100644
--- a/http-location.t
+++ b/http-location.t
@@ -21,7 +21,7 @@
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
index 7658733..763f0be 100644
--- a/http-server-name.t
+++ b/http-server-name.t
@@ -21,7 +21,7 @@
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
index 2411262..e354fb1 100644
--- a/imap.t
+++ b/imap.t
@@ -29,7 +29,7 @@
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
index e44725d..6a3c814 100644
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -51,11 +51,13 @@
}
}
-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 @@
my ($self, $feature) = @_;
my %regex = (
- mail => '--with-mail',
+ mail => '--with-mail(?!\S)',
flv => '--with-http_flv_module',
perl => '--with-http_perl_module',
- rewrite => '(?s)^(?!.*--without-http_rewrite_module)',
+ charset => '(?s)^(?!.*--without-http_charset_module)',
gzip => '(?s)^(?!.*--without-http_gzip_module)',
- cache => '(?s)^(?!.*--without-http-cache)',
- fastcgi => '(?s)^(?!.*--without-http_fastcgi_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)',
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)',
+ 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
index 4fdc25f..2b48b21 100644
--- a/limit-req.t
+++ b/limit-req.t
@@ -21,7 +21,7 @@
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
index 71091b8..ce434f2 100644
--- a/memcached.t
+++ b/memcached.t
@@ -24,7 +24,8 @@
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
index a1ebcfe..38f4406 100644
--- a/not-modified.t
+++ b/not-modified.t
@@ -21,7 +21,7 @@
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
index cb37830..c8e63a1 100644
--- a/perl-gzip.t
+++ b/perl-gzip.t
@@ -24,7 +24,7 @@
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
index 66c6969..2294657 100644
--- a/perl.t
+++ b/perl.t
@@ -21,7 +21,7 @@
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
index f65eccc..0b64caa 100644
--- a/pop3.t
+++ b/pop3.t
@@ -29,7 +29,7 @@
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
index 99afea5..d885474 100644
--- a/proxy-cache.t
+++ b/proxy-cache.t
@@ -21,9 +21,8 @@
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
index 88482a6..e626c08 100644
--- 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 @@
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
index cee71d0..e69e9e3 100644
--- 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 @@
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
index 699f919..6a86ece 100644
--- 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 @@
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
index 9d1985e..6384c26 100644
--- a/proxy-xar.t
+++ b/proxy-xar.t
@@ -21,7 +21,7 @@
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
index 85cf6e1..2a895d4 100644
--- 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 @@
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
index b950fcc..2d100b1 100644
--- a/random-index.t
+++ b/random-index.t
@@ -21,7 +21,7 @@
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
index 0653a16..f1a09d1 100644
--- a/range-flv.t
+++ b/range-flv.t
@@ -21,7 +21,7 @@
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
index 9d84120..8a9dc39 100644
--- a/range.t
+++ b/range.t
@@ -21,7 +21,7 @@
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
index 94e2fc5..f970887 100644
--- a/rewrite.t
+++ b/rewrite.t
@@ -21,7 +21,7 @@
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
index b42d0c1..74ada36 100644
--- a/smtp-greeting-delay.t
+++ b/smtp-greeting-delay.t
@@ -20,7 +20,7 @@
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
index 8d485be..4da0753 100644
--- a/smtp-xclient.t
+++ b/smtp-xclient.t
@@ -25,7 +25,7 @@
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
index 1a04a66..b6f7f29 100644
--- a/smtp.t
+++ b/smtp.t
@@ -28,7 +28,7 @@
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
index 3e95153..2e0338a 100644
--- a/ssi-include-big.t
+++ b/ssi-include-big.t
@@ -21,7 +21,7 @@
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
index 28938a1..21b7073 100644
--- a/ssi.t
+++ b/ssi.t
@@ -21,7 +21,7 @@
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');