Unverified Commit 4e5cfe9a authored by boklm's avatar boklm
Browse files

Start adding browserrebase testsuite type

parent 0caf20cb
......@@ -10,7 +10,8 @@ our (@ISA, @EXPORT_OK);
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(git_clone_fetch get_commits_by_branch parent_commit);
@EXPORT_OK = qw(git_clone_fetch get_commits_by_branch parent_commit
git_cmd git_cmd_ch);
}
my $torbrowsergit = 'https://git.torproject.org/tor-browser.git';
......
package TBBTestSuite::BrowserRebaseTests;
use strict;
use File::Slurp;
use IO::CaptureOutput qw(capture_exec);
use TBBTestSuite::BrowserGit qw(git_clone_fetch get_commits_by_branch
parent_commit git_cmd git_cmd_ch);
my $test_types = {
cherry_pick => \&cherry_pick,
};
our %testsuite = (
description => 'Tor Browser rebase tests',
test_types => $test_types,
pre_tests => \&pre_tests,
post_tests => \&post_tests,
pre_makereport => \&pre_makereport,
pre_reports_index => \&pre_reports_index,
);
sub test_name {
my ($commit) = @_;
my ($res) = git_cmd_ch('git', 'show', '-s', '--abbrev=12',
'--format=%h-%f', $commit);
return $res;
}
sub get_tbbinfos {
my ($infos) = @_;
git_clone_fetch;
my %tbbinfos = (
%$infos,
type => 'browserrebase',
filename => 'browser-rebase',
tests => [],
);
my @commits = reverse get_commits_by_branch($infos->{tb_branch},
$infos->{esr_branch});
shift @commits;
foreach my $commit (@commits) {
my $test = {
name => test_name($commit),
type => 'cherry_pick',
descr => "Cherry pick commit $commit\n",
commit => $commit,
retry => 1,
};
push @{$tbbinfos{tests}}, $test;
}
return \%tbbinfos;
}
sub pre_tests {
my ($tbbinfos) = @_;
chdir $TBBTestSuite::BrowserGit::clone_dir;
git_cmd('git', 'clean', '-fx');
git_cmd('git', 'checkout', '-f', '--detach');
if (-f '.git/refs/heads/rebase-test') {
print "Removing rebase-test branch\n";
my ($out) = git_cmd('git', 'branch', '-D', 'rebase-test');
print $out;
}
git_cmd('git', 'branch', '-f', 'rebase-test', 'gecko-dev/master');
git_cmd('git', 'checkout', '-f', 'rebase-test');
}
sub post_tests {
my ($tbbinfos) = @_;
}
sub pre_makereport {
}
sub pre_reports_index {
}
sub cherry_pick {
my ($tbbinfos, $test) = @_;
print "Rebase $test->{commit}\n";
my ($out, $err, $success) = capture_exec('git', 'cherry-pick', '-Xpatience',
'--allow-empty', '--ff', $test->{commit});
$test->{results}{success} = $success;
if (!$success) {
$test->{results}{git_out} = $out;
$test->{results}{git_err} = $err;
($test->{results}{failed_diff}) = git_cmd_ch('git', 'diff');
$test->{results}{success} = 1 unless $test->{results}{failed_diff};
git_cmd('git', 'reset', '--hard');
} else {
my ($patch) = git_cmd_ch('git', 'format-patch', '--stdout', 'HEAD^');
write_file("$tbbinfos->{'results-dir'}/$test->{name}.patch", $patch);
$test->{results}{patch_file} = 1;
}
}
1;
......@@ -18,6 +18,7 @@ use TBBTestSuite::XServer qw(set_Xmode);
our %testsuite_types = (
browserunit => \%TBBTestSuite::BrowserUnitTests::testsuite,
browserrebase => \%TBBTestSuite::BrowserRebaseTests::testsuite,
browserbundle => \%TBBTestSuite::BrowserBundleTests::testsuite,
browserbundle_virustotal => \%TBBTestSuite::BrowserBundleTests::testsuite_virustotal,
);
......
# vim: filetype=perl expandtab
use strict;
use FindBin;
use TBBTestSuite::Common;
use TBBTestSuite::BrowserRebaseTests;
use TBBTestSuite::BrowserGit qw(git_clone_fetch get_commits_by_branch
parent_commit);
use Data::Dump qw(dd);
my $torbrowser_branch = 'tor-browser-31.2.0esr-4.x-1';
my $esr_branch = 'esr31';
my $testsuite_version = '2';
my $tbbinfos = TBBTestSuite::BrowserRebaseTests::get_tbbinfos({
tb_branch => 'tor-browser-31.2.0esr-4.x-1',
esr_branch => 'esr31',
});
dd $tbbinfos;
my %res = (
args => [ $tbbinfos ],
);
%res;
[% IF test.results.success %]
[% IF test.results.patch_file %]
<a href="results-[% tbbfile %]/[% test.name %].patch">rebased patch</a>
[% ELSE %]
Skipped
[% END %]
[% ELSE %]
Failed diff:
<pre>[% FILTER html_entity %][% test.results.failed_diff %][% END %]</pre>
[% END %]
[% USE date -%]
<html>
<head>
<title>Tests reports</title>
<style type="text/css">
.test_ok {
color: #006600;
font-weight: bold;
}
.test_ok A {
color: #006600;
font-weight: bold;
}
.test_notok {
color: #FF0000;
font-weight: bold;
}
.test_notok A {
color: #FF0000;
}
.reportdate {
font-size: small;
}
</style>
[% INCLUDE togglecontent.js %]
</head>
<body>
<h1>Tor Browser Rebase Test Reports: [% title %]</h1>
[% FOREACH report IN reports_list %]
[%
SET tbbfiles = reports.$report.tbbfiles;
SET tbbfile = reports.$report.tbbfiles.keys.0;
%]
<ul>
<li><a href="r/[% report %]/[% tbbfile %].html">Details</a></li>
</ul>
<hr />
[% END %]
</body>
</html>
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