Ignore:
Timestamp:
01/23/12 06:00:05 (4 months ago)
Author:
PaulHarvey
Message:

Item11431: Clean UnitTests of Foswiki->new/finish

Committing what was 96 commits rebased on top of Foswikirev:13781. You
can view this full commit history at
 https://github.com/csirac2/UnitTestContrib/commits/Item11431-rebased

Tackling memory leaks, this effort seems to have saved 300MB and 10
minutes from the cost of running a full FoswikiSuite.

The recipe was:

  • Find and remove all Foswiki->new/finish calls with $this->createNewFoswikiSession()
  • Generally removed $fatwilly variables and replaced with $this->{session}, to avoid references to ->finish()'d Foswiki singleton/session objects
  • Addressed perlcriticisms in touched files
  • Convert Foswiki::Meta->new/load to Foswiki::Func::readTopic, for the sake of store2 re-integration
  • Call $topicObject->finish() where/whenever we can

Some of the tests in the default plugins need a little work, and
there's some uncommitted stuff against core lib/Foswiki.pm to help
assert SINGLE_SINGLETONS from Foswiki::new/::finish subs, we'll get
to that later...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UnitTestContrib/test/unit/ConfigureTests.pm

    r13730 r13791  
    44use warnings; 
    55 
    6 use FoswikiTestCase; 
     6use FoswikiTestCase(); 
    77our @ISA = qw( FoswikiTestCase ); 
    88 
    99use Error qw( :try ); 
    10 use File::Temp; 
     10use File::Temp(); 
    1111use FindBin; 
    1212use File::Path qw(mkpath rmtree); 
     
    3232    $root =~ s|\\|/|g; 
    3333 
    34     $this->{rootdir}  = $root; 
    35     $this->{user}     = $Foswiki::cfg{AdminUserLogin}; 
    36     $this->{session}  = Foswiki->new( $this->{user} ); 
     34    $this->{rootdir} = $root; 
     35    $this->{user}    = $Foswiki::cfg{AdminUserLogin}; 
     36    $this->createNewFoswikiSession( $this->{user} ); 
    3737    $this->{test_web} = 'Testsystemweb1234'; 
    3838    my $webObject = Foswiki::Meta->new( $this->{session}, $this->{test_web} ); 
    3939    $webObject->populateNewWeb(); 
     40    $webObject->finish(); 
    4041    $this->{trash_web} = 'Testtrashweb1234'; 
    4142    $webObject = Foswiki::Meta->new( $this->{session}, $this->{trash_web} ); 
    4243    $webObject->populateNewWeb(); 
     44    $webObject->finish(); 
    4345    $this->{sandbox_web} = 'Testsandboxweb1234'; 
    4446    $webObject = Foswiki::Meta->new( $this->{session}, $this->{sandbox_web} ); 
    4547    $webObject->populateNewWeb(); 
     48    $webObject->finish(); 
    4649    $this->{sandbox_subweb} = 'Testsandboxweb1234/Subweb'; 
    4750    $webObject = 
    4851      Foswiki::Meta->new( $this->{session}, $this->{sandbox_subweb} ); 
    4952    $webObject->populateNewWeb(); 
     53    $webObject->finish(); 
    5054    $this->{tempdir} = $Foswiki::cfg{TempfileDir} . '/test_ConfigureTests'; 
    5155    rmtree( $this->{tempdir} ) 
     
    19261930    my ( $result, $err ) = $pkg->loadInstaller(); 
    19271931 
    1928     my $expected = <<HERE; 
     1932    my $expected = <<'HERE'; 
    19291933I can't download http://foswiki.org/pub/Extensions/EmptyPluginx/EmptyPluginx_installer because of the following error: 
    19301934Not Found 
Note: See TracChangeset for help on using the changeset viewer.