Mercurial > hg > nginx-tests
changeset 574:2cd00179f4b2
Tests: has_feature() introduced in Test::Nginx.
It is used to check in a platform-aware way for a non-standard capability.
Use it for shared memory ('shmem') and symlink. Notably, this enables
corresponding tests on win32 where/when appropriate.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 14 May 2015 14:46:13 +0300 |
parents | 517cde5075d8 |
children | eea2b0158b51 |
files | autoindex.t autoindex_format.t http_disable_symlinks.t image_filter_finalize.t lib/Test/Nginx.pm limit_conn.t limit_conn_complex.t limit_req.t not_modified_proxy.t proxy_cache.t proxy_cache_chunked.t proxy_cache_lock.t proxy_cache_lock_age.t proxy_cache_lock_ssi.t proxy_cache_path.t proxy_cache_range.t proxy_cache_revalidate.t proxy_cache_variables.t proxy_cache_vary.t proxy_force_ranges.t proxy_merge_headers.t proxy_unfinished.t random_index.t range_charset.t scgi_merge_params.t spdy.t ssi.t |
diffstat | 27 files changed, 55 insertions(+), 79 deletions(-) [+] |
line wrap: on
line diff
--- a/autoindex.t Wed May 13 16:57:45 2015 +0300 +++ b/autoindex.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'no symlinks on win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http autoindex charset/)->plan(16) +my $t = Test::Nginx->new()->has(qw/http autoindex charset symlink/)->plan(16) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/autoindex_format.t Wed May 13 16:57:45 2015 +0300 +++ b/autoindex_format.t Thu May 14 14:46:13 2015 +0300 @@ -23,9 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'no symlinks on win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http autoindex/)->plan(37) +my $t = Test::Nginx->new()->has(qw/http autoindex symlink/)->plan(37) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/http_disable_symlinks.t Wed May 13 16:57:45 2015 +0300 +++ b/http_disable_symlinks.t Thu May 14 14:46:13 2015 +0300 @@ -23,7 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http rewrite/) +my $t = Test::Nginx->new()->has(qw/http rewrite symlink/) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/image_filter_finalize.t Wed May 13 16:57:45 2015 +0300 +++ b/image_filter_finalize.t Thu May 14 14:46:13 2015 +0300 @@ -21,10 +21,8 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new() - ->has(qw/http proxy cache image_filter limit_req rewrite/)->plan(4) +my $t = Test::Nginx->new()->has(qw/http proxy cache image_filter limit_req/) + ->has(qw/rewrite shmem/)->plan(4) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/lib/Test/Nginx.pm Wed May 13 16:57:45 2015 +0300 +++ b/lib/Test/Nginx.pm Thu May 14 14:46:13 2015 +0300 @@ -73,8 +73,9 @@ my ($self, @features) = @_; foreach my $feature (@features) { - Test::More::plan(skip_all => "$feature not compiled in") - unless $self->has_module($feature); + Test::More::plan(skip_all => "no $feature available") + unless $self->has_module($feature) + or $self->has_feature($feature); } return $self; @@ -152,6 +153,20 @@ return ($self->{_configure_args} =~ $re) ? 1 : 0; } +sub has_feature($) { + my ($self, $feature) = @_; + + if ($feature eq 'symlink') { + return $^O ne 'MSWin32'; + } + + if ($feature eq 'shmem') { + return $^O ne 'MSWin32' || $self->has_version('1.9.0'); + } + + return 0; +} + sub has_version($) { my ($self, $need) = @_;
--- a/limit_conn.t Wed May 13 16:57:45 2015 +0300 +++ b/limit_conn.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,8 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy limit_conn limit_req/)->plan(8); +my $t = Test::Nginx->new()->has(qw/http proxy limit_conn limit_req shmem/) + ->plan(8); $t->write_file_expand('nginx.conf', <<'EOF');
--- a/limit_conn_complex.t Wed May 13 16:57:45 2015 +0300 +++ b/limit_conn_complex.t Thu May 14 14:46:13 2015 +0300 @@ -24,9 +24,8 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy limit_conn limit_req/)->plan(4); +my $t = Test::Nginx->new()->has(qw/http proxy limit_conn limit_req shmem/) + ->plan(4); $t->write_file_expand('nginx.conf', <<'EOF');
--- a/limit_req.t Wed May 13 16:57:45 2015 +0300 +++ b/limit_req.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(5); +my $t = Test::Nginx->new()->has(qw/http limit_req shmem/)->plan(5); $t->write_file_expand('nginx.conf', <<'EOF');
--- a/not_modified_proxy.t Wed May 13 16:57:45 2015 +0300 +++ b/not_modified_proxy.t Thu May 14 14:46:13 2015 +0300 @@ -26,9 +26,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(9) +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(9) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache gzip/)->plan(14) +my $t = Test::Nginx->new()->has(qw/http proxy cache gzip shmem/)->plan(14) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache_chunked.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_chunked.t Thu May 14 14:46:13 2015 +0300 @@ -24,9 +24,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(2); +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(2); $t->write_file_expand('nginx.conf', <<'EOF');
--- a/proxy_cache_lock.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_lock.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(18) +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(18) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache_lock_age.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_lock_age.t Thu May 14 14:46:13 2015 +0300 @@ -24,9 +24,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(2) +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(2) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache_lock_ssi.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_lock_ssi.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache ssi/) +my $t = Test::Nginx->new()->has(qw/http proxy cache ssi shmem/) ->write_file_expand('nginx.conf', <<'EOF')->plan(2); %%TEST_GLOBALS%%
--- a/proxy_cache_path.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_path.t Thu May 14 14:46:13 2015 +0300 @@ -22,9 +22,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(7) +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(7) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache_range.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_range.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(7) +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(7) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache_revalidate.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_revalidate.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(23) +my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite shmem/)->plan(23) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache_variables.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_variables.t Thu May 14 14:46:13 2015 +0300 @@ -22,9 +22,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(9) +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(9) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_cache_vary.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_cache_vary.t Thu May 14 14:46:13 2015 +0300 @@ -21,10 +21,8 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache gzip rewrite/)->plan(42) - ->write_file_expand('nginx.conf', <<'EOF'); +my $t = Test::Nginx->new()->has(qw/http proxy cache gzip rewrite shmem/) + ->plan(42)->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_force_ranges.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_force_ranges.t Thu May 14 14:46:13 2015 +0300 @@ -23,9 +23,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(5) +my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(5) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_merge_headers.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_merge_headers.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(7) +my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite shmem/)->plan(7) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/proxy_unfinished.t Wed May 13 16:57:45 2015 +0300 +++ b/proxy_unfinished.t Thu May 14 14:46:13 2015 +0300 @@ -31,9 +31,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache sub/)->plan(15) +my $t = Test::Nginx->new()->has(qw/http proxy cache sub shmem/)->plan(15) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/random_index.t Wed May 13 16:57:45 2015 +0300 +++ b/random_index.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'no symlinks on win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http random_index/)->plan(1) +my $t = Test::Nginx->new()->has(qw/http random_index symlink/)->plan(1) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/range_charset.t Wed May 13 16:57:45 2015 +0300 +++ b/range_charset.t Thu May 14 14:46:13 2015 +0300 @@ -22,9 +22,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http proxy cache charset/)->plan(10) +my $t = Test::Nginx->new()->has(qw/http proxy cache charset shmem/)->plan(10) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/scgi_merge_params.t Wed May 13 16:57:45 2015 +0300 +++ b/scgi_merge_params.t Thu May 14 14:46:13 2015 +0300 @@ -23,9 +23,8 @@ eval { require SCGI; }; plan(skip_all => 'SCGI not installed') if $@; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; -my $t = Test::Nginx->new()->has(qw/http scgi cache/)->plan(9) +my $t = Test::Nginx->new()->has(qw/http scgi cache shmem/)->plan(9) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%%
--- a/spdy.t Wed May 13 16:57:45 2015 +0300 +++ b/spdy.t Thu May 14 14:46:13 2015 +0300 @@ -33,10 +33,9 @@ Compress::Raw::Zlib->WANT_GZIP_OR_ZLIB; }; plan(skip_all => 'Compress::Raw::Zlib not installed') if $@; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; my $t = Test::Nginx->new() - ->has(qw/http proxy cache limit_conn rewrite spdy realip/); + ->has(qw/http proxy cache limit_conn rewrite spdy realip shmem/); $t->plan(82)->write_file_expand('nginx.conf', <<'EOF');
--- a/ssi.t Wed May 13 16:57:45 2015 +0300 +++ b/ssi.t Thu May 14 14:46:13 2015 +0300 @@ -21,9 +21,8 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - -my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(28); +my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite shmem/) + ->plan(28); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -102,7 +101,7 @@ 'X<!--#include virtual="/proxy/empty.html" -->X'); $t->write_file('empty.html', ''); -$t->write_file('unescape.html?', 'SEE-THIS'); +$t->write_file('unescape.html?', 'SEE-THIS') unless $^O eq 'MSWin32'; $t->write_file('unescape1.html', 'X<!--#include virtual="/tes%741.html?test=test" -->X'); $t->write_file('unescape2.html', @@ -165,11 +164,17 @@ # handling of escaped URIs like(http_get('/unescape1.html'), qr/^XXtestXX$/m, 'escaped in path'); + +SKIP: { +skip 'incorrect filename on win32', 2 if $^O eq 'MSWin32'; + like(http_get('/unescape2.html'), qr/^XSEE-THISX$/m, 'escaped question in path'); like(http_get('/unescape3.html'), qr/404 Not Found/, 'escaped query separator'); +} + # handling of embedded date variables my $re_date_gmt = qr/X-Var: x\w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d [\w ]+x/;