Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
debugger: Add a test for 'debug> ' prompt.
  • Loading branch information
lance committed Dec 5, 2016
commit 2909c6a7f924c8126ee5fb114c6ff48a4c9296eb
18 changes: 18 additions & 0 deletions test/parallel/test-debug-prompt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const assert = require('assert');
const common = require('../common');
const spawn = require('child_process').spawn;

const timeoutId = setTimeout(function() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the timeout needed? Couldn't we just let the test timeout and fail instead of introducing a timer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it is redundant. I was just modeling off of another test that spawns a node process.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, if you don't need it, I'd remove it. They add complexity to the code and timers have been a source of annoyance on the CI.

common.fail('test-debug-prompt timeout failure');
}, common.platformTimeout(5000));

const proc = spawn(process.execPath, ['debug', 'foo']);
proc.stdout.setEncoding('utf8');

proc.stdout.once('data', common.mustCall((data) => {
clearTimeout(timeoutId);
assert.strictEqual(data, 'debug> ');
proc.kill();
}));