This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathtest.js
More file actions
61 lines (54 loc) · 1.94 KB
/
Copy pathtest.js
File metadata and controls
61 lines (54 loc) · 1.94 KB
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
'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)
.apply(common.configOverrides)
.opt()
.name('reporters')
.long('reporter').short('r')
.arr()
.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 reporters = opts.reporters;
return Config.read(opts.configFile, opts)
.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;
}
});
reporters.forEach(function(reporter) {
reporter(tester);
});
return tester.run(suite.children)
.then(function() {
return common.exitCoa(exitCode);
});
})
.fail(common.handleErrors);
});
};