Add script to run specs in CI, fixes #61.
This commit is contained in:
parent
0cd3f3cc40
commit
d160da7752
4 changed files with 47 additions and 2 deletions
8
script/cibuild
Executable file
8
script/cibuild
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
test = os.path.join(os.path.dirname(__file__), 'test.py')
|
||||||
|
subprocess.check_call([test, '--ci'])
|
|
@ -17,7 +17,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
atom_shell = os.path.join(SOURCE_ROOT, 'out', 'Debug', 'atom.exe')
|
atom_shell = os.path.join(SOURCE_ROOT, 'out', 'Debug', 'atom.exe')
|
||||||
|
|
||||||
subprocess.check_call([atom_shell, 'spec'])
|
subprocess.check_call([atom_shell, 'spec'] + sys.argv[1:])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -15,6 +15,21 @@
|
||||||
|
|
||||||
require('coffee-script'); // Supports .coffee tests.
|
require('coffee-script'); // Supports .coffee tests.
|
||||||
|
|
||||||
|
// Rediret all output to browser.
|
||||||
|
var ipc = require('ipc');
|
||||||
|
global.__defineGetter__('console', function() {
|
||||||
|
return {
|
||||||
|
log: function() {
|
||||||
|
args = Array.prototype.slice.call(arguments);
|
||||||
|
ipc.sendChannel('console.log', args);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
args = Array.prototype.slice.call(arguments);
|
||||||
|
ipc.sendChannel('console.error', args);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var Mocha = require('mocha');
|
var Mocha = require('mocha');
|
||||||
|
|
||||||
var mocha = new Mocha();
|
var mocha = new Mocha();
|
||||||
|
@ -24,6 +39,14 @@
|
||||||
if (query.grep) mocha.grep(query.grep);
|
if (query.grep) mocha.grep(query.grep);
|
||||||
if (query.invert) mocha.invert();
|
if (query.invert) mocha.invert();
|
||||||
|
|
||||||
|
// Check if we are running in CI.
|
||||||
|
var argv = require('remote').process.argv;
|
||||||
|
var isCi = false;
|
||||||
|
if (argv[1] == '--ci') {
|
||||||
|
isCi = true;
|
||||||
|
mocha.reporter('tap');
|
||||||
|
}
|
||||||
|
|
||||||
// Read all test files.
|
// Read all test files.
|
||||||
var walker = require('walkdir').walk(__dirname);
|
var walker = require('walkdir').walk(__dirname);
|
||||||
|
|
||||||
|
@ -33,8 +56,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
walker.on('end', function() {
|
walker.on('end', function() {
|
||||||
mocha.run(function() {
|
var runner = mocha.run(function() {
|
||||||
Mocha.utils.highlightTags('code');
|
Mocha.utils.highlightTags('code');
|
||||||
|
if (isCi)
|
||||||
|
ipc.sendChannel('process.exit', runner.failures);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
12
spec/main.js
12
spec/main.js
|
@ -10,6 +10,18 @@ ipc.on('message', function() {
|
||||||
ipc.send.apply(this, arguments);
|
ipc.send.apply(this, arguments);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipc.on('console.log', function(pid, rid, args) {
|
||||||
|
console.log.apply(console, args);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipc.on('console.error', function(pid, rid, args) {
|
||||||
|
console.log.apply(console, args);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipc.on('process.exit', function(pid, rid, code) {
|
||||||
|
process.exit(code);
|
||||||
|
});
|
||||||
|
|
||||||
process.on('uncaughtException', function() {
|
process.on('uncaughtException', function() {
|
||||||
window.openDevTools();
|
window.openDevTools();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue