This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Tatarintsev
committed
Feb 13, 2014
1 parent
8f8da7d
commit d66eede
Showing
3 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> | |||
<title>Shooter report</title> | |||
<style> | |||
.success::before { | |||
content: '\2713 '; | |||
color: green; | |||
} | |||
|
|||
.fail { | |||
color: red; | |||
} | |||
|
|||
.fail:before { | |||
content: '\2718 '; | |||
color: red; | |||
} | |||
|
|||
.image-box { | |||
display: inline-block; | |||
padding: 5px; | |||
} | |||
|
|||
</style> | |||
</head> | |||
|
|||
<body> | |||
<h1>Shooter report</h1> | |||
<% plans.forEach(function(plan) { %> | |||
<h2><%- plan.name %></h2> | |||
<% plan.tests.forEach(function(test) { %> | |||
<h3 class="<%= test.equal? 'success' : 'fail' %>"><%- test.state %></h3> | |||
<% if (test.equal) { %> | |||
<img src="<%= attach(plan.name, test.state, 'current') %>"> | |||
<%} else {%> | |||
<div class="image-box"> | |||
<div>Reference</div> | |||
<img class="ref-image" src="<%= attach(plan.name, test.state, 'ref') %>"> | |||
</div> | |||
|
|||
|
|||
<div class="image-box"> | |||
<div>Current</div> | |||
<img class="current-image" src="<%= attach(plan.name, test.state, 'current') %>"> | |||
</div> | |||
<%} %> | |||
<%});%> | |||
<% });%> | |||
</body> | |||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,73 @@ | |||
'use strict'; | |||
|
|||
var q = require('q'), | |||
fs = require('q-io/fs'), | |||
path = require('path'), | |||
_ = require('lodash'); | |||
|
|||
var REPORT_DIR = 'shooter-report', | |||
REPORT_INDEX = path.join(REPORT_DIR, 'index.html'), | |||
REPORT_ATTACHMENTS = path.join(REPORT_DIR, 'attach'); | |||
|
|||
function attachmentsPath(plan) { | |||
return path.join(REPORT_ATTACHMENTS, plan); | |||
} | |||
|
|||
function attachmentPath(plan, state, kind) { | |||
return path.join(attachmentsPath(plan), state + '~' + kind + '.png'); | |||
} | |||
|
|||
module.exports = function htmlReporter(tester) { | |||
var plans, | |||
currentPlan, | |||
attachmentsQueue; | |||
|
|||
tester.on('beginTests', function() { | |||
plans = []; | |||
attachmentsQueue = fs.makeTree(REPORT_ATTACHMENTS); | |||
}); | |||
|
|||
tester.on('beginPlan', function(plan) { | |||
currentPlan = {name: plan, tests: []}; | |||
plans.push(currentPlan); | |||
attachmentsQueue.then(function() { | |||
return fs.makeDirectory(attachmentsPath(plan)); | |||
}); | |||
}); | |||
|
|||
tester.on('endTest', function(result) { | |||
currentPlan.tests.push(result); | |||
attachmentsQueue.then(function() { | |||
var copyCurrent = fs.copy(result.currentPath, attachmentPath(result.name, result.state, 'current')); | |||
if (result.equal) { | |||
return copyCurrent; | |||
} | |||
return copyCurrent | |||
.then(function() { | |||
return fs.copy(result.previousPath, attachmentPath(result.name, result.state, 'ref')); | |||
}); | |||
}); | |||
}); | |||
|
|||
tester.on('endTests', function () { | |||
attachmentsQueue | |||
.then(function() { | |||
return fs.read(path.resolve(__dirname, './html-tpl.html')); | |||
}) | |||
.then(function(tpl) { | |||
var tplFunc = _.template(tpl); | |||
return tplFunc({ | |||
plans: plans, | |||
attach: function(plan, state, kind) { | |||
return encodeURIComponent(path.join('attach', plan, state + '~' + kind + '.png')); | |||
} | |||
}); | |||
}) | |||
.then(function(index) { | |||
return fs.write(REPORT_INDEX, index); | |||
}) | |||
.fail(function(error) { | |||
console.log('err', error); | |||
}); | |||
}); | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters