Skip to content

Commit

Permalink
test suite update
Browse files Browse the repository at this point in the history
  • Loading branch information
barbie committed Dec 23, 2012
1 parent 73e298a commit 694e951
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 25 deletions.
31 changes: 18 additions & 13 deletions t/50logging.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@
use strict;
use warnings;

use Test::More tests => 22;
use Cwd;
use File::Path;
use File::Slurp;
use File::Spec;
use Cwd;
use IO::File;
use Test::More tests => 22;

use lib 't';
use CTWS_Testing;

unlink('50logging.log') if(-f '50logging.log');
my $LOG = '50logging.log';

unlink($LOG) if(-f $LOG);

{
ok( my $obj = CTWS_Testing::getObj(config => 't/50logging.ini'), "got object" );

is($obj->logfile, '50logging.log', 'logfile default set');
is($obj->logfile, $LOG, 'logfile default set');
is($obj->logclean, 0, 'logclean default set');

$obj->_log("Hello");
$obj->_log("Goodbye");

ok( -f '50logging.log', '50logging.log created in current dir' );
ok( -f $LOG, '50logging.log created in current dir' );

my @log = do { open FILE, '<', '50logging.log'; <FILE> };
my @log = read_file($LOG);
chomp @log;

is(scalar(@log),12, 'log written');
Expand All @@ -34,14 +39,14 @@ unlink('50logging.log') if(-f '50logging.log');
{
ok( my $obj = CTWS_Testing::getObj(config => 't/50logging.ini'), "got object" );

is($obj->logfile, '50logging.log', 'logfile default set');
is($obj->logfile, $LOG, 'logfile default set');
is($obj->logclean, 0, 'logclean default set');

$obj->_log("Back Again");

ok( -f '50logging.log', '50logging.log created in current dir' );
ok( -f $LOG, '50logging.log created in current dir' );

my @log = do { open FILE, '<', '50logging.log'; <FILE> };
my @log = read_file($LOG);
chomp @log;

is(scalar(@log),23, 'log extended');
Expand All @@ -53,20 +58,20 @@ unlink('50logging.log') if(-f '50logging.log');
{
ok( my $obj = CTWS_Testing::getObj(config => 't/50logging.ini'), "got object" );

is($obj->logfile, '50logging.log', 'logfile default set');
is($obj->logfile, $LOG, 'logfile default set');
is($obj->logclean, 0, 'logclean default set');
$obj->logclean(1);
is($obj->logclean, 1, 'logclean reset');

$obj->_log("Start Again");

ok( -f '50logging.log', '50logging.log created in current dir' );
ok( -f $LOG, '50logging.log created in current dir' );

my @log = do { open FILE, '<', '50logging.log'; <FILE> };
my @log = read_file($LOG);
chomp @log;

is(scalar(@log),1, 'log overwritten');
like($log[0], qr!\d{4}/\d\d/\d\d \d\d:\d\d:\d\d Start Again!, 'line 1 of log');
}

unlink('50logging.log');
unlink($LOG);
25 changes: 14 additions & 11 deletions t/56writes.t
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,16 @@ SKIP: {
CTWS_Testing::saveFiles($dir . '/graphs');

$obj->directory($dir . '/graphs'),
$graph->create();
check_dir_contents(
"[graphs]",
$obj->directory,
File::Spec->catfile($EXPECTEDPATH,'56writes.graphs'),
);
ok( CTWS_Testing::cleanDir($obj), 'directory cleaned' );
my $status = $graph->create();
SKIP: {
skip "Google Chart API returned an error", 10 if($status);
check_dir_contents(
"[graphs]",
$obj->directory,
File::Spec->catfile($EXPECTEDPATH,'56writes.graphs'),
);
}
ok( CTWS_Testing::cleanDir($obj), 'directory cleaned' );
};

#---------------------------------------
Expand All @@ -256,17 +259,17 @@ SKIP: {
#);
#ok( CTWS_Testing::cleanDir($obj), 'directory cleaned' );


SKIP: {
skip "Can't see a network connection", 18 if(pingtest($CHECK_DOMAIN));

CTWS_Testing::saveFiles($dir . '/make_graphs');

my $status;
$obj->directory($dir . '/make_graphs');
eval { $obj->make_graphs() };
eval { $status = $obj->make_graphs() };

SKIP: {
skip "could not retrieve graphs", 1 if($@ =~ /- (request failed|Cannot access page) -/);
skip "Google Chart API returned an error", 10 if($@ =~ /- (request failed|Cannot access page) -/ || $status);
check_dir_contents(
"[make_graphs]",
$obj->directory,
Expand Down Expand Up @@ -347,7 +350,7 @@ sub check_dir_contents {
$_[0] =~ s!\(\d{2}/\d{2}\)!(==TIMESTAMP==)!gmi;
# $_[0] =~ s!\d{2}/\d{2}!==TIMESTAMP==!gmi;
$_[0] =~ s!\w+ \d{4}!==TIMESTAMP==!gmi;
$_[0] =~ s!CPAN-Testers-WWW-Statistics-0.\d{2}!==DISTRO==!gmi;
$_[0] =~ s!CPAN-Testers-WWW-Statistics-\d.\d{2}!==DISTRO==!gmi;
$_[0] =~ s/\d{4}\s*\-\s*\d{4}/==DATERANGE==/gmi;
}
$_[0];
Expand Down
4 changes: 3 additions & 1 deletion t/90podtest.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/perl -w
use strict;

use Test::More;

# Skip if doing a regular install
Expand All @@ -7,4 +10,3 @@ plan skip_all => "Author tests not required for installation"
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();

3 changes: 3 additions & 0 deletions t/91podcover.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/perl -w
use strict;

use Test::More;

# Skip if doing a regular install
Expand Down

0 comments on commit 694e951

Please sign in to comment.