Mercurial > hg > nginx-tests
changeset 27:fb94a224fef2
Tests: add has() functions for feature testing.
Currently it just skips all tests if feature not found in nginx -V output.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 10 Oct 2008 20:09:14 +0400 |
parents | 0880e0fafde4 |
children | 8f1519472ece |
files | lib/Test/Nginx.pm smtp-greeting-delay.t smtp.t |
diffstat | 3 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/Test/Nginx.pm Thu Oct 02 16:18:11 2008 +0400 +++ b/lib/Test/Nginx.pm Fri Oct 10 20:09:14 2008 +0400 @@ -18,9 +18,12 @@ use File::Temp qw/ tempdir /; use IO::Socket; use Socket qw/ CRLF /; +use Test::More qw//; ############################################################################### +our $NGINX = '../nginx/objs/nginx'; + sub new { my $self = {}; bless $self; @@ -40,6 +43,13 @@ $self->stop(); } +sub has { + my ($self, $feature, %options) = @_; + Test::More::plan(skip_all => "$feature not compiled in") + unless `$NGINX -V 2>&1` =~ $feature; + Test::More::plan($options{plan}) if defined $options{plan}; +} + sub run { my ($self, $conf) = @_; @@ -54,7 +64,7 @@ die "Unable to fork(): $!\n" unless defined $pid; if ($pid == 0) { - exec('../nginx/objs/nginx', '-c', "$testdir/nginx.conf", '-g', + exec($NGINX, '-c', "$testdir/nginx.conf", '-g', "pid $testdir/nginx.pid; " . "error_log $testdir/error.log debug;") or die "Unable to exec(): $!\n";
--- a/smtp-greeting-delay.t Thu Oct 02 16:18:11 2008 +0400 +++ b/smtp-greeting-delay.t Fri Oct 10 20:09:14 2008 +0400 @@ -7,7 +7,7 @@ use warnings; use strict; -use Test::More tests => 2; +use Test::More; use MIME::Base64; use Socket qw/ CRLF /; @@ -23,7 +23,8 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->write_file_expand('nginx.conf', <<'EOF')->run(); +my $t = Test::Nginx->new()->has('mail', plan => 2) + ->write_file_expand('nginx.conf', <<'EOF')->run(); master_process off; daemon off;
--- a/smtp.t Thu Oct 02 16:18:11 2008 +0400 +++ b/smtp.t Fri Oct 10 20:09:14 2008 +0400 @@ -9,7 +9,7 @@ use warnings; use strict; -use Test::More tests => 26; +use Test::More; use MIME::Base64; use Socket qw/ CRLF /; @@ -26,6 +26,7 @@ select STDOUT; $| = 1; my $t = Test::Nginx->new() + ->has('mail', plan => 26) ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon) ->write_file_expand('nginx.conf', <<'EOF')->run();