GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit 26564200 authored by boklm's avatar boklm

Add a --name option to set the name of the tests run

parent 85c0d949
......@@ -91,6 +91,11 @@ Available options
--reports-dir=<directory>
Directory where the tests reports are saved.
--name=<name>
The name of the tests run. This is used as directory name to
save the results inside the reports-dir. If not set, a random
name is used.
--virtualenv=<directory>
Path to the virtualenv where selenium and mozmill are installed.
The default is the 'virtualenv' directory created by the 'setup'
......
......@@ -37,6 +37,7 @@ my %default_options = (
keyring => 'erinn.gpg',
'tor-control-port' => '9551',
'tor-socks-port' => '9550',
'reports-dir' => "$FindBin::Bin/reports",
virtualenv => "$FindBin::Bin/virtualenv",
resolution => '1024x768',
xvfb => 1,
......@@ -51,24 +52,26 @@ sub exit_error {
sub get_options {
my @options = qw(mozmill! selenium! starttor! tor-control-port=i
tor-socks-port=i reports-dir=s gpgcheck! keyring=s
virtualenv=s xvfb!);
virtualenv=s xvfb! name=s);
my %res = %default_options;
Getopt::Long::GetOptionsFromArray(\@_, \%res, @options) || exit 1;
$res{files} = \@_;
return \%res;
}
sub set_reports_dir {
if ($options->{'reports-dir'}) {
make_path($options->{'reports-dir'});
sub set_report_dir {
if ($options->{'name'}) {
$options->{'report-dir'} = "$options->{'reports-dir'}/$options->{'name'}";
make_path($options->{'report-dir'});
return;
}
my $r = $FindBin::Bin . '/reports';
mkdir $r;
return $options->{'reports-dir'} = File::Temp::newdir(
make_path($options->{'reports-dir'});
$options->{'report-dir'} = File::Temp::newdir(
'XXXXXX',
DIR => $r,
DIR => $options->{'reports-dir'},
CLEANUP => 0)->dirname;
(undef, undef, $options->{name})
= File::Spec->splitpath($options->{'report-dir'});
}
sub get_tbbfile {
......@@ -313,7 +316,7 @@ sub make_report {
my $template = Template->new(
ENCODING => 'utf8',
INCLUDE_PATH => "$FindBin::Bin/tmpl",
OUTPUT_PATH => $options->{'reports-dir'},
OUTPUT_PATH => $options->{'report-dir'},
);
my $vars = {
options => $options,
......@@ -344,7 +347,7 @@ sub test_tbb {
: sha256_hex(read_file($tbbfile));
$tbbinfos->{tests} = { map { $_ => { %{$tests{$_}} } } keys %tests };
$tbbinfos->{'results-dir'} =
"$options->{'reports-dir'}/results-$tbbinfos->{filename}";
"$options->{'report-dir'}/results-$tbbinfos->{filename}";
mkdir $tbbinfos->{'results-dir'};
extract_tbb($tbbinfos, $tbbfile);
chdir $tbbinfos->{tbbdir} || exit_error "Can't enter directory $tbbinfos->{tbbdir}";
......@@ -360,12 +363,12 @@ sub test_tbb {
$results{$tbbinfos->{filename}} = $tbbinfos;
}
set_reports_dir;
set_report_dir;
foreach my $tbbfile (@{$options->{files}}) {
test_tbb($tbbfile);
}
print "Reports directory: $options->{'reports-dir'}\n";
YAML::DumpFile("$options->{'reports-dir'}/results.yml",
print "Report directory: $options->{'report-dir'}\n";
YAML::DumpFile("$options->{'report-dir'}/results.yml",
{
results => \%results,
options => $options,
......
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