Skip to content

Commit

Permalink
Item10963: perltidy everything I just modified
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x01@12160 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed Jul 13, 2011
1 parent de2ef43 commit 0c90b02
Show file tree
Hide file tree
Showing 18 changed files with 968 additions and 758 deletions.
397 changes: 229 additions & 168 deletions BuildContrib/lib/Foswiki/Contrib/Build.pm

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions UnitTestContrib/test/unit/Fn_REVINFO.pm
Expand Up @@ -309,13 +309,16 @@ OFNIVER
$x = Foswiki::Time::formatTime( $t, $Foswiki::cfg{DefaultDateFormat} );
$y = $topicObject->expandMacros('%REVINFO{"$date"}%');

foreach my $f (qw(rcs http email iso longdate sec min hou day wday
dow week mo ye epoch tz)) {
foreach my $f (
qw(rcs http email iso longdate sec min hou day wday
dow week mo ye epoch tz)
)
{
my $tf = '$' . $f;
$x = Foswiki::Time::formatTime( $t, $tf );
$y = $topicObject->expandMacros("%REVINFO{\"$tf\"}%");
$this->assert_str_equals( $x, $y );
};
$x = Foswiki::Time::formatTime( $t, $tf );
$y = $topicObject->expandMacros("%REVINFO{\"$tf\"}%");
$this->assert_str_equals( $x, $y );
}
}

# test for combinations of format strings
Expand Down
59 changes: 31 additions & 28 deletions UnitTestContrib/test/unit/Logger.pm
Expand Up @@ -15,9 +15,9 @@ our $logDir;

sub set_up {
my $this = shift;
delete $Foswiki::cfg{LogFileName} ;
delete $Foswiki::cfg{DebugFileName} ;
delete $Foswiki::cfg{WarningFileName} ;
delete $Foswiki::cfg{LogFileName};
delete $Foswiki::cfg{DebugFileName};
delete $Foswiki::cfg{WarningFileName};
$this->SUPER::set_up();
$logDir = "logDir$$";
$Foswiki::cfg{Log}{Dir} = "$logDir";
Expand All @@ -27,18 +27,18 @@ sub set_up {
sub tear_down {
my $this = shift;

File::Path::rmtree( $logDir );
File::Path::rmtree($logDir);
$this->SUPER::tear_down();
}

sub CompatibilityLogger {
my $this = shift;
require Foswiki::Logger::Compatibility;
$Foswiki::cfg{Log}{Implementation} = 'Foswiki::Logger::Compatibility';
$this->{logger} = new Foswiki::Logger::Compatibility();
$Foswiki::cfg{LogFileName} = "$logDir/logfile%DATE%";
$Foswiki::cfg{DebugFileName} = "$logDir/debug%DATE%";
$Foswiki::cfg{WarningFileName} = "$logDir/warn%DATE%!!";
$this->{logger} = new Foswiki::Logger::Compatibility();
$Foswiki::cfg{LogFileName} = "$logDir/logfile%DATE%";
$Foswiki::cfg{DebugFileName} = "$logDir/debug%DATE%";
$Foswiki::cfg{WarningFileName} = "$logDir/warn%DATE%!!";
}

sub PlainFileLogger {
Expand Down Expand Up @@ -92,9 +92,9 @@ sub verify_eachEventSinceOnEmptyLog {
my $this = shift;
foreach my $level (qw(debug info warning)) {
my $it = $this->{logger}->eachEventSince( 0, $level );
if ($it->hasNext()) {
if ( $it->hasNext() ) {
use Data::Dumper;
die Data::Dumper->Dump([$it->next()]);
die Data::Dumper->Dump( [ $it->next() ] );
}
$this->assert( !$it->hasNext() );
}
Expand Down Expand Up @@ -189,20 +189,21 @@ sub verify_filter {
$this->assert( !$it->hasNext() );
}

my $mode; # access mode
my $mtime; # modify time
my $mode; # access mode
my $mtime; # modify time

sub PlainFileTestStat {
return (0, 0, $mode, 0, 0, 0, 0, 99, 0, $mtime, 0, 0, 0, 0);
return ( 0, 0, $mode, 0, 0, 0, 0, 99, 0, $mtime, 0, 0, 0, 0 );
}

sub verify_rotate {
my $this = shift;

return unless
$Foswiki::cfg{Log}{Implementation} eq 'Foswiki::Logger::PlainFile';
return
unless $Foswiki::cfg{Log}{Implementation} eq 'Foswiki::Logger::PlainFile';

my $timecache = \&Foswiki::Logger::PlainFile::_time;
my $statcache = \&Foswiki::Logger::PlainFile::_stat;
my $timecache = \&Foswiki::Logger::PlainFile::_time;
my $statcache = \&Foswiki::Logger::PlainFile::_stat;
no warnings 'redefine';
*Foswiki::Logger::PlainFile::_time = \&PlainFileTestTime;
*Foswiki::Logger::PlainFile::_stat = \&PlainFileTestStat;
Expand All @@ -212,46 +213,48 @@ sub verify_rotate {
my $then = Foswiki::Time::parseTime("2000-02-01");

$plainFileTestTime = $then;
$mode = 0777;
$mode = 0777;

# Don't try to rotate a non-existant log
my $lfn = "$Foswiki::cfg{Log}{Dir}/events.log";

my $logger = new Foswiki::Logger::PlainFile();
$this->assert(! -e $lfn);
$this->assert( !-e $lfn );
$logger->_rotate($plainFileTestTime);
$this->assert(! -e $lfn);
$this->assert( !-e $lfn );

# Create the log, the entry should be stamped at $then - 1000 (last month)
$plainFileTestTime = $then - 1000;
$logger->log('info', 'Nil carborundum illegitami');
$logger->log( 'info', 'Nil carborundum illegitami' );

# fake the modify time
$mtime = $plainFileTestTime;

$Foswiki::Logger::PlainFile::dontRotate = 0;
$Foswiki::Logger::PlainFile::dontRotate = 0;
$Foswiki::Logger::PlainFile::nextCheckDue = $then;

# now advance the clock to this month, and add another log entry. This
# should rotate the log.
$plainFileTestTime = $then;
$logger->log('info', 'Salve nauta');
$logger->log( 'info', 'Salve nauta' );

local $/ = undef;
$this->assert(open(F, '<', $lfn));
$this->assert( open( F, '<', $lfn ) );
my $e = <F>;
$this->assert_equals("| 2000-02-01T00:00:00Z info | Salve nauta |\n", $e);
$this->assert_equals( "| 2000-02-01T00:00:00Z info | Salve nauta |\n", $e );
close(F);

# We should see the creation of a backup log with
# the last-month entry, and the current log should be cut down to
# this month's entry.
my $backup = $lfn;
$backup =~ s/log$/200001/;
$this->assert(-e $backup);
$this->assert( -e $backup );

$this->assert(open(F, '<', $backup));
$this->assert( open( F, '<', $backup ) );
$e = <F>;
$this->assert_equals("| 2000-01-31T23:43:20Z info | Nil carborundum illegitami |\n", $e);
$this->assert_equals(
"| 2000-01-31T23:43:20Z info | Nil carborundum illegitami |\n", $e );
close(F);

*Foswiki::Logger::PlainFile::_time = $timecache;
Expand Down
36 changes: 18 additions & 18 deletions UnitTestContrib/test/unit/RobustnessTests.pm
Expand Up @@ -51,22 +51,22 @@ sub test_validateAttachmentName {
$this->assert_str_equals( "abc",
Foswiki::Sandbox::validateAttachmentName("//abc") );

$this->assert_str_equals(
"", Foswiki::Sandbox::validateAttachmentName("c/.."));
$this->assert_str_equals( "",
Foswiki::Sandbox::validateAttachmentName("c/..") );

$this->assert_null(Foswiki::Sandbox::validateAttachmentName("../a"));
$this->assert_null( Foswiki::Sandbox::validateAttachmentName("../a") );

$this->assert_null(Foswiki::Sandbox::validateAttachmentName("/a/../.."));
$this->assert_str_equals(
"a", Foswiki::Sandbox::validateAttachmentName("//a/b/c/../..") );
$this->assert_null( Foswiki::Sandbox::validateAttachmentName("/a/../..") );
$this->assert_str_equals( "a",
Foswiki::Sandbox::validateAttachmentName("//a/b/c/../..") );
$this->assert_str_equals( "..a",
Foswiki::Sandbox::validateAttachmentName("..a/") );
$this->assert_str_equals( "a/..b",
Foswiki::Sandbox::validateAttachmentName("a/..b") );
}

sub _shittify {
my ($a, $b) = Foswiki::Sandbox::sanitizeAttachmentName(shift);
my ( $a, $b ) = Foswiki::Sandbox::sanitizeAttachmentName(shift);
return $a;
}

Expand All @@ -83,7 +83,7 @@ sub test_sanitizeAttachmentName {
# Check that "certain characters" are munched
my $crap = '';
$Foswiki::cfg{UseLocale} = 0;
for (0..255) {
for ( 0 .. 255 ) {
my $c = chr($_);
$crap .= $c if $c =~ /$Foswiki::regex{filenameInvalidCharRegex}/;
}
Expand All @@ -93,7 +93,7 @@ sub test_sanitizeAttachmentName {

$crap = '';
$Foswiki::cfg{UseLocale} = 1;
for (0..255) {
for ( 0 .. 255 ) {
my $c = chr($_);
$crap .= $c if $c =~ /$Foswiki::cfg{NameFilter}/;
}
Expand All @@ -102,8 +102,7 @@ sub test_sanitizeAttachmentName {
_shittify("pick me${crap}pick me") );

# Check that the upload filter is applied.
$Foswiki::cfg{UploadFilter} =
qr(^(
$Foswiki::cfg{UploadFilter} = qr(^(
\.htaccess
| .*\.(?i)(?:php[0-9s]?(\..*)?
| [sp]htm[l]?(\..*)?
Expand Down Expand Up @@ -139,7 +138,8 @@ sub test_buildCommandLine {
]
);
$this->assert_deep_equals(
#unfortuanatly, buildCommandLine cleans up paths using File::Spec, which thus uses \\ on some win32's (strawberry for eg)

#unfortuanatly, buildCommandLine cleans up paths using File::Spec, which thus uses \\ on some win32's (strawberry for eg)
[ 1, "./-..", "a${slash}b" ],
[
Foswiki::Sandbox::_buildCommandLine(
Expand Down Expand Up @@ -175,7 +175,8 @@ sub test_buildCommandLine {
)
]
);
#unfortuanatly, buildCommandLine cleans up paths using File::Spec, which thus uses \\ on some win32's (strawberry for eg)

#unfortuanatly, buildCommandLine cleans up paths using File::Spec, which thus uses \\ on some win32's (strawberry for eg)
$this->assert_deep_equals(
[ "a", "b", "${slash}c" ],
[
Expand Down Expand Up @@ -237,31 +238,30 @@ sub verify {
Foswiki::Sandbox->sysCommand( 'sh -c %A%', A => 'echo urmf; exit 7' );
$this->assert( $exit != 0 );
$this->assert_str_equals( "urmf\n", $out );
( $out, $exit ) =
Foswiki::Sandbox->sysCommand( 'echo' );
( $out, $exit ) = Foswiki::Sandbox->sysCommand('echo');
$this->assert_equals( 0, $exit );
$this->assert_str_equals( `echo`, $out );
}

sub test_executeRSP {
my $this = shift;
return if ($^O eq 'MSWin32');
return if ( $^O eq 'MSWin32' );
$Foswiki::Sandbox::REAL_SAFE_PIPE_OPEN = 1;
$Foswiki::Sandbox::EMULATED_SAFE_PIPE_OPEN = 0;
$this->verify();
}

sub test_executeESP {
my $this = shift;
return if ($^O eq 'MSWin32');
return if ( $^O eq 'MSWin32' );
$Foswiki::Sandbox::REAL_SAFE_PIPE_OPEN = 0;
$Foswiki::Sandbox::EMULATED_SAFE_PIPE_OPEN = 1;
$this->verify();
}

sub test_executeNSP {
my $this = shift;
return if ($^O eq 'MSWin32');
return if ( $^O eq 'MSWin32' );
$Foswiki::Sandbox::REAL_SAFE_PIPE_OPEN = 0;
$Foswiki::Sandbox::EMULATED_SAFE_PIPE_OPEN = 0;
$this->verify();
Expand Down

0 comments on commit 0c90b02

Please sign in to comment.