8000 gemini/lib/cli/test.js at v0.3.1 · gemini-testing/gemini · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Latest commit

 

History

History
57 lines (50 loc) · 1.76 KB

test.js

File metadata and controls

57 lines (50 loc) · 1.76 KB
'use strict';
var common = require('./common'),
Config = require('../config'),
Tester = require('../tester');
module.exports = function() {
this.title('Compare current state with previous')
.helpful()
.apply(common.testFiles)
.apply(common.configFile)
.opt()
.name('reporter')
.long('reporter').short('r')
.def('tree')
.val(function(value) {
try {
return require('../reporters/' + value);
} catch(e) {
if (e.code === 'MODULE_NOT_FOUND') {
throw 'No such reporter: ' + value;
}
throw e;
}
})
.end()
.act(function(opts, args) {
var reporter = opts.reporter;
return Config.read(opts.configFile)
.then(function(config) {
return [config, common.buildSuite(args.testFiles)];
})
.spread(function(config, suite) {
var tester = new Tester(config),
exitCode = 0;
tester.on('error', function() {
exitCode = 2;
});
tester.on('endTest', function(result) {
if (!result.equal) {
exitCode = 2;
}
});
reporter(tester);
return tester.run(suite.children)
.then(function() {
return common.exitCoa(exitCode);
});
})
.fail(common.handleErrors);
});
};
0