Mercurial > hg > nginx-tests
comparison lib/Test/Nginx.pm @ 392:c28ecaef065f
Tests: try_run() introduced.
This method replaces multiple ad-hoc solutions to grecefully skip tests if
nginx startup fails, e.g., due to no support for a particular directive.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 18 Apr 2014 18:36:26 +0400 |
parents | 5fdde9f755c9 |
children | d7d9b4367bab |
comparison
equal
deleted
inserted
replaced
391:915ef26ac6eb | 392:c28ecaef065f |
---|---|
170 unless `which $daemon`; | 170 unless `which $daemon`; |
171 | 171 |
172 return $self; | 172 return $self; |
173 } | 173 } |
174 | 174 |
175 sub try_run($$) { | |
176 my ($self, $message) = @_; | |
177 | |
178 eval { | |
179 open OLDERR, ">&", \*STDERR; close STDERR; | |
180 $self->run(); | |
181 open STDERR, ">&", \*OLDERR; | |
182 }; | |
183 | |
184 Test::More::plan(skip_all => $message) if $@; | |
185 return $self; | |
186 } | |
187 | |
175 sub plan($) { | 188 sub plan($) { |
176 my ($self, $plan) = @_; | 189 my ($self, $plan) = @_; |
177 | 190 |
178 Test::More::plan(tests => $plan); | 191 Test::More::plan(tests => $plan); |
179 | 192 |