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

Start adding browserrebase testsuite type

parent 0caf20cb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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';
+97 −0
Original line number Diff line number Diff line
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;
+1 −0
Original line number Diff line number Diff line
@@ -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,
);

config/browser-rebase

0 → 100644
+24 −0
Original line number Diff line number Diff line
# 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;
+10 −0
Original line number Diff line number Diff line
[% 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 %]
Loading