Skip to content

Commit

Permalink
Add a log for elapsed time per each test (jerryscript-project#1104)
Browse files Browse the repository at this point in the history
IoT.js-DCO-1.0-Signed-off-by: Daeyeon Jeong [email protected]
  • Loading branch information
daeyeon authored and yichoi committed Aug 8, 2017
1 parent abcfeab commit 7e22f19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tools/check_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var EventEmitter = require('events').EventEmitter;

var root = 'test';
var parent = '..';
var watch = new util.Watch();

function Driver() {
this.results = {
Expand All @@ -33,24 +34,26 @@ function Driver() {

this.emitter = new EventEmitter();
this.emitter.addListener('nextTest', function(driver, status, test) {
var elapsedTime = ' (' + watch.delta().toFixed(2) + 's) ';

if (driver.runner) {
driver.runner.cleanup();
}
var filename = test['name'];

if (status == 'pass') {
driver.results.pass++;
driver.logger.message('PASS : ' + filename, status);
driver.logger.message('PASS : ' + filename + elapsedTime, status);
} else if (status == 'fail') {
driver.results.fail++;
driver.logger.message('FAIL : ' + filename, status);
driver.logger.message('FAIL : ' + filename + elapsedTime, status);
} else if (status == 'skip') {
driver.results.skip++;
driver.logger.message('SKIP : ' + filename +
' (reason : ' + test.reason + ")", status);
} else if (status == 'timeout') {
driver.results.timeout++;
driver.logger.message('TIMEOUT : ' + filename, status);
driver.logger.message('TIMEOUT : ' + filename + elapsedTime, status);
}
driver.fIdx++;
driver.runNextTest();
Expand Down Expand Up @@ -258,5 +261,6 @@ process.exit = function(code) {

var conf = driver.config();
if (conf) {
watch.delta();
driver.runNextTest();
}
20 changes: 20 additions & 0 deletions tools/common_js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,25 @@ function join() {
return path;
}

function Watch() {
this.reset();
}

Watch.prototype.reset = function() {
this.startTime = 0;
this.elapsedTime = 0;
}

Watch.prototype.delta = function() {
if (this.startTime) {
this.elapsedTime = (Date.now() - this.startTime) / 1000;
}

this.startTime = Date.now();

return this.elapsedTime;
}

module.exports.absolutePath = absolutePath;
module.exports.join = join;
module.exports.Watch = Watch;

0 comments on commit 7e22f19

Please sign in to comment.