Skip to content

Commit

Permalink
test: try to fix linux
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Nov 28, 2017
1 parent 1a7b14d commit 463135e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
25 changes: 18 additions & 7 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const spawn = require('child_process').spawn;
const EventEmitter = require('events').EventEmitter;

exports.fixturesDir = path.join(__dirname, 'fixtures');
exports.buildDir = path.join(__dirname, '..', 'out', 'Release');
exports.projectDir = path.join(__dirname, '..');

exports.core = path.join(os.tmpdir(), 'core');
exports.promptDelay = 200;

function llnodeDebug(...args) {
console.error('[TEST]', ...args);
Expand All @@ -25,9 +26,9 @@ if (process.platform === 'darwin')
else if (process.platform === 'windows')
pluginName = 'llnode.dll';
else
pluginName = path.join('lib.target', 'llnode.so');
pluginName = 'llnode.so';

exports.llnodePath = path.join(exports.buildDir, pluginName);
exports.llnodePath = path.join(exports.projectDir, pluginName);
exports.saveCoreTimeout = 180 * 1000;
exports.loadCoreTimeout = 20 * 1000;

Expand All @@ -37,6 +38,7 @@ function SessionOutput(session, stream, timeout) {
this.waitQueue = [];
let buf = '';
this.timeout = timeout || 10000;
this.session = session;

stream.on('data', (data) => {
buf += data;
Expand Down Expand Up @@ -129,7 +131,12 @@ SessionOutput.prototype.wait = function wait(regexp, callback, allLines) {
};

SessionOutput.prototype.waitBreak = function waitBreak(callback) {
this.wait(/Process \d+ stopped/i, callback);
this.wait(/Process \d+ stopped/i, () => {
// Do not resume immediately since the process would print
// the instructions out and input sent before the stdout finish
// could be lost
setTimeout(callback, exports.promptDelay);
});
};

SessionOutput.prototype.linesUntil = function linesUntil(regexp, callback) {
Expand Down Expand Up @@ -210,13 +217,17 @@ Session.prototype.waitCoreLoad = function waitCoreLoad(callback) {
};

Session.prototype.kill = function kill() {
this.lldb.kill();
this.lldb = null;
// if a 'quit' has been sent to lldb, killing it could result in ECONNRESET
if (this.lldb.channel) {
debug('kill lldb');
this.lldb.kill();
this.lldb = null;
}
};

Session.prototype.quit = function quit() {
if (this.needToKill) {
this.send('kill');
this.send('kill'); // kill the process launched in lldb
}
this.send('quit');
};
Expand Down
16 changes: 7 additions & 9 deletions test/usage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,26 @@ tape('usage messages', (t) => {
});

sess.stderr.linesUntil(/USAGE/, (lines) => {
t.ok(/^error: USAGE: v8 print expr$/.test(removeBlankLines(lines)[0]),
'print usage message');
const re = /^error: USAGE: v8 print expr$/;
t.ok(lines.some(line => re.test(line.trim())), 'print usage message');
sess.send('v8 source list');
});

sess.stderr.linesUntil(/USAGE/, (lines) => {
t.ok(/^error: USAGE: v8 source list$/.test(removeBlankLines(lines)[0]),
'list usage message');
const re = /^error: USAGE: v8 source list$/;
t.ok(lines.some(line => re.test(line.trim())), 'list usage message');
sess.send('v8 findjsinstances');
});

sess.stderr.linesUntil(/USAGE/, (lines) => {
const re = /^error: USAGE: v8 findjsinstances \[flags\] instance_name$/;

t.ok(re.test(removeBlankLines(lines)[0]),
'findjsinstances usage message');
t.ok(lines.some(line => re.test(line.trim())), 'findjsinstances usage message');
sess.send('v8 findrefs');
});

sess.stderr.linesUntil(/USAGE/, (lines) => {
t.ok(/^error: USAGE: v8 findrefs expr$/.test(removeBlankLines(lines)[0]),
'findrefs usage message');
const re = /^error: USAGE: v8 findrefs expr$/;
t.ok(lines.some(line => re.test(line.trim())), 'findrefs usage message');
sess.quit();
t.end();
});
Expand Down

0 comments on commit 463135e

Please sign in to comment.