diff options
author | Rich Trott <rtrott@gmail.com> | 2016-04-05 17:17:33 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2016-04-14 10:53:07 -0700 |
commit | 1df84f4f75843ad01d95dc55d63ba30b2b69fbd4 (patch) | |
tree | 0334d5a568202fca7c60ebfdcbf2a6ea001ef86d /test | |
parent | b68827b1d1c20d0f3e0592734e845b87967a72bc (diff) | |
download | android-node-v8-1df84f4f75843ad01d95dc55d63ba30b2b69fbd4.tar.gz android-node-v8-1df84f4f75843ad01d95dc55d63ba30b2b69fbd4.tar.bz2 android-node-v8-1df84f4f75843ad01d95dc55d63ba30b2b69fbd4.zip |
debugger: run last command on presssing enter
PR-URL: https://github.com/nodejs/node/pull/6090
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Fixes: https://github.com/nodejs/node/issues/2895
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/debugger-repeat-last.js | 7 | ||||
-rw-r--r-- | test/parallel/test-debugger-repeat-last.js | 46 |
2 files changed, 53 insertions, 0 deletions
diff --git a/test/fixtures/debugger-repeat-last.js b/test/fixtures/debugger-repeat-last.js new file mode 100644 index 0000000000..86df8eebcb --- /dev/null +++ b/test/fixtures/debugger-repeat-last.js @@ -0,0 +1,7 @@ +var a = 1; + +var b = 2; + +var c = 3; + +b = c; diff --git a/test/parallel/test-debugger-repeat-last.js b/test/parallel/test-debugger-repeat-last.js new file mode 100644 index 0000000000..7f0e1e6816 --- /dev/null +++ b/test/parallel/test-debugger-repeat-last.js @@ -0,0 +1,46 @@ +'use strict'; +const path = require('path'); +const spawn = require('child_process').spawn; +const assert = require('assert'); + +const common = require('../common'); + +const fixture = path.join( + common.fixturesDir, + 'debugger-repeat-last.js' +); + +const args = [ + 'debug', + fixture +]; + +const proc = spawn(process.execPath, args, { stdio: 'pipe' }); +proc.stdout.setEncoding('utf8'); + +var stdout = ''; + +var sentCommand = false; +var sentEmpty = false; +var sentExit = false; + +proc.stdout.on('data', (data) => { + stdout += data; + if (!sentCommand && stdout.includes('> 1')) { + setImmediate(() => {proc.stdin.write('n\n');}); + return sentCommand = true; + } + if (!sentEmpty && stdout.includes('> 3')) { + setImmediate(() => {proc.stdin.write('\n');}); + return sentEmpty = true; + } + if (!sentExit && sentCommand && sentEmpty) { + setTimeout(() => {proc.stdin.write('\n\n\n.exit\n\n\n');}, 1); + return sentExit = true; + } +}); + +process.on('exit', (exitCode) => { + assert.strictEqual(exitCode, 0); + console.log(stdout); +}); |