DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
#!/usr/bin/perl -w
# -*- mode: cperl; c-basic-offset: 8; indent-tabs-mode: nil; -*-

# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Litmus.
#
# The Initial Developer of the Original Code is
# the Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2006
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#   Chris Cooper <ccooper@deadsquid.com>
#   Zach Lipton <zach@zachlipton.com>
#
# ***** END LICENSE BLOCK *****

use strict;
use diagnostics;

use Time::HiRes qw( gettimeofday tv_interval );
our $t0 = [gettimeofday];

use Litmus;
use Litmus::Auth;
use Litmus::FormWidget;
use Litmus::Error;
use Litmus::SysConfig;

Litmus->init();
my $c = Litmus->cgi();

print $c->header();

my $vars;
if ($c->param) {
  my $test_run_id = $c->param("test_run_id");

  if (!$test_run_id) {
   invalidInputError("No Test Run selected!");
   exit 1;
  }
  my $test_run = Litmus::DB::TestRun->getTestRunWithRefs($test_run_id);

  my @sysconfigs;
  foreach my $criterion (@{$test_run->{'criteria'}}) {
    my $sysconfig = Litmus::SysConfig::new(
                                           $test_run_id,
                                           $criterion->{'build_id'} || undef,
                                           $criterion->{'platform_id'} || undef,
                                           $criterion->{'opsys_id'} || undef,
                                           undef
                                          );
    push @sysconfigs, $sysconfig;
  }
  
  my $user =  Litmus::Auth::getCookie();
  my @testgroups = Litmus::DB::Testgroup->search_EnabledByTestRun($test_run_id);

  # All possible subgroups per group:
  my %subgroups; 
  my %testcases;
  my %testcase_coverage;
  foreach my $testgroup (@testgroups) {
    my @component_subgroups = Litmus::DB::Subgroup->search_EnabledByTestgroup($testgroup->testgroup_id());
    $subgroups{$testgroup->testgroup_id()} = \@component_subgroups;

    foreach my $subgroup (@component_subgroups) {
      my @component_testcases = Litmus::DB::Testcase->search_EnabledBySubgroup($subgroup->subgroup_id(),$testgroup->testgroup_id());
      $testcases{$subgroup->subgroup_id()} = \@component_testcases;

      foreach my $testcase (@component_testcases) {
        if (scalar @sysconfigs > 0) {

          foreach my $sysconfig (@sysconfigs) {
            my $coverage = $testcase->coverage(
                                               $test_run_id,
                                               $sysconfig->{'build_id'} || 0,
                                               $sysconfig->{'platform_id'} || 0,
                                               $sysconfig->{'opsys_id'} || 0,
                                               $sysconfig->{'locale'} || 0
                                              );
            $testcase_coverage{$testcase->{'testcase_id'}}{$sysconfig->{'id'}} = $coverage || 0;
          }

        } else {
          my $coverage = $testcase->coverage(
                                             $test_run_id,
                                             0,
                                             0,
                                             0,
                                             0
                                            );
          $testcase_coverage{$testcase->{'testcase_id'}}{'catchall'} = $coverage || 0;          
        }
      }
    }
  }
  
  $vars = {
           title => "Test Run Report - " . $test_run->{'name'},
           test_runs => [$test_run],
           testcase_coverage => \%testcase_coverage,
           testgroups => \@testgroups,
           subgroups => \%subgroups,
           testcases => \%testcases,
           sysconfigs => \@sysconfigs,
          };
  
} else {
  $vars = {
           title => "Select Test Run",
           show_search_form => 1,
          };
}

my $test_runs = Litmus::FormWidget->getTestRuns(1);  
$vars->{"all_test_runs"} = $test_runs;

my $cookie =  Litmus::Auth::getCookie();
$vars->{"defaultemail"} = $cookie;
$vars->{"show_admin"} = Litmus::Auth::istrusted($cookie);

Litmus->template()->process("reporting/test_run_report.tmpl", $vars) || 
    internalError(Litmus->template()->error());

if ($Litmus::Config::DEBUG) {
  my $elapsed = tv_interval ( $t0 );
  printf  "<div id='pageload'>Page took %f seconds to load.</div>", $elapsed;
}

exit 0;