Add a new method to t/lib/WebGUI/Test.pm to return the path to the test

collateral.
Update all tests to use the new method.
Change testCodebase.pl to run long tests by default.  To disable the
long tests, use the --noLongTests switch.
This commit is contained in:
Colin Kuskie 2006-12-15 23:17:22 +00:00
parent 40e3967b19
commit 9d0894b674
6 changed files with 55 additions and 29 deletions

View file

@ -3,6 +3,10 @@
- fix: Miscellaneous Calendar template fixes
- fix: Cannot manageAssets with a locked Thread -- NOTE: Kludgy, but any other
way would probably have to break API.
- t/lib/WebGUI/Test.pm now has a method for returning the path to the
test collateral directory. The method is called getTestCollateralPath.
Existing tests using that directory have been modified to use the new
method instead of finding the path manually.
7.3.1
- Fixed a problem with IE and resizable text areas that caused IE to crash

View file

@ -7,6 +7,11 @@ upgrading from one version to the next, or even between multiple
versions. Be sure to heed the warnings contained herein as they will
save you many hours of grief.
7.3.2
--------------------------------------------------------------------
* The testCodebase.pl script will now automatically set the CODE_COP
script unless you give it the --noLongTests switch.
7.3.0
--------------------------------------------------------------------
* The i18n/label.t and help/setHelp.t test now require that you set

View file

@ -20,11 +20,13 @@ my $configFile;
my $help;
my $verbose;
my $perlBase;
my $noLongTests;
GetOptions(
'verbose'=>\$verbose,
'configFile=s'=>\$configFile,
'perl-base=s'=>\$perlBase,
'noLongTests'=>\$noLongTests,
'help'=>\$help,
);
@ -43,26 +45,31 @@ my $helpmsg=<<STOP;
use. Defaults to the perl installation in your
PATH.
--noLongTests Prevent long tests from being run
STOP
my $verboseFlag = "-v" if ($verbose);
$perlBase .= '/bin/' if ($perlBase);
if ( $configFile ) {
if (! -e $configFile) {
##Probably given the name of the config file with no path, prepend
##the path to it.
##Defaults to command-line switch
$configFile ||= $ENV{WEBGUI_CONFIG};
if (! -e $configFile) {
##Probably given the name of the config file with no path,
##attempt to prepend the path to it.
$configFile = File::Spec->canonpath($FindBin::Bin.'/../etc/'.$configFile);
}
if (-e $configFile) {
system("WEBGUI_CONFIG=".$configFile." ".$perlBase."prove ".$verboseFlag." -r ../t");
}
else {
die "Unable to use $configFile as a WebGUI config file\n";
}
} elsif ( defined @ENV{WEBGUI_CONFIG} ) {
system($perlBase."prove ".$verboseFlag." -r ../t");
} else {
print $helpmsg;
}
die "Unable to use $configFile as a WebGUI config file\n"
unless(-e $configFile and -f _);
my $prefix = "WEBGUI_CONFIG=".$configFile;
##Run all tests unless explicitly forbidden
$prefix .= " CODE_COP=1" unless $noLongTests;
print(join ' ', $prefix, $perlBase."prove", $verboseFlag, '-r ../t'); print "\n";
system(join ' ', $prefix, $perlBase."prove", $verboseFlag, '-r ../t');

View file

@ -10,6 +10,7 @@
use FindBin;
use strict;
use File::Spec;
use lib "$FindBin::Bin/../../lib";
##The goal of this test is to test the creation of Article Wobjects.
@ -64,13 +65,12 @@ foreach my $newSetting (keys %{$newArticleSettings}) {
}
# Test the duplicate method... not for assets, just the extended duplicate functionality of the article wobject
my $path = $session->config->getWebguiRoot()."/t/supporting_collateral/";
my $filename = "page_title.jpg";
my $pathedFile = File::Spec->catfile(WebGUI::Test->getTestCollateralPath, $filename);
# Use some test collateral to create a storage location and assign it to our article
my $storage = WebGUI::Storage::Image->create($session);
system("pwd");
my $storedFilename = $storage->addFileFromFilesystem($path.$filename);
my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
my $filenameOK = is ($storedFilename, $filename, 'storage created correctly');
diag(join("\n", @{ $storage->getErrors })) unless $filenameOK;

View file

@ -14,7 +14,8 @@ use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More; # increment this value for each test you create
use File::Copy qw(cp);
use File::Copy;
use File::Spec;
my $session = WebGUI::Test->session;
@ -71,15 +72,19 @@ SKIP: {
}
sub installPigLatin {
my $wgLib = WebGUI::Test->lib;
mkdir join('/', $wgLib, 'WebGUI/i18n/PigLatin');
cp 'supporting_collateral/WebGUI.pm', join('/', $wgLib, 'WebGUI/i18n/PigLatin/WebGUI.pm');
cp 'supporting_collateral/PigLatin.pm', join('/', $wgLib, 'WebGUI/i18n/PigLatin.pm');
mkdir File::Spec->catdir(WebGUI::Test->lib, 'WebGUI', 'i18n', 'PigLatin');
copy(
File::Spec->catfile(WebGUI::Test->getTestCollateralPath, 'WebGUI.pm'),
File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/)
);
copy(
File::Spec->catfile(WebGUI::Test->getTestCollateralPath, 'PigLatin.pm'),
File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/)
);
}
END: {
my $wgLib = WebGUI::Test->lib;
unlink join('/', $wgLib, 'WebGUI/i18n/PigLatin/WebGUI.pm');
unlink join('/', $wgLib, 'WebGUI/i18n/PigLatin.pm');
rmdir join('/', $wgLib, 'WebGUI/i18n/PigLatin');
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/);
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/);
rmdir File::Spec->catdir(WebGUI::Test->lib, qw/WebGUI i18n PigLatin/);
}

View file

@ -3,7 +3,7 @@ package WebGUI::Test;
use strict;
use warnings;
our ( $SESSION, $WEBGUI_ROOT, $CONFIG_FILE, $WEBGUI_LIB );
our ( $SESSION, $WEBGUI_ROOT, $CONFIG_FILE, $WEBGUI_LIB, $WEBGUI_TEST_COLLATERAL );
use Config qw[];
use IO::Handle qw[];
@ -50,6 +50,7 @@ BEGIN {
$CONFIG_FILE = ( File::Spec->splitpath( $WEBGUI_ROOT ) )[2];
$WEBGUI_ROOT = substr( $WEBGUI_ROOT, 0, index( $WEBGUI_ROOT, File::Spec->catdir( 'etc', $CONFIG_FILE ) ) );
$WEBGUI_ROOT = File::Spec->canonpath($WEBGUI_ROOT);
$WEBGUI_TEST_COLLATERAL = File::Spec->catdir($WEBGUI_ROOT, 't', 'supporting_collateral');
$WEBGUI_LIB ||= File::Spec->catpath( (File::Spec->splitpath($WEBGUI_ROOT))[0], $WEBGUI_ROOT, 'lib' );
@ -107,4 +108,8 @@ sub root {
return $WEBGUI_ROOT;
}
sub getTestCollateralPath {
return $WEBGUI_TEST_COLLATERAL;
}
1;