tests: Only skip HTTPD tests if dependencies are unavailable
This prevents the tests from passing due to syntax errors in the ddclient::t::HTTPD module.
This commit is contained in:
parent
ddeaedc136
commit
8cf322e162
10 changed files with 55 additions and 38 deletions
|
@ -87,6 +87,7 @@ m4_foreach_w([_m], [
|
||||||
# then some tests will fail. Only prints a warning if not installed.
|
# then some tests will fail. Only prints a warning if not installed.
|
||||||
m4_foreach_w([_m], [
|
m4_foreach_w([_m], [
|
||||||
B
|
B
|
||||||
|
Exporter
|
||||||
File::Spec::Functions
|
File::Spec::Functions
|
||||||
File::Temp
|
File::Temp
|
||||||
List::Util
|
List::Util
|
||||||
|
@ -100,7 +101,6 @@ m4_foreach_w([_m], [
|
||||||
# prints a warning if not installed.
|
# prints a warning if not installed.
|
||||||
m4_foreach_w([_m], [
|
m4_foreach_w([_m], [
|
||||||
Carp
|
Carp
|
||||||
Exporter
|
|
||||||
HTTP::Daemon=6.12
|
HTTP::Daemon=6.12
|
||||||
HTTP::Daemon::SSL
|
HTTP::Daemon::SSL
|
||||||
HTTP::Message::PSGI
|
HTTP::Message::PSGI
|
||||||
|
@ -112,6 +112,7 @@ m4_foreach_w([_m], [
|
||||||
Test::Warnings
|
Test::Warnings
|
||||||
Time::HiRes
|
Time::HiRes
|
||||||
URI
|
URI
|
||||||
|
parent
|
||||||
], [AX_PROG_PERL_MODULES([_m], [],
|
], [AX_PROG_PERL_MODULES([_m], [],
|
||||||
[AC_MSG_WARN([some tests may be skipped due to missing module _m])])])
|
[AC_MSG_WARN([some tests may be skipped due to missing module _m])])])
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
|
||||||
}
|
|
||||||
use ddclient::t::ip;
|
use ddclient::t::ip;
|
||||||
|
|
||||||
|
httpd_required();
|
||||||
|
|
||||||
$ddclient::globals{'ssl_ca_file'} = $ca_file;
|
$ddclient::globals{'ssl_ca_file'} = $ca_file;
|
||||||
|
|
||||||
for my $ipv ('4', '6') {
|
for my $ipv ('4', '6') {
|
||||||
|
|
|
@ -7,21 +7,42 @@ use warnings;
|
||||||
use parent qw(ddclient::Test::Fake::HTTPD);
|
use parent qw(ddclient::Test::Fake::HTTPD);
|
||||||
|
|
||||||
use Exporter qw(import);
|
use Exporter qw(import);
|
||||||
use JSON::PP;
|
|
||||||
use Test::More;
|
use Test::More;
|
||||||
BEGIN { require 'ddclient'; }
|
BEGIN { require 'ddclient'; }
|
||||||
use ddclient::t::ip;
|
use ddclient::t::ip;
|
||||||
|
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
httpd
|
httpd
|
||||||
|
httpd_ok httpd_required $httpd_supported $httpd_support_error
|
||||||
httpd_ipv6_ok httpd_ipv6_required $httpd_ipv6_supported $httpd_ipv6_support_error
|
httpd_ipv6_ok httpd_ipv6_required $httpd_ipv6_supported $httpd_ipv6_support_error
|
||||||
httpd_ssl_ok httpd_ssl_required $httpd_ssl_supported $httpd_ssl_support_error
|
httpd_ssl_ok httpd_ssl_required $httpd_ssl_supported $httpd_ssl_support_error
|
||||||
$ca_file $certdir $other_ca_file
|
$ca_file $certdir $other_ca_file
|
||||||
$textplain
|
$textplain
|
||||||
);
|
);
|
||||||
|
|
||||||
our $httpd_ssl_support_error;
|
our $httpd_supported;
|
||||||
our $httpd_ssl_supported = eval { require HTTP::Daemon::SSL; 1; } or $httpd_ssl_support_error = $@;
|
our $httpd_support_error;
|
||||||
|
BEGIN {
|
||||||
|
$httpd_supported = eval {
|
||||||
|
require parent; parent->import(qw(ddclient::Test::Fake::HTTPD));
|
||||||
|
require JSON::PP; JSON::PP->import();
|
||||||
|
1;
|
||||||
|
} or $httpd_support_error = $@;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub httpd_ok {
|
||||||
|
ok($httpd_supported, "HTTPD is supported") or diag($httpd_support_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub httpd_required {
|
||||||
|
plan(skip_all => $httpd_support_error) if !$httpd_supported;
|
||||||
|
}
|
||||||
|
|
||||||
|
our $httpd_ssl_supported = $httpd_supported;
|
||||||
|
our $httpd_ssl_support_error = $httpd_support_error;
|
||||||
|
$httpd_ssl_supported = eval { require HTTP::Daemon::SSL; 1; }
|
||||||
|
or $httpd_ssl_support_error = $@
|
||||||
|
if $httpd_ssl_supported;
|
||||||
|
|
||||||
sub httpd_ssl_ok {
|
sub httpd_ssl_ok {
|
||||||
ok($httpd_ssl_supported, "SSL is supported") or diag($httpd_ssl_support_error);
|
ok($httpd_ssl_supported, "SSL is supported") or diag($httpd_ssl_support_error);
|
||||||
|
@ -31,8 +52,11 @@ sub httpd_ssl_required {
|
||||||
plan(skip_all => $httpd_ssl_support_error) if !$httpd_ssl_supported;
|
plan(skip_all => $httpd_ssl_support_error) if !$httpd_ssl_supported;
|
||||||
}
|
}
|
||||||
|
|
||||||
our $httpd_ipv6_support_error;
|
our $httpd_ipv6_supported = $httpd_supported;
|
||||||
our $httpd_ipv6_supported = $ipv6_supported or $httpd_ipv6_support_error = $ipv6_support_error;
|
our $httpd_ipv6_support_error = $httpd_support_error;
|
||||||
|
$httpd_ipv6_supported = $ipv6_supported
|
||||||
|
or $httpd_ipv6_support_error = $ipv6_support_error
|
||||||
|
if $httpd_ipv6_supported;
|
||||||
$httpd_ipv6_supported = eval { require HTTP::Daemon; HTTP::Daemon->VERSION(6.12); }
|
$httpd_ipv6_supported = eval { require HTTP::Daemon; HTTP::Daemon->VERSION(6.12); }
|
||||||
or $httpd_ipv6_support_error = $@
|
or $httpd_ipv6_support_error = $@
|
||||||
if $httpd_ipv6_supported;
|
if $httpd_ipv6_supported;
|
||||||
|
@ -112,6 +136,7 @@ sub httpd {
|
||||||
my ($ipv, $ssl) = @_;
|
my ($ipv, $ssl) = @_;
|
||||||
$ipv //= '';
|
$ipv //= '';
|
||||||
$ssl = !!$ssl;
|
$ssl = !!$ssl;
|
||||||
|
return undef if !$httpd_supported;
|
||||||
return undef if $ipv eq '6' && !$httpd_ipv6_supported;
|
return undef if $ipv eq '6' && !$httpd_ipv6_supported;
|
||||||
return undef if $ssl && !$httpd_ssl_supported;
|
return undef if $ssl && !$httpd_ssl_supported;
|
||||||
if (!defined($daemons{$ipv}{$ssl})) {
|
if (!defined($daemons{$ipv}{$ssl})) {
|
||||||
|
|
|
@ -2,10 +2,9 @@ use Test::More;
|
||||||
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
||||||
BEGIN { eval { require JSON::PP; 1; } or plan(skip_all => $@); JSON::PP->import(); }
|
BEGIN { eval { require JSON::PP; 1; } or plan(skip_all => $@); JSON::PP->import(); }
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
httpd_required();
|
||||||
}
|
|
||||||
|
|
||||||
ddclient::load_json_support('directnic');
|
ddclient::load_json_support('directnic');
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@ use Test::More;
|
||||||
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
||||||
BEGIN { eval { require JSON::PP; 1; } or plan(skip_all => $@); JSON::PP->import(); }
|
BEGIN { eval { require JSON::PP; 1; } or plan(skip_all => $@); JSON::PP->import(); }
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
httpd_required();
|
||||||
}
|
|
||||||
|
|
||||||
ddclient::load_json_support('dnsexit2');
|
ddclient::load_json_support('dnsexit2');
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@ use Test::More;
|
||||||
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
||||||
use MIME::Base64;
|
use MIME::Base64;
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
httpd_required();
|
||||||
}
|
|
||||||
|
|
||||||
httpd()->run(sub {
|
httpd()->run(sub {
|
||||||
my ($req) = @_;
|
my ($req) = @_;
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
|
||||||
}
|
|
||||||
use ddclient::t::ip;
|
use ddclient::t::ip;
|
||||||
|
|
||||||
|
httpd_required();
|
||||||
|
|
||||||
httpd('4')->run(
|
httpd('4')->run(
|
||||||
sub { return [200, ['Content-Type' => 'text/plain'], ['127.0.0.1 skip 127.0.0.2']]; });
|
sub { return [200, ['Content-Type' => 'text/plain'], ['127.0.0.1 skip 127.0.0.2']]; });
|
||||||
httpd('6')->run(
|
httpd('6')->run(
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
|
||||||
}
|
|
||||||
use ddclient::t::ip;
|
use ddclient::t::ip;
|
||||||
|
|
||||||
local $ddclient::globals{debug} = 1;
|
local $ddclient::globals{debug} = 1;
|
||||||
local $ddclient::globals{verbose} = 1;
|
local $ddclient::globals{verbose} = 1;
|
||||||
|
|
||||||
|
httpd_required();
|
||||||
httpd_ssl_required();
|
httpd_ssl_required();
|
||||||
|
|
||||||
httpd('4', 1)->run(sub { return [200, $textplain, ['127.0.0.1']]; });
|
httpd('4', 1)->run(sub { return [200, $textplain, ['127.0.0.1']]; });
|
||||||
|
|
|
@ -6,12 +6,11 @@ BEGIN { eval { require JSON::PP; 1; } or plan(skip_all => $@); JSON::PP->import(
|
||||||
use List::Util qw(max);
|
use List::Util qw(max);
|
||||||
use Scalar::Util qw(refaddr);
|
use Scalar::Util qw(refaddr);
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
|
||||||
}
|
|
||||||
use ddclient::t::ip;
|
use ddclient::t::ip;
|
||||||
|
|
||||||
|
httpd_required();
|
||||||
|
|
||||||
httpd('4')->run();
|
httpd('4')->run();
|
||||||
httpd('6')->run() if httpd('6');
|
httpd('6')->run() if httpd('6');
|
||||||
local %ddclient::builtinweb = (
|
local %ddclient::builtinweb = (
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
BEGIN { SKIP: { eval { require Test::Warnings; 1; } or skip($@, 1); } }
|
||||||
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
BEGIN { eval { require 'ddclient'; } or BAIL_OUT($@); }
|
||||||
BEGIN {
|
use ddclient::t::HTTPD;
|
||||||
eval { require ddclient::t::HTTPD; 1; } or plan(skip_all => $@);
|
|
||||||
ddclient::t::HTTPD->import();
|
|
||||||
}
|
|
||||||
use ddclient::t::ip;
|
use ddclient::t::ip;
|
||||||
|
|
||||||
|
httpd_required();
|
||||||
|
|
||||||
my $builtinweb = 't/use_web.pl builtinweb';
|
my $builtinweb = 't/use_web.pl builtinweb';
|
||||||
my $h = 't/use_web.pl hostname';
|
my $h = 't/use_web.pl hostname';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue