Unverified Commit aa894700 authored by boklm's avatar boklm
Browse files

Move all testsuites to a TestSuite directory

parent 4073e787
......@@ -15,6 +15,7 @@ use YAML::Syck;
use TBBTestSuite::Common qw(exit_error as_array);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::Tests;
use TBBTestSuite::TestSuites;
use Email::Simple;
use Email::Sender::Simple qw(try_to_sendmail);
use DateTime;
......@@ -159,6 +160,7 @@ sub make_reports_index {
my $month = date_month($summaries{$report}->{time});
push @{$reports_by_month{$type}->{$month}}, $report;
}
my %testsuite_infos = TBBTestSuite::TestSuites::testsuite_infos();
my $vars = {
%template_functions,
reports => \%reports,
......@@ -166,7 +168,7 @@ sub make_reports_index {
reports_by_type => \%reports_by_type,
reports_by_tag => \%reports_by_tag,
reports_by_month => \%reports_by_month,
testsuite_types => \%TBBTestSuite::Tests::testsuite_types,
testsuite_types => \%testsuite_infos,
};
$template->process('reports_index.html', $vars, 'index.html')
|| exit_error "Template Error:\n" . $template->error;
......
package TBBTestSuite::TestSuite;
use TBBTestSuite::TestTestSuite;
use TBBTestSuite::BrowserBundleTests;
use TBBTestSuite::BrowserBundleVirusTotal;
use TBBTestSuite::BrowserUnitTests;
use TBBTestSuite::BrowserRebaseTests;
use TBBTestSuite::TestSuites;
use Scalar::Util 'blessed';
my @testsuite_list = qw(TestTestSuite BrowserBundleTests BrowserBundleVirusTotal
BrowserUnitTests BrowserRebaseTests);
my %testsuite_types;
sub testsuite_types {
return %testsuite_types if %testsuite_types;
foreach my $ts (@testsuite_list) {
$testsuite_types{"TBBTestSuite::${ts}"->type()} = $ts;
}
return %testsuite_types;
}
sub testsuite_infos {
my %testsuite_infos;
foreach my $ts (@testsuite_list) {
my $n = "TBBTestSuite::${ts}";
$testsuite_infos{$n->type()} = {
name => $n,
type => $n->type(),
description => $n->description(),
};
}
return %testsuite_infos;
}
sub new {
my ($testsuite) = @_;
......@@ -39,8 +11,8 @@ sub new {
sub load {
my ($testsuite) = @_;
my %ts = testsuite_types;
return bless $testsuite, "TBBTestSuite::$ts{$testsuite->{type}}";
my %ts = TBBTestSuite::TestSuites::testsuite_types();
return bless $testsuite, "TBBTestSuite::TestSuite::$ts{$testsuite->{type}}";
}
sub type {
......
package TBBTestSuite::BrowserBundleTests;
package TBBTestSuite::TestSuite::BrowserBundleTests;
use warnings;
use strict;
......
package TBBTestSuite::BrowserBundleVirusTotal;
package TBBTestSuite::TestSuite::BrowserBundleVirusTotal;
use parent 'TBBTestSuite::BrowserBundleTests';
use parent 'TBBTestSuite::TestSuite::BrowserBundleTests';
sub description {
'Tor Browser Bundle Virustotal checks';
......
package TBBTestSuite::BrowserRebaseTests;
package TBBTestSuite::TestSuite::BrowserRebaseTests;
use strict;
......
package TBBTestSuite::BrowserUnitTests;
package TBBTestSuite::TestSuite::BrowserUnitTests;
use strict;
......
package TBBTestSuite::TestTestSuite;
package TBBTestSuite::TestSuite::TestTestSuite;
use strict;
use parent 'TBBTestSuite::TestSuite';
......
package TBBTestSuite::TestSuites;
use strict;
use TBBTestSuite::TestSuite::TestTestSuite;
use TBBTestSuite::TestSuite::BrowserBundleTests;
use TBBTestSuite::TestSuite::BrowserBundleVirusTotal;
use TBBTestSuite::TestSuite::BrowserUnitTests;
use TBBTestSuite::TestSuite::BrowserRebaseTests;
my @testsuite_list = qw(TestTestSuite BrowserBundleTests BrowserBundleVirusTotal
BrowserUnitTests BrowserRebaseTests);
my %testsuite_types;
sub testsuite_types {
return %testsuite_types if %testsuite_types;
foreach my $ts (@testsuite_list) {
$testsuite_types{"TBBTestSuite::TestSuite::${ts}"->type()} = $ts;
}
return %testsuite_types;
}
sub testsuite_infos {
my %testsuite_infos;
foreach my $ts (@testsuite_list) {
my $n = "TBBTestSuite::TestSuite::${ts}";
$testsuite_infos{$n->type()} = {
name => $n,
type => $n->type(),
description => $n->description(),
};
}
return %testsuite_infos;
}
1;
......@@ -12,10 +12,10 @@ use LWP::UserAgent;
use TBBTestSuite::Reports;
use TBBTestSuite::Common qw(exit_error);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::BrowserBundleTests;
use TBBTestSuite::BrowserUnitTests;
use TBBTestSuite::TestSuites;
use TBBTestSuite::TestSuite::BrowserBundleTests;
use TBBTestSuite::TestSuite::BrowserUnitTests;
use TBBTestSuite::XServer qw(set_Xmode);
use TBBTestSuite::TestSuite;
our (@ISA, @EXPORT_OK);
BEGIN {
......@@ -24,8 +24,6 @@ BEGIN {
@EXPORT_OK = qw(tbb_filename_infos);
}
our %testsuite_types = TBBTestSuite::TestSuite::testsuite_infos();
sub run_tests {
my ($tbbinfos) = @_;
my @enable_tests;
......@@ -147,8 +145,8 @@ sub tbb_filename_infos {
return undef;
}
return $options->{virustotal} ?
TBBTestSuite::BrowserBundleVirusTotal->new(\%res)
: TBBTestSuite::BrowserBundleTests->new(\%res);
TBBTestSuite::TestSuite::BrowserBundleVirusTotal->new(\%res)
: TBBTestSuite::TestSuite::BrowserBundleTests->new(\%res);
}
......@@ -208,12 +206,13 @@ sub test_start {
my $oldcwd = getcwd;
my $tmpdir = File::Temp::newdir('XXXXXX', DIR => $options->{tmpdir});
$tbbinfos->{tmpdir} = $tmpdir->dirname;
$tbbinfos->{tests} //= [ map { { %$_ } } @TBBTestSuite::BrowserBundleTests::tests ];
$tbbinfos->{tests} //= [ map { { %$_ } } @TBBTestSuite::TestSuite::BrowserBundleTests::tests ];
$tbbinfos->{'results-dir'} =
TBBTestSuite::Reports::report_path($report,
"results-$tbbinfos->{filename}");
mkdir $tbbinfos->{'results-dir'};
my $testsuite = $testsuite_types{$tbbinfos->{type}};
my %testsuite_infos = TBBTestSuite::TestSuites::testsuite_infos();
my $testsuite = $testsuite_infos{$tbbinfos->{type}};
$tbbinfos->pre_tests();
$tbbinfos->{start_time} = time;
run_tests($tbbinfos);
......
......@@ -3,7 +3,7 @@
use strict;
use FindBin;
use TBBTestSuite::Common;
use TBBTestSuite::BrowserRebaseTests;
use TBBTestSuite::TestSuite::BrowserRebaseTests;
use TBBTestSuite::BrowserGit qw(git_clone_fetch get_commits_by_branch
parent_commit);
use Data::Dump qw(dd);
......@@ -12,7 +12,7 @@ my $torbrowser_branch = 'tor-browser-31.2.0esr-4.x-1';
my $esr_branch = 'esr31';
my $testsuite_version = '2';
my $tbbinfos = TBBTestSuite::BrowserRebaseTests->new({
my $tbbinfos = TBBTestSuite::TestSuite::BrowserRebaseTests->new({
tb_branch => 'tor-browser-31.2.0esr-4.x-1',
esr_branch => 'esr31',
});
......
......@@ -3,7 +3,7 @@
use strict;
use FindBin;
use TBBTestSuite::Common;
use TBBTestSuite::BrowserUnitTests;
use TBBTestSuite::TestSuite::BrowserUnitTests;
use TBBTestSuite::BrowserGit qw(git_clone_fetch get_commits_by_branch
parent_commit);
......@@ -39,7 +39,7 @@ for my $commit (reverse @commits) {
next;
}
$res{name} = $name;
my $tbbinfos = TBBTestSuite::BrowserUnitTests->new({
my $tbbinfos = TBBTestSuite::TestSuite::BrowserUnitTests->new({
browserdir => $TBBTestSuite::BrowserGit::clone_dir,
commit => substr($commit, 0, 20),
$previous ? (parent_results => $previous) : (),
......
# vim: filetype=perl expandtab
use strict;
use TBBTestSuite::TestTestSuite;
use TBBTestSuite::TestSuite::TestTestSuite;
my $testsuite = TBBTestSuite::TestTestSuite->new({});
my $testsuite = TBBTestSuite::TestSuite::TestTestSuite->new({});
my %res = (
args => [ $testsuite ],
......
......@@ -34,7 +34,7 @@ Adding a browser bundle test
----------------------------
The list of tests to be run by the test suite is defined in file
'TBBTestSuite/BrowserBundleTests.pm' in the '@tests' variable.
'TBBTestSuite/TestSuite/BrowserBundleTests.pm' in the '@tests' variable.
Each test is defined with the following properties:
......@@ -73,7 +73,7 @@ Adding a mozmill test
~~~~~~~~~~~~~~~~~~~~~
To add a new test based on mozmill, you will add something like this in
'TBBTestSuite/BrowserBundleTests.pm':
'TBBTestSuite/TestSuite/BrowserBundleTests.pm':
----
{
......@@ -164,7 +164,7 @@ Adding a selenium test
~~~~~~~~~~~~~~~~~~~~~~
To add a new test based on selenium webdriver, you will add something
like this in 'TBBTestSuite/BrowserBundleTests.pm':
like this in 'TBBTestSuite/TestSuite/BrowserBundleTests.pm':
----
{
......@@ -183,7 +183,7 @@ Adding a command test
~~~~~~~~~~~~~~~~~~~~~
To run a command on some files, and check the output. You will add
something like this in 'TBBTestSuite/BrowserBundleTests.pm':
something like this in 'TBBTestSuite/TestSuite/BrowserBundleTests.pm':
----
{
......
......@@ -12,7 +12,7 @@ use TBBTestSuite::Reports qw(report_dir report_path save_report);
use TBBTestSuite::Reports::Receive;
use TBBTestSuite::Reports::Send;
use TBBTestSuite::Tests qw(tbb_filename_infos);
use TBBTestSuite::BrowserBundleTests;
use TBBTestSuite::TestSuite::BrowserBundleTests;
sub set_report_success {
my ($report) = @_;
......@@ -107,7 +107,7 @@ sub gen_missing_thumbnails {
my %actions = (
run_tests => \&run_tests,
list_tests => \&TBBTestSuite::BrowserBundleTests::list_tests,
list_tests => \&TBBTestSuite::TestSuite::BrowserBundleTests::list_tests,
reports_index => \&TBBTestSuite::Reports::make_reports_index,
make_report => \&make_report,
send_report => \&TBBTestSuite::Reports::Send::send_report,
......
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