Skip to content

Commit

Permalink
test: add containsLine function
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Nov 30, 2017
1 parent dd401ff commit 65c577c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/usage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
const tape = require('tape');
const common = require('./common');

function containsLine(lines, re) {
return lines.some(line => re.test(line.trim()));
}

tape('usage messages', (t) => {
t.timeoutAfter(15000);

Expand All @@ -15,29 +19,28 @@ tape('usage messages', (t) => {
sess.stderr.linesUntil(/USAGE/, (err, lines) => {
t.error(err);
const re = /^error: USAGE: v8 print expr$/;
t.ok(lines.some(line => re.test(line.trim())), 'print usage message');
t.ok(containsLine(lines, re), 'print usage message');
sess.send('v8 source list');
});

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

sess.stderr.linesUntil(/USAGE/, (err, lines) => {
t.error(err);
const re = /^error: USAGE: v8 findjsinstances \[flags\] instance_name$/;
t.ok(lines.some(line => re.test(line.trim())),
'findjsinstances usage message');
t.ok(containsLine(lines, re), 'findjsinstances usage message');
sess.send('v8 findrefs');
});

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

0 comments on commit 65c577c

Please sign in to comment.