changeset 121:8ac1faaddd2c

Tests: better handle various configure arguments.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 26 Dec 2009 16:06:17 +0300
parents 598b758c68a9
children 01e86a067f05
files autoindex.t expect-100-continue.t fastcgi.t gzip.t http-location.t http-server-name.t imap.t lib/Test/Nginx.pm limit-req.t memcached.t not-modified.t perl-gzip.t perl.t pop3.t proxy-cache.t proxy-chunked.t proxy-noclose.t proxy-store.t proxy-xar.t proxy.t random-index.t range-flv.t range.t rewrite.t smtp-greeting-delay.t smtp-xclient.t smtp.t ssi-include-big.t ssi.t
diffstat 29 files changed, 71 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- 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%%
--- 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');
 
--- 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%%
--- 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');
 
--- 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%%
--- 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%%
--- 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();
 
--- 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};
--- 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');
 
--- 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%%
--- 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%%
--- 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%%
--- 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%%
--- 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();
 
--- 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%%
 
--- 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');
 
--- 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');
 
--- 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%%
 
--- 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');
 
--- 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');
 
--- 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%%
--- 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');
 
--- 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');
 
--- 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%%
--- 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%%
--- 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();
 
--- 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();
 
--- 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');
 
--- 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');