Mercurial > pub > Impl
changeset 83:74bae30eb25e
(no commit message)
author | wizard |
---|---|
date | Tue, 13 Apr 2010 20:27:56 +0400 |
parents | 3a4205e7b663 |
children | e568c7c8b743 |
files | Lib/IMPL/Test/Plan.pm Lib/IMPL/Test/Unit.pm Lib/IMPL/Web/Security.pm _test/temp.pl |
diffstat | 4 files changed, 44 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Test/Plan.pm Thu Apr 08 13:15:31 2010 +0400 +++ b/Lib/IMPL/Test/Plan.pm Tue Apr 13 20:27:56 2010 +0400 @@ -73,9 +73,17 @@ $info{Unit} = $Unit; try { - $info{Tests} = [map $Unit->new($_), $Unit->List]; + $info{Tests} = [$Unit->List]; } otherwise { - $info{Tests} = [$info{Unit} = new IMPL::Test::BadUnit($Unit->can('UnitName') ? $Unit->UnitName : $Unit,"Failed to extract tests",$@)]; + my $err = $@; + $Unit = $info{Unit} = new IMPL::Test::BadUnit( + $Unit->can('UnitName') ? + $Unit->UnitName : + $Unit, + "Failed to extract tests", + $err + ); + $info{Tests} = [$Unit->List]; }; $count += @{$info{Tests}}; push @cache, \%info if @{$info{Tests}}; @@ -107,26 +115,48 @@ eval { $data = $info->{Unit}->StartUnit; }; - + my @results; if (not $@) { + foreach my $test (@{$info->{Tests}}) { + my $name = $test->Name; + + #protected creation of the test + $test = eval { $info->{Unit}->new($test); } || new IMPL::Test::BadUnit( + $info->{Unit}->can('UnitName') ? + $info->{Unit}->UnitName : + $info->{Unit}, + "Failed to construct the test $name", + $@ + ); + + # invoke the test $this->_Tell(RunTest => $test); my $result = $test->Run($data); $this->_Tell(EndTest => $test,$result); + push @results,$result; } } else { my $e = $@; + my $badTest = new IMPL::Test::BadUnit( + $info->{Unit}->can('UnitName') ? + $info->{Unit}->UnitName : + $info->{Unit}, + "Failed to initialize the unit", + $@ + ); foreach my $test (@{$info->{Tests}}) { - $this->_Tell(RunTest => $test); + + $this->_Tell(RunTest => $badTest); my $result = new IMPL::Test::Result( Name => $test->Name, State => IMPL::Test::Result::FAIL, Exception => $e ); - $this->_Tell(EndTest => $test,$result); + $this->_Tell(EndTest => $badTest,$result); push @results,$result; } }
--- a/Lib/IMPL/Test/Unit.pm Thu Apr 08 13:15:31 2010 +0400 +++ b/Lib/IMPL/Test/Unit.pm Tue Apr 13 20:27:56 2010 +0400 @@ -8,6 +8,7 @@ use Time::HiRes qw(gettimeofday tv_interval); use Error qw(:try); +use Carp qw(carp); use IMPL::Test::Result; use IMPL::Test::FailException; use IMPL::Exception;
--- a/Lib/IMPL/Web/Security.pm Thu Apr 08 13:15:31 2010 +0400 +++ b/Lib/IMPL/Web/Security.pm Tue Apr 13 20:27:56 2010 +0400 @@ -42,7 +42,7 @@ sub MakeContext { my ($this,$principal,$roles,$auth) = @_; - return $this->sourceSession->insert( + return $this->sourceSession->create( { principal => $principal, rolesAssigned => $roles,