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

Add report_dir and report_path functions

This replace the report-dir option.
parent 16841e7b
......@@ -19,7 +19,7 @@ our (@ISA, @EXPORT_OK);
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(load_report);
@EXPORT_OK = qw(load_report report_dir report_path);
}
my %template_functions = (
......@@ -29,21 +29,26 @@ my %template_functions = (
test_by_name => \&TBBTestSuite::Tests::test_by_name,
);
sub set_report_dir {
sub report_dir {
my ($report) = @_;
my $rdir = $report->{options}{'reports-dir'} . '/r';
my $rdir = $options->{'reports-dir'} . '/r';
make_path($rdir) unless -d $rdir;
if ($report->{options}{name}) {
$report->{options}{'report-dir'} = "$rdir/$report->{options}{name}";
make_path($options->{'report-dir'});
return;
my $reportdir = "$rdir/$report->{options}{name}";
make_path($reportdir) unless -d $reportdir;
return $reportdir;
}
make_path($rdir);
$report->{options}{'report-dir'} = File::Temp::newdir(
my $reportdir = File::Temp::newdir(
'XXXXXX',
DIR => $rdir,
CLEANUP => 0)->dirname;
(undef, undef, $report->{options}{name})
= File::Spec->splitpath($report->{options}{'report-dir'});
= File::Spec->splitpath($reportdir);
return $reportdir;
}
sub report_path {
report_dir($_[0]) . '/' . $_[1];
}
sub copy_static {
......@@ -61,8 +66,8 @@ sub make_report {
copy_static;
my $template = Template->new(
ENCODING => 'utf8',
INCLUDE_PATH => "$FindBin::Bin/tmpl:$report->{options}{'report-dir'}",
OUTPUT_PATH => $report->{options}{'report-dir'},
INCLUDE_PATH => "$FindBin::Bin/tmpl:" . report_dir($report),
OUTPUT_PATH => report_dir($report),
);
foreach my $tbbfile (keys %{$report->{tbbfiles}}) {
my $type = $report->{tbbfiles}{$tbbfile}{type};
......
......@@ -10,6 +10,7 @@ use File::Temp;
use File::Slurp;
use LWP::UserAgent;
use YAML;
use TBBTestSuite::Reports;
use TBBTestSuite::Common qw(exit_error);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::BrowserBundleTests qw(tbb_filename_infos);
......@@ -155,7 +156,8 @@ sub test_start {
$tbbinfos->{tmpdir} = $tmpdir->dirname;
$tbbinfos->{tests} //= [ map { { %$_ } } @TBBTestSuite::BrowserBundleTests::tests ];
$tbbinfos->{'results-dir'} =
"$options->{'report-dir'}/results-$tbbinfos->{filename}";
TBBTestSuite::Reports::report_path($report,
"results-$tbbinfos->{filename}");
mkdir $tbbinfos->{'results-dir'};
my $testsuite = $testsuite_types{$tbbinfos->{type}};
$testsuite->{pre_tests}($tbbinfos);
......
......@@ -7,7 +7,7 @@ use File::Path qw(make_path);
use YAML;
use TBBTestSuite::Common qw(exit_error run_alone rm_pidfile);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::Reports;
use TBBTestSuite::Reports qw(report_dir report_path);
use TBBTestSuite::Reports::Receive;
use TBBTestSuite::Reports::Send;
use TBBTestSuite::Tests;
......@@ -44,15 +44,14 @@ sub run_tests {
system_infos => TBBTestSuite::Common::system_infos,
report_format => '1',
};
TBBTestSuite::Reports::set_report_dir($report);
foreach my $tbbfile (@{$options->{args}}) {
my $tbbinfos = ref $tbbfile eq 'HASH' ? $tbbfile
: tbb_filename_infos($tbbfile);
TBBTestSuite::Tests::test_start($report, $tbbinfos);
}
set_report_success($report);
print "Report directory: $options->{'report-dir'}\n";
YAML::DumpFile("$options->{'report-dir'}/report.yml", $report);
print 'Report directory: ', report_dir($report), "\n";
YAML::DumpFile(report_path($report, 'report.yml'), $report);
TBBTestSuite::Reports::make_report($report);
TBBTestSuite::Reports::make_reports_index;
TBBTestSuite::Reports::Send::send_report if $options->{'upload-to'};
......@@ -61,8 +60,7 @@ sub run_tests {
sub load_report_from_file {
exit_error "--name is not set" unless $options->{name};
my $report = { options => $options };
TBBTestSuite::Reports::set_report_dir($report);
$report = YAML::LoadFile("$options->{'report-dir'}/report.yml");
$report = YAML::LoadFile(report_path($report, 'report.yml'));
$report->{options} = { %{$report->{options}}, %$options };
return $report;
}
......
Supports Markdown
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