Skip to content

Commit

Permalink
Remove t/libnet_t.pl
Browse files Browse the repository at this point in the history
Use the Test::More versions of the subroutines provided by this script,
removing the need for it at all.

Based on a patch by jkeenan in PR#39.

Also add missing skip messages, and add missing skips in ipv6 and ssl test
scripts.
  • Loading branch information
steve-m-hay committed Nov 28, 2020
1 parent 25ba79a commit 1e76e0d
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 96 deletions.
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ t/external/pop3-ssl.t Test script
t/external/smtp-ssl.t Test script
t/ftp.t Test script
t/hostname.t Test script
t/libnet_t.pl Test script
t/netrc.t Test script
t/nntp.t Test script
t/nntp_ipv6.t Test script
Expand Down
21 changes: 11 additions & 10 deletions t/config.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # no Socket\n"; exit 0;
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
else {
plan tests => 10;
}

undef *{Socket::inet_aton};
undef *{Socket::inet_ntoa};
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
}
$INC{'Socket.pm'} = 1;
}

Expand Down Expand Up @@ -45,13 +51,8 @@ sub inet_ntoa {
return $names{$_[0]};
}

package main;


(my $libnet_t = __FILE__) =~ s/config.t/libnet_t.pl/;
require $libnet_t;

print "1..10\n";
package main;

use Net::Config;
ok( exists $INC{'Net/Config.pm'}, 'Net::Config should have been used' );
Expand Down
16 changes: 8 additions & 8 deletions t/datasend.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # no Socket\n"; exit 0;
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
else {
plan tests => 54;
}
}

Expand Down Expand Up @@ -41,11 +46,6 @@ BEGIN {
}
}

(my $libnet_t = __FILE__) =~ s/datasend.t/libnet_t.pl/;
require $libnet_t or die;

print "1..54\n";

sub check {
my $expect = pop;
my $cmd = Foo->new;
Expand Down
2 changes: 1 addition & 1 deletion t/ftp.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use warnings;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # Skip: no Socket module\n"; exit 0;
print "1..0 # Skip: no Socket\n"; exit 0;
}
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # Skip: EBCDIC but no Convert::EBCDIC\n"; exit 0;
Expand Down
6 changes: 3 additions & 3 deletions t/hostname.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ use warnings;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # no Socket\n"; exit 0;
print "1..0 # Skip: no Socket\n"; exit 0;
}
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
print "1..0 # Skip: EBCDIC but no Convert::EBCDIC\n"; exit 0;
}
}

use Net::Domain qw(hostname domainname hostdomain hostfqdn);
use Net::Config;

unless($NetConfig{test_hosts}) {
print "1..0\n";
print "1..0 # Skip: test_hosts not enabled in config\n";
exit 0;
}

Expand Down
41 changes: 0 additions & 41 deletions t/libnet_t.pl

This file was deleted.

15 changes: 8 additions & 7 deletions t/netrc.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # no Socket\n"; exit 0;
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
else {
plan tests => 20;
}
}

use Cwd;
print "1..20\n";

# for testing _readrc
$ENV{HOME} = Cwd::cwd();
Expand All @@ -36,9 +40,6 @@ my @stat;
# for testing _readrc
$INC{'FileHandle.pm'} = 1;

(my $libnet_t = __FILE__) =~ s/\w+.t$/libnet_t.pl/;
require $libnet_t;

# now that the tricks are out of the way...
eval { require Net::Netrc; };
ok( !$@, 'should be able to require() Net::Netrc safely' );
Expand Down
13 changes: 9 additions & 4 deletions t/nntp.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ use warnings;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # no Socket\n"; exit 0;
print "1..0 # Skip: no Socket\n"; exit 0;
}
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
print "1..0 # Skip: EBCDIC but no Convert::EBCDIC\n"; exit 0;
}
}

use Net::Config;
use Net::NNTP;
use Net::Cmd qw(CMD_REJECT);

unless(@{$NetConfig{nntp_hosts}} && $NetConfig{test_hosts}) {
print "1..0\n";
unless(@{$NetConfig{nntp_hosts}}) {
print "1..0 # Skip: no nntp_hosts defined in config\n";
exit;
}

unless($NetConfig{test_hosts}) {
print "1..0 # Skip: test_hosts not enabled in config\n";
exit;
}

Expand Down
12 changes: 11 additions & 1 deletion t/nntp_ipv6.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
}

use Config;
use File::Temp 'tempfile';
use Net::NNTP;
use Test::More;

my $debug = 0; # Net::NNTP->new( Debug => .. )

Expand Down
12 changes: 11 additions & 1 deletion t/nntp_ssl.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
}

use Config;
use File::Temp 'tempfile';
use Net::NNTP;
use Test::More;

my $debug = 0; # Net::NNTP Debug => ..

Expand Down
8 changes: 7 additions & 1 deletion t/pod_coverage.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Test script to check POD coverage.
#
# COPYRIGHT
# Copyright (C) 2014, 2015 Steve Hay. All rights reserved.
# Copyright (C) 2014, 2015, 2020 Steve Hay. All rights reserved.
#
# LICENCE
# This script is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -43,6 +43,12 @@ MAIN: {
elsif ($Test::Pod::Coverage::VERSION < 0.08) {
plan skip_all => 'Test::Pod::Coverage 0.08 or higher required to test POD coverage';
}
elsif (!eval { require Socket }) {
plan skip_all => 'no Socket';
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => 'EBCDIC but no Convert::EBCDIC';
}
else {
plan tests => 12;
my $params = { coverage_class => qw(Pod::Coverage::CountParents) };
Expand Down
12 changes: 11 additions & 1 deletion t/pop3_ipv6.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
}

use Config;
use File::Temp 'tempfile';
use Net::POP3;
use Test::More;

my $debug = 0; # Net::POP3->new( Debug => .. )

Expand Down
12 changes: 11 additions & 1 deletion t/pop3_ssl.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
}

use Config;
use File::Temp 'tempfile';
use Net::POP3;
use Test::More;

my $debug = 0; # Net::POP3 Debug => ..

Expand Down
4 changes: 2 additions & 2 deletions t/require.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use warnings;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # no Socket\n"; exit 0;
print "1..0 # Skip: no Socket\n"; exit 0;
}
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
print "1..0 # Skip: EBCDIC but no Convert::EBCDIC\n"; exit 0;
}
}

Expand Down
15 changes: 10 additions & 5 deletions t/smtp.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ use warnings;

BEGIN {
if (!eval { require Socket }) {
print "1..0 # no Socket\n"; exit 0;
print "1..0 # Skip: no Socket\n"; exit 0;
}
if (ord('A') == 193 && eval { require Convert::EBCDIC }) {
print "1..0 # EBCDIC but no Convert::EBCDIC\n"; exit 0;
if (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
print "1..0 # Skip: EBCDIC but no Convert::EBCDIC\n"; exit 0;
}
}

use Net::Config;
use Net::SMTP;

unless(@{$NetConfig{smtp_hosts}} && $NetConfig{test_hosts}) {
print "1..0\n";
unless(@{$NetConfig{smtp_hosts}}) {
print "1..0 # Skip: no smtp_hosts defined in config\n";
exit 0;
}

unless($NetConfig{test_hosts}) {
print "1..0 # Skip: test_hosts not enabled in config\n";
exit 0;
}

Expand Down
12 changes: 11 additions & 1 deletion t/smtp_ipv6.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ use 5.008001;
use strict;
use warnings;

use Test::More;

BEGIN {
if (!eval { require Socket }) {
plan skip_all => "no Socket";
}
elsif (ord('A') == 193 && !eval { require Convert::EBCDIC }) {
plan skip_all => "EBCDIC but no Convert::EBCDIC";
}
}

use Config;
use File::Temp 'tempfile';
use Net::SMTP;
use Test::More;

my $debug = 0; # Net::SMTP->new( Debug => .. )

Expand Down
Loading

0 comments on commit 1e76e0d

Please sign in to comment.