forked from wheeler/codeship-meteor-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_test.js
executable file
·49 lines (41 loc) · 1.51 KB
/
start_test.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
#!/usr/bin/env node
var spawn = require('child_process').spawn;
var fs = require('fs');
var workingDir = process.env.WORKING_DIR || process.env.PACKAGE_DIR || './';
var args = ['test-packages', '--once', '--driver-package', 'test-in-console', '-p', 10015];
if (typeof process.env.METEOR_RELEASE !== 'undefined' &&
process.env.METEOR_RELEASE !== '') {
args.push('--release');
args.push(process.env.METEOR_RELEASE);
}
if (typeof process.env.PACKAGES === 'undefined' && fs.existsSync(workingDir + 'package.js')) {
args.push('./');
}
else if (typeof process.env.PACKAGES !== 'undefined' && process.env.PACKAGES !== '') {
args = args.concat(process.env.PACKAGES.split(';'));
}
var meteor = spawn((process.env.TEST_COMMAND || 'meteor'), args, {cwd: workingDir});
meteor.stdout.pipe(process.stdout);
meteor.stderr.pipe(process.stderr);
meteor.on('close', function (code) {
console.log('meteor exited with code ' + code);
process.exit(code);
});
meteor.stdout.on('data', function startTesting(data) {
data = data.toString();
if(data.match(/10015|test-in-console listening/)) {
console.log('starting testing...');
meteor.stdout.removeListener('data', startTesting);
runTestSuite();
}
});
function runTestSuite() {
process.env.URL = "http://localhost:10015/";
var phantomjs = spawn('phantomjs', ['./phantom_runner.js']);
phantomjs.stdout.pipe(process.stdout);
phantomjs.stderr.pipe(process.stderr);
phantomjs.on('close', function(code) {
meteor.kill('SIGQUIT');
process.exit(code);
});
}