mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
allow grepping of the coverage report
This commit is contained in:
parent
a8ab11bbd0
commit
219bd6753c
4 changed files with 46 additions and 8 deletions
|
@ -29,7 +29,7 @@ module.exports = function (grunt) {
|
|||
},
|
||||
clientside: {
|
||||
files: {
|
||||
'<%= testUtilsDir %>/istanbul_reporter/report.jade.js': '<%= testUtilsDir %>/istanbul_reporter/report.clientside-jade'
|
||||
'<%= testUtilsDir %>/istanbul_reporter/report.jade.js': '<%= testUtilsDir %>/istanbul_reporter/report.clientside.jade'
|
||||
},
|
||||
options: {
|
||||
client: true,
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
span.cov(class=coverageClass(cov.coverage)) #{cov.coverage | 0}
|
||||
|
||||
for dir in cov.dirs
|
||||
li.dirname= dir.name || '.'
|
||||
li.dirname
|
||||
| #{dir.name || '.'}
|
||||
span.cov ★
|
||||
for file in dir.files
|
||||
li
|
||||
span.cov(class=coverageClass(file.coverage)) #{file.coverage | 0}
|
||||
|
@ -262,7 +264,8 @@ style.
|
|||
color: white;
|
||||
opacity: .60;
|
||||
text-align: left;
|
||||
padding: 15px 35px 0 20px;
|
||||
margin: 15px 0px 0 20px;
|
||||
padding: 0 40px 0 0;
|
||||
}
|
||||
|
||||
#menu li .dirname {
|
||||
|
@ -288,6 +291,7 @@ style.
|
|||
border-radius: 10px;
|
||||
padding: 2px 3px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#stats:nth-child(2n) {
|
File diff suppressed because one or more lines are too long
|
@ -31,6 +31,8 @@ define(function (require) {
|
|||
|
||||
var Base = window.Mocha.reporters.Base;
|
||||
|
||||
var covGrepQueryParamRE = /cov_grep=([^&]+)/;
|
||||
|
||||
function IstanbulReporter(runner) {
|
||||
// "inherit" the base reporters characteristics
|
||||
Base.call(this, runner);
|
||||
|
@ -88,9 +90,20 @@ define(function (require) {
|
|||
}
|
||||
|
||||
function createReport() {
|
||||
var summary = objUtils.summarizeCoverage(window.__coverage__);
|
||||
var covResults = window.__coverage__;
|
||||
var grep = window.location.search.match(covGrepQueryParamRE);
|
||||
if (grep) {
|
||||
grep = decodeURIComponent(grep[1]);
|
||||
covResults = _.transform(covResults, function (results, cov, filename) {
|
||||
if (~filename.indexOf(grep)) {
|
||||
results[filename] = cov;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var dirs = _(window.__coverage__)
|
||||
var summary = objUtils.summarizeCoverage(covResults);
|
||||
|
||||
var dirs = _(covResults)
|
||||
.map(convertFile)
|
||||
.groupBy(function (file) {
|
||||
var dir = path.dirname(file.filename);
|
||||
|
@ -187,6 +200,7 @@ define(function (require) {
|
|||
function linkNav() {
|
||||
var headings = $('h2').toArray();
|
||||
|
||||
// when scrolling, highlight the related menu item
|
||||
$(window).scroll(function (e) {
|
||||
var heading = find(window.scrollY);
|
||||
if (!heading) return;
|
||||
|
@ -201,6 +215,7 @@ define(function (require) {
|
|||
}
|
||||
});
|
||||
|
||||
// find the file they are probably looking at
|
||||
function find(y) {
|
||||
var i = headings.length
|
||||
, heading;
|
||||
|
@ -212,6 +227,25 @@ define(function (require) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#menu').on('click', '.dirname .cov', function () {
|
||||
var dir = $(this).parent()[0].childNodes[0].textContent;
|
||||
var loc = window.location;
|
||||
var proto = loc.protocol;
|
||||
var host = loc.host;
|
||||
var path = loc.pathname;
|
||||
var search = loc.search;
|
||||
var hash = loc.hash;
|
||||
|
||||
var grep = 'cov_grep=' + encodeURIComponent(dir);
|
||||
if (search && search.match(covGrepQueryParamRE)) {
|
||||
search = search.replace(covGrepQueryParamRE, grep);
|
||||
} else {
|
||||
search = (search ? search + '&' : '?') + grep;
|
||||
}
|
||||
|
||||
window.location = path + search + hash;
|
||||
});
|
||||
}
|
||||
|
||||
function toSec(stats, prop) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue