Unverified Commit 8cf679ee authored by boklm's avatar boklm
Browse files

Move test_types, pre_tests, post_tests outside tbbinfos

parent f6c5b484
......@@ -47,6 +47,12 @@ my $test_types = {
command => \&command_run,
};
our %testsuite = (
test_types => $test_types,
pre_tests => \&pre_tests,
post_tests => \&post_tests,
);
our @tests = (
{
name => 'readelf_RELRO',
......@@ -273,8 +279,7 @@ sub tbb_filename_infos {
my ($tbbfile) = @_;
my (undef, undef, $file) = File::Spec->splitpath($tbbfile);
my %res = (filename => $file, tbbfile => $tbbfile,
pre_tests => \&pre_tests, post_tests => \&post_tests,
test_types => $test_types, type => 'browserbundle');
type => 'browserbundle');
if ($file =~ m/^tor-browser-linux(..)-([^_]+)_(.+)\.tar\.xz$/) {
@res{qw(type os version language)} = ('tbbfile', 'Linux', $2, $3);
$res{arch} = $1 eq '64' ? 'x86_64' : 'x86';
......
......@@ -13,15 +13,18 @@ my $test_types = {
build_firefox => \&build_firefox,
};
our %testsuite = (
test_types => $test_types,
pre_tests => \&pre_tests,
post_tests => \&post_tests,
);
sub get_tbbinfos {
my ($infos) = @_;
my %tbbinfos = (
%$infos,
pre_tests => \&pre_tests,
post_tests => \&post_tests,
type => 'browserunit',
filename => "browser-$infos->{commit}",
test_types => $test_types,
tests => [
{
name => 'build_firefox',
......
......@@ -13,12 +13,18 @@ use YAML;
use TBBTestSuite::Common qw(exit_error);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::BrowserBundleTests qw(tbb_filename_infos);
use TBBTestSuite::BrowserUnitTests;
my %testsuite_types = (
browserunit => \%TBBTestSuite::BrowserUnitTests::testsuite,
browserbundle => \%TBBTestSuite::BrowserBundleTests::testsuite,
);
sub run_tests {
my ($tbbinfos) = @_;
my @enable_tests = $options->{'enable-tests'}
? split(',', $options->{'enable-tests'}) : ();
my $test_types = $tbbinfos->{test_types};
my $test_types = $testsuite_types{$tbbinfos->{type}}->{test_types};
foreach my $test (@{$tbbinfos->{tests}}) {
$test->{fail_type} //= 'error';
}
......@@ -125,15 +131,13 @@ sub test_start {
$tbbinfos->{'results-dir'} =
"$options->{'report-dir'}/results-$tbbinfos->{filename}";
mkdir $tbbinfos->{'results-dir'};
$tbbinfos->{pre_tests}($tbbinfos);
delete $tbbinfos->{pre_tests};
my $testsuite = $testsuite_types{$tbbinfos->{type}};
$testsuite->{pre_tests}($tbbinfos);
$tbbinfos->{start_time} = time;
run_tests($tbbinfos);
$tbbinfos->{finish_time} = time;
$tbbinfos->{run_time} = $tbbinfos->{finish_time} - $tbbinfos->{start_time};
$tbbinfos->{post_tests}($tbbinfos);
delete $tbbinfos->{post_tests};
delete $tbbinfos->{test_types};
$testsuite->{post_tests}($tbbinfos);
chdir $oldcwd;
$tbbinfos->{success} = is_success($tbbinfos->{tests});
$report->{tbbfiles}{$tbbinfos->{filename}} = $tbbinfos;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment