This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix tests to be able to run in the core and the CPAN dist
[perl5.git] / lib / Net / t / nntp.t
1 #!./perl -w
2
3 BEGIN {
4     unless (-d 'blib') {
5         chdir 't' if -d 't';
6         @INC = '../lib';
7     }
8 }
9
10 use Net::Config;
11 use Net::NNTP;
12 use Net::Cmd qw(CMD_REJECT);
13
14 unless(@{$NetConfig{nntp_hosts}} && $NetConfig{test_hosts}) {
15     print "1..0\n";
16     exit;
17 }
18
19 print "1..4\n";
20
21 my $i = 1;
22
23 $nntp = Net::NNTP->new(Debug => 0)
24         or (print("not ok 1\n"), exit);
25
26 print "ok 1\n";
27
28 my $grp;
29 foreach $grp (qw(test alt.test control news.announce.newusers)) {
30     @grp = $nntp->group($grp);
31     last if @grp;
32 }
33
34 if($nntp->status == CMD_REJECT) {
35     # Command was rejected, probably because we need authinfo
36     map { print "ok ",$_,"\n" } 2,3,4;
37     exit;
38 }
39
40 print "not " unless @grp;
41 print "ok 2\n";
42
43
44 if(@grp && $grp[2] > $grp[1]) {
45     $nntp->head($grp[1]) or print "not ";
46 }
47 print "ok 3\n";
48
49 if(@grp) {
50     $nntp->quit or print "not ";
51 }
52 print "ok 4\n";
53