Mercurial > hg > nginx-tests
comparison lib/Test/Nginx.pm @ 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 | 5c3946ebd867 |
children | 355f2d5ff60f |
comparison
equal
deleted
inserted
replaced
573:517cde5075d8 | 574:2cd00179f4b2 |
---|---|
71 | 71 |
72 sub has($;) { | 72 sub has($;) { |
73 my ($self, @features) = @_; | 73 my ($self, @features) = @_; |
74 | 74 |
75 foreach my $feature (@features) { | 75 foreach my $feature (@features) { |
76 Test::More::plan(skip_all => "$feature not compiled in") | 76 Test::More::plan(skip_all => "no $feature available") |
77 unless $self->has_module($feature); | 77 unless $self->has_module($feature) |
78 or $self->has_feature($feature); | |
78 } | 79 } |
79 | 80 |
80 return $self; | 81 return $self; |
81 } | 82 } |
82 | 83 |
150 if !defined $self->{_configure_args}; | 151 if !defined $self->{_configure_args}; |
151 | 152 |
152 return ($self->{_configure_args} =~ $re) ? 1 : 0; | 153 return ($self->{_configure_args} =~ $re) ? 1 : 0; |
153 } | 154 } |
154 | 155 |
156 sub has_feature($) { | |
157 my ($self, $feature) = @_; | |
158 | |
159 if ($feature eq 'symlink') { | |
160 return $^O ne 'MSWin32'; | |
161 } | |
162 | |
163 if ($feature eq 'shmem') { | |
164 return $^O ne 'MSWin32' || $self->has_version('1.9.0'); | |
165 } | |
166 | |
167 return 0; | |
168 } | |
169 | |
155 sub has_version($) { | 170 sub has_version($) { |
156 my ($self, $need) = @_; | 171 my ($self, $need) = @_; |
157 | 172 |
158 $self->{_configure_args} = `$NGINX -V 2>&1` | 173 $self->{_configure_args} = `$NGINX -V 2>&1` |
159 if !defined $self->{_configure_args}; | 174 if !defined $self->{_configure_args}; |