# HG changeset patch # User Sergey Kandaurov # Date 1431603973 -10800 # Node ID 2cd00179f4b2778e59b52e1b5e4166e63f8cffa9 # Parent 517cde5075d8b79aa8ca788a0dd497d197a1a003 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. diff --git a/autoindex.t b/autoindex.t --- a/autoindex.t +++ b/autoindex.t @@ -21,9 +21,7 @@ use Test::Nginx; 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%% diff --git a/autoindex_format.t b/autoindex_format.t --- a/autoindex_format.t +++ b/autoindex_format.t @@ -23,9 +23,7 @@ use Test::Nginx; 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%% diff --git a/http_disable_symlinks.t b/http_disable_symlinks.t --- a/http_disable_symlinks.t +++ b/http_disable_symlinks.t @@ -23,7 +23,7 @@ use Test::Nginx; 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%% diff --git a/image_filter_finalize.t b/image_filter_finalize.t --- a/image_filter_finalize.t +++ b/image_filter_finalize.t @@ -21,10 +21,8 @@ use Test::Nginx; 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%% diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -73,8 +73,9 @@ sub has($;) { 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 @@ sub has_module($) { 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) = @_; diff --git a/limit_conn.t b/limit_conn.t --- a/limit_conn.t +++ b/limit_conn.t @@ -21,9 +21,8 @@ use Test::Nginx; 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'); diff --git a/limit_conn_complex.t b/limit_conn_complex.t --- a/limit_conn_complex.t +++ b/limit_conn_complex.t @@ -24,9 +24,8 @@ use Test::Nginx; 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'); diff --git a/limit_req.t b/limit_req.t --- a/limit_req.t +++ b/limit_req.t @@ -21,9 +21,7 @@ use Test::Nginx; 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'); diff --git a/not_modified_proxy.t b/not_modified_proxy.t --- a/not_modified_proxy.t +++ b/not_modified_proxy.t @@ -26,9 +26,7 @@ use Test::Nginx; 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%% diff --git a/proxy_cache.t b/proxy_cache.t --- a/proxy_cache.t +++ b/proxy_cache.t @@ -21,9 +21,7 @@ use Test::Nginx qw/ :DEFAULT :gzip /; 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%% diff --git a/proxy_cache_chunked.t b/proxy_cache_chunked.t --- a/proxy_cache_chunked.t +++ b/proxy_cache_chunked.t @@ -24,9 +24,7 @@ use Test::Nginx; 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'); diff --git a/proxy_cache_lock.t b/proxy_cache_lock.t --- a/proxy_cache_lock.t +++ b/proxy_cache_lock.t @@ -21,9 +21,7 @@ use Test::Nginx qw/ :DEFAULT http_end /; 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%% diff --git a/proxy_cache_lock_age.t b/proxy_cache_lock_age.t --- a/proxy_cache_lock_age.t +++ b/proxy_cache_lock_age.t @@ -24,9 +24,7 @@ use Test::Nginx; 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%% diff --git a/proxy_cache_lock_ssi.t b/proxy_cache_lock_ssi.t --- a/proxy_cache_lock_ssi.t +++ b/proxy_cache_lock_ssi.t @@ -21,9 +21,7 @@ use Test::Nginx qw/ :DEFAULT http_end /; 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%% diff --git a/proxy_cache_path.t b/proxy_cache_path.t --- a/proxy_cache_path.t +++ b/proxy_cache_path.t @@ -22,9 +22,7 @@ use Test::Nginx; 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%% diff --git a/proxy_cache_range.t b/proxy_cache_range.t --- a/proxy_cache_range.t +++ b/proxy_cache_range.t @@ -21,9 +21,7 @@ use Test::Nginx; 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%% diff --git a/proxy_cache_revalidate.t b/proxy_cache_revalidate.t --- a/proxy_cache_revalidate.t +++ b/proxy_cache_revalidate.t @@ -21,9 +21,7 @@ use Test::Nginx qw/ :DEFAULT :gzip /; 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%% diff --git a/proxy_cache_variables.t b/proxy_cache_variables.t --- a/proxy_cache_variables.t +++ b/proxy_cache_variables.t @@ -22,9 +22,7 @@ use Test::Nginx; 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%% diff --git a/proxy_cache_vary.t b/proxy_cache_vary.t --- a/proxy_cache_vary.t +++ b/proxy_cache_vary.t @@ -21,10 +21,8 @@ use Test::Nginx; 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%% diff --git a/proxy_force_ranges.t b/proxy_force_ranges.t --- a/proxy_force_ranges.t +++ b/proxy_force_ranges.t @@ -23,9 +23,7 @@ use Test::Nginx; 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%% diff --git a/proxy_merge_headers.t b/proxy_merge_headers.t --- a/proxy_merge_headers.t +++ b/proxy_merge_headers.t @@ -21,9 +21,7 @@ use Test::Nginx; 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%% diff --git a/proxy_unfinished.t b/proxy_unfinished.t --- a/proxy_unfinished.t +++ b/proxy_unfinished.t @@ -31,9 +31,7 @@ use Test::Nginx; 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%% diff --git a/random_index.t b/random_index.t --- a/random_index.t +++ b/random_index.t @@ -21,9 +21,7 @@ use Test::Nginx; 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%% diff --git a/range_charset.t b/range_charset.t --- a/range_charset.t +++ b/range_charset.t @@ -22,9 +22,7 @@ use Test::Nginx; 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%% diff --git a/scgi_merge_params.t b/scgi_merge_params.t --- a/scgi_merge_params.t +++ b/scgi_merge_params.t @@ -23,9 +23,8 @@ select STDOUT; $| = 1; 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%% diff --git a/spdy.t b/spdy.t --- a/spdy.t +++ b/spdy.t @@ -33,10 +33,9 @@ eval { 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'); diff --git a/ssi.t b/ssi.t --- a/ssi.t +++ b/ssi.t @@ -21,9 +21,8 @@ use Test::Nginx; 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 @@ EOF 'XX'); $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', 'XX'); $t->write_file('unescape2.html', @@ -165,11 +164,17 @@ like(http_get('/test-empty-postpone.html # 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/;