-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstub-driver.js
49 lines (42 loc) · 1.49 KB
/
stub-driver.js
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
/**
* Module depenencies
*/
var _ = require('@sailshq/lodash');
var runAllTests = require('./run-all-tests');
/**
* Stub/default implementation of a generic test driver
* @param {[type]} pathToMachinepack [description]
*/
module.exports = function stubDriver(pathToMachinepack) {
runAllTests(pathToMachinepack, function beforeRunningAnyTests(opts, done){
done();
}, function eachMachineSuite(machineIdentity, runTests){
console.log('\n\ntesting `'+machineIdentity+'` machine...\n================================\n');
runTests(function onTest(testCase, nextTestCase){
var jsonInputVals;
try {
jsonInputVals = JSON.stringify(testCase.using);
}
catch (e) {
}
if (testCase.todo) {
console.log('\n • skipping test marked as "TODO" :: (should exit with `'+testCase.outcome+'`'+(_.isUndefined(jsonInputVals)?'':' given input values: `'+jsonInputVals+'`)') );
return nextTestCase();
}
return nextTestCase(function (err) {
console.log('\n • should exit with `'+testCase.outcome+'`'+ (_.isUndefined(jsonInputVals)?'':' given input values: `'+jsonInputVals+'`'));
if (err) {
console.error(' (X) failed - '+err);
return;
}
console.log(' (+) passed');
return;
});
});
}, function afterRunningAllTests(err) {
if (err) {
console.error('finished with error:',(_.isObject(err)&&err.stack)||err);
}
console.log('finished successfully');
});
};