зеркало из https://github.com/mozilla/pjs.git
simple test framework r=preed b=352230
This commit is contained in:
Родитель
18f11a8a68
Коммит
6bea4e3858
|
@ -0,0 +1,70 @@
|
|||
package t::Bootstrap::Step::Dummy;
|
||||
use Bootstrap::Step;
|
||||
@ISA = ("Bootstrap::Step");
|
||||
|
||||
sub Execute {
|
||||
my $this = shift;
|
||||
|
||||
my $productTag = $this->Config('var' => 'productTag');
|
||||
|
||||
if (not $productTag) {
|
||||
print("testfailed, could not get productTag var from Config: $!\n");
|
||||
}
|
||||
|
||||
eval {
|
||||
$this->Shell( 'cmd' => 'true' );
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
print("testfailed, shell call to true should not throw exception: $!\n");
|
||||
}
|
||||
|
||||
eval {
|
||||
$this->Shell( 'cmd' => 'false' );
|
||||
};
|
||||
|
||||
if (not $@) {
|
||||
print("testfailed, shell call to false should throw exception: $!\n");
|
||||
}
|
||||
|
||||
eval {
|
||||
$this->CheckLog(
|
||||
'log' => './t/test.log',
|
||||
'checkForOnly' => '^success',
|
||||
);
|
||||
};
|
||||
|
||||
if (not $@) {
|
||||
print("testfailed, should throw exception, log contains more than success: $!\n");
|
||||
}
|
||||
eval {
|
||||
$this->CheckLog(
|
||||
'log' => './t/test.log',
|
||||
'checkForOnly' => '^success',
|
||||
);
|
||||
};
|
||||
|
||||
if (not $@) {
|
||||
print("testfailed, should throw exception, log contains more than success: $!\n");
|
||||
}
|
||||
|
||||
eval {
|
||||
$this->CheckLog(
|
||||
'log' => './t/test.log',
|
||||
'checkFor' => '^success',
|
||||
);
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
print("testfailed, should throw exception, log contains success: $!\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub Verify {
|
||||
my $this = shift;
|
||||
$this->Shell('cmd' => 'echo Verify tag');
|
||||
$this->Log('msg' => 'finished');
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,4 @@
|
|||
success
|
||||
failed
|
||||
success
|
||||
failed
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use Bootstrap::Step;
|
||||
use t::Bootstrap::Step::Dummy;
|
||||
|
||||
my $step = t::Bootstrap::Step::Dummy->new();
|
||||
|
||||
$step->Execute();
|
||||
$step->Verify();
|
Загрузка…
Ссылка в новой задаче