You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
JavaScript
88 lines
JavaScript
7 years ago
|
// jshint esversion: 6, browser: false, node: true
|
||
7 years ago
|
// This file is for automated testing, it should probably not be invoked for any other purpose.
|
||
|
// It will:
|
||
|
// 1. npm install
|
||
|
// 2. bower install
|
||
|
// 3. launch the server
|
||
|
// 4. run the tests on the machine
|
||
|
const Spawn = require('child_process').spawn;
|
||
|
|
||
|
const processes = [];
|
||
|
|
||
|
const killAll = (cb) => {
|
||
|
processes.forEach((p) => { p.kill(); });
|
||
|
setTimeout(() => {
|
||
|
processes.forEach((p) => {
|
||
|
console.log("Process [" + p.command + "] did not end, using kill-9");
|
||
|
p.kill('SIGKILL');
|
||
|
});
|
||
|
cb();
|
||
|
}, 10);
|
||
|
};
|
||
|
const error = (msg) => {
|
||
|
killAll(() => {
|
||
|
throw new Error(msg);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
const run = (cmd, args, cb) => {
|
||
|
const proc = Spawn(cmd, args);
|
||
|
processes.push(proc);
|
||
|
proc.procName = cmd + ' ' + args.join(' ');
|
||
|
console.log('>>' + proc.procName);
|
||
|
proc.stdout.on('data', (data) => { process.stdout.write(data); });
|
||
|
proc.stderr.on('data', (data) => { process.stderr.write(data); });
|
||
|
proc.on('close', (code) => {
|
||
|
const idx = processes.indexOf(proc);
|
||
|
if (idx === -1) {
|
||
|
error("process " + proc.procName + " disappeared from list");
|
||
|
return;
|
||
|
}
|
||
|
processes.splice(idx, 1);
|
||
|
if (code) {
|
||
|
error("Process [" + proc.procName + "] ended with " + code);
|
||
|
}
|
||
|
cb();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
run('npm', ['install'], () => {
|
||
|
const nThen = require('nthen');
|
||
|
nThen((waitFor) => {
|
||
7 years ago
|
if (process.platform === 'darwin') {
|
||
7 years ago
|
run('bash', ['-c',
|
||
|
'ps -ef | grep -v grep | grep \'Google Chrome.app/Contents/MacOS/Google Chrome\'' +
|
||
|
' | awk \'{print $2}\' | while read x; do kill $x; done'
|
||
7 years ago
|
], waitFor());
|
||
7 years ago
|
|
||
|
run('bash', ['-c',
|
||
|
'ps -ef | grep -v grep | grep \'/usr/bin/safaridriver\'' +
|
||
|
' | awk \'{print $2}\' | while read x; do kill $x; done'
|
||
|
], waitFor());
|
||
7 years ago
|
|
||
|
run('bash', ['-c',
|
||
|
'ps -ef | grep -v grep | grep \'/Applications/Firefox.app/Contents/MacOS/firefox-bin\'' +
|
||
|
' | awk \'{print $2}\' | while read x; do kill $x; done'
|
||
|
], waitFor());
|
||
7 years ago
|
|
||
|
run('bash', ['-c',
|
||
|
'lsof | grep \'TCP .*:hbci (LISTEN)\'' +
|
||
|
' | awk \'{print $2}\' | while read x; do kill $x; done'
|
||
|
], waitFor());
|
||
7 years ago
|
|
||
7 years ago
|
run('bash', ['-c', 'rm -rf ./blob ./blobstage ./datastore'], waitFor());
|
||
|
|
||
7 years ago
|
run('bash', ['-c', 'caffeinate -u -t 2'], waitFor());
|
||
7 years ago
|
}
|
||
|
}).nThen((waitFor) => {
|
||
7 years ago
|
run('bower', ['install'], waitFor());
|
||
|
}).nThen((waitFor) => {
|
||
|
run('npm', ['run', 'fresh'], ()=>{});
|
||
6 years ago
|
run('node', ['./scripts/TestSelenium.js'], waitFor());
|
||
7 years ago
|
}).nThen((waitFor) => {
|
||
|
if (process.platform === 'darwin') {
|
||
|
run('bash', ['-c', 'pmset displaysleepnow'], waitFor());
|
||
|
}
|
||
7 years ago
|
}).nThen(killAll);
|
||
7 years ago
|
});
|