Mercurial > hg > nginx-tests
diff lib/Test/Nginx.pm @ 592:355f2d5ff60f
Tests: catch nginx alerts on exit.
The new todo_alerts() function is used to mark such a test as TODO.
Notably, proxy_if.t is currently expected to produce alerts.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 27 May 2015 16:58:35 +0300 |
parents | 2cd00179f4b2 |
children | 3a9a7b4f27f0 |
line wrap: on
line diff
--- a/lib/Test/Nginx.pm Tue May 26 19:35:36 2015 +0300 +++ b/lib/Test/Nginx.pm Wed May 27 16:58:35 2015 +0300 @@ -36,6 +36,7 @@ bless $self; $self->{_pid} = $$; + $self->{_alerts} = 1; $self->{_testdir} = tempdir( 'nginx-test-XXXXXXXXXX', @@ -61,6 +62,14 @@ $self->stop(); $self->stop_daemons(); + if (Test::More->builder->expected_tests) { + local $Test::Nginx::TODO = 'alerts' unless $self->{_alerts}; + + my $alerts = $self->read_file('error.log'); + $alerts = join "\n", $alerts =~ /.+\[alert\].+/gm; + Test::More::is($alerts, '', 'no alerts'); + } + if ($ENV{TEST_NGINX_CATLOG}) { system("cat $self->{_testdir}/error.log"); } @@ -223,7 +232,15 @@ sub plan($) { my ($self, $plan) = @_; - Test::More::plan(tests => $plan); + Test::More::plan(tests => $plan + 1); + + return $self; +} + +sub todo_alerts() { + my ($self) = @_; + + $self->{_alerts} = 0; return $self; }