diff --git a/Makefile b/Makefile index 274df0745871cf..e9c5a2e6bbcf17 100644 --- a/Makefile +++ b/Makefile @@ -386,9 +386,6 @@ test-pummel: all test-internet: all $(PYTHON) tools/test.py internet -test-debugger: all - $(PYTHON) tools/test.py debugger - test-inspector: all $(PYTHON) tools/test.py inspector diff --git a/doc/api/debugger.md b/doc/api/debugger.md index b27d83bee34ea0..b0da263f5947b4 100644 --- a/doc/api/debugger.md +++ b/doc/api/debugger.md @@ -125,18 +125,18 @@ It is also possible to set a breakpoint in a file (module) that is not loaded yet: ```txt -$ node inspect test/fixtures/break-in-module/main.js +$ node inspect main.js < Debugger listening on ws://127.0.0.1:9229/4e3db158-9791-4274-8909-914f7facf3bd < For help see https://nodejs.org/en/docs/inspector < Debugger attached. -Break on start in test/fixtures/break-in-module/main.js:1 +Break on start in main.js:1 > 1 (function (exports, require, module, __filename, __dirname) { const mod = require('./mod.js'); 2 mod.hello(); 3 mod.hello(); debug> setBreakpoint('mod.js', 22) Warning: script 'mod.js' was not loaded yet. debug> c -break in test/fixtures/break-in-module/mod.js:22 +break in mod.js:22 20 // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 >22 exports.hello = function() { diff --git a/test/README.md b/test/README.md index 0f3660fbe45da0..3849f32543c69d 100644 --- a/test/README.md +++ b/test/README.md @@ -16,7 +16,6 @@ On how to run tests in this directory, see |addons |Yes |Tests for [addon](https://nodejs.org/api/addons.html) functionality along with some tests that require an addon to function properly.| |cctest |Yes |C++ test that is run as part of the build process.| |common | |Common modules shared among many tests. [Documentation](./common/README.md)| -|debugger |No |Tests for [debugger](https://nodejs.org/api/debugger.html) functionality along with some tests that require an addon to function properly.| |fixtures | |Test fixtures used in various tests throughout the test suite.| |gc |No |Tests for garbage collection related functionality.| |inspector |Yes |Tests for the V8 inspector integration.| diff --git a/test/debugger/helper-debugger-repl.js b/test/debugger/helper-debugger-repl.js deleted file mode 100644 index 365b29e50d6556..00000000000000 --- a/test/debugger/helper-debugger-repl.js +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const spawn = require('child_process').spawn; - -process.env.NODE_DEBUGGER_TIMEOUT = 2000; -const port = common.PORT; - -let child; -let buffer = ''; -const expected = []; -let quit; - -function startDebugger(scriptToDebug) { - scriptToDebug = process.env.NODE_DEBUGGER_TEST_SCRIPT || - `${common.fixturesDir}/${scriptToDebug}`; - - child = spawn(process.execPath, ['debug', `--port=${port}`, scriptToDebug]); - - console.error('./node', 'debug', `--port=${port}`, scriptToDebug); - - child.stdout.setEncoding('utf-8'); - child.stdout.on('data', function(data) { - data = (buffer + data).split('\n'); - buffer = data.pop(); - data.forEach(function(line) { - child.emit('line', line); - }); - }); - child.stderr.pipe(process.stderr); - - child.on('line', function(line) { - line = line.replace(/^(?:debug> *)+/, ''); - console.log(line); - assert.ok(expected.length > 0, `Got unexpected line: ${line}`); - - const expectedLine = expected[0].lines.shift(); - assert.ok(expectedLine.test(line), `${line} != ${expectedLine}`); - - if (expected[0].lines.length === 0) { - const callback = expected[0].callback; - expected.shift(); - callback && callback(); - } - }); - - let childClosed = false; - child.on('close', function(code) { - assert(!code); - childClosed = true; - }); - - let quitCalled = false; - quit = function() { - if (quitCalled || childClosed) return; - quitCalled = true; - child.stdin.write('quit'); - child.kill('SIGTERM'); - }; - - setTimeout(function() { - console.error('dying badly buffer=%j', buffer); - let err = 'Timeout'; - if (expected.length > 0 && expected[0].lines) { - err = `${err}. Expected: ${expected[0].lines.shift()}`; - } - - child.on('close', function() { - console.error('child is closed'); - throw new Error(err); - }); - - quit(); - }, 10000).unref(); - - process.once('uncaughtException', function(e) { - console.error('UncaughtException', e, e.stack); - quit(); - console.error(e.toString()); - process.exit(1); - }); - - process.on('exit', function(code) { - console.error('process exit', code); - quit(); - if (code === 0) - assert(childClosed); - }); -} - -function addTest(input, output) { - function next() { - if (expected.length > 0) { - console.log(`debug> ${expected[0].input}`); - child.stdin.write(`${expected[0].input}\n`); - - if (!expected[0].lines) { - const callback = expected[0].callback; - expected.shift(); - - callback && callback(); - } - } else { - quit(); - } - } - expected.push({ input: input, lines: output, callback: next }); -} - -const handshakeLines = [ - /listening on /, - /connecting.* ok/ -]; - -const initialBreakLines = [ - /break in .*:1/, - /1/, /2/, /3/ -]; - -const initialLines = handshakeLines.concat(initialBreakLines); - -// Process initial lines -addTest(null, initialLines); - -exports.startDebugger = startDebugger; -exports.addTest = addTest; -exports.initialLines = initialLines; -exports.handshakeLines = handshakeLines; -exports.initialBreakLines = initialBreakLines; diff --git a/test/debugger/test-debugger-repl-break-in-module.js b/test/debugger/test-debugger-repl-break-in-module.js deleted file mode 100644 index d428b7a6fcaa21..00000000000000 --- a/test/debugger/test-debugger-repl-break-in-module.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -require('../common'); -const repl = require('./helper-debugger-repl.js'); - -repl.startDebugger('break-in-module/main.js'); - -// -- SET BREAKPOINT -- - -// Set breakpoint by file name + line number where the file is not loaded yet -repl.addTest('sb("mod.js", 2)', [ - /Warning: script 'mod\.js' was not loaded yet\./, - /1/, /2/, /3/, /4/, /5/, /6/ -]); - -// Check escaping of regex characters -repl.addTest('sb(")^$*+?}{|][(.js\\\\", 1)', [ - /Warning: script '[^']+' was not loaded yet\./, - /1/, /2/, /3/, /4/, /5/, /6/ -]); - -// continue - the breakpoint should be triggered -repl.addTest('c', [ - /break in .*[\\/]mod\.js:2/, - /1/, /2/, /3/, /4/ -]); - -// -- RESTORE BREAKPOINT ON RESTART -- - -// Restart the application - breakpoint should be restored -repl.addTest('restart', [].concat( - [ - /terminated/ - ], - repl.handshakeLines, - [ - /Restoring breakpoint mod\.js:2/, - /Warning: script 'mod\.js' was not loaded yet\./, - /Restoring breakpoint \).*:\d+/, - /Warning: script '\)[^']*' was not loaded yet\./ - ], - repl.initialBreakLines)); - -// continue - the breakpoint should be triggered -repl.addTest('c', [ - /break in .*[\\/]mod\.js:2/, - /1/, /2/, /3/, /4/ -]); - -// -- CLEAR BREAKPOINT SET IN MODULE TO BE LOADED -- - -repl.addTest('cb("mod.js", 2)', [ - /1/, /2/, /3/, /4/, /5/ -]); - -repl.addTest('c', [ - /break in .*[\\/]main\.js:4/, - /2/, /3/, /4/, /5/, /6/ -]); - -// -- (END) -- -repl.addTest('quit', []); diff --git a/test/debugger/test-debugger-repl-restart.js b/test/debugger/test-debugger-repl-restart.js deleted file mode 100644 index 5345702ca72a67..00000000000000 --- a/test/debugger/test-debugger-repl-restart.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -require('../common'); -const repl = require('./helper-debugger-repl.js'); - -repl.startDebugger('breakpoints.js'); -const linesWithBreakpoint = [ - /1/, /2/, /3/, /4/, /5/, /\* 6/ -]; -// We slice here, because addTest will change the given array. -repl.addTest('sb(6)', linesWithBreakpoint.slice()); - -const initialLines = repl.initialLines.slice(); -initialLines.splice(2, 0, /Restoring/, /Warning/); - -// Restart the debugged script -repl.addTest('restart', [ - /terminated/, -].concat(initialLines)); - -repl.addTest('list(5)', linesWithBreakpoint); -repl.addTest('quit', []); diff --git a/test/debugger/test-debugger-repl-term.js b/test/debugger/test-debugger-repl-term.js deleted file mode 100644 index 0155df51b262b7..00000000000000 --- a/test/debugger/test-debugger-repl-term.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -require('../common'); -process.env.NODE_FORCE_READLINE = 1; - -const repl = require('./helper-debugger-repl.js'); - -repl.startDebugger('breakpoints.js'); - -const addTest = repl.addTest; - -// next -addTest('n', [ - /debug>.*n/, - /break in .*:11/, - /9/, /10/, /11/, /12/, /13/ -]); - -// should repeat next -addTest('', [ - /debug>/, - /break in .*:5/, - /3/, /4/, /5/, /6/, /7/, -]); - -// continue -addTest('c', [ - /debug>.*c/, - /break in .*:12/, - /10/, /11/, /12/, /13/, /14/ -]); - -// should repeat continue -addTest('', [ - /debug>/, - /break in .*:5/, - /3/, /4/, /5/, /6/, /7/, -]); - -// should repeat continue -addTest('', [ - /debug>/, - /break in .*:23/, - /21/, /22/, /23/, /24/, /25/, -]); diff --git a/test/debugger/test-debugger-repl-utf8.js b/test/debugger/test-debugger-repl-utf8.js deleted file mode 100644 index 76e604dd231d7e..00000000000000 --- a/test/debugger/test-debugger-repl-utf8.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -const common = require('../common'); -const script = `${common.fixturesDir}/breakpoints_utf8.js`; -process.env.NODE_DEBUGGER_TEST_SCRIPT = script; - -require('./test-debugger-repl.js'); diff --git a/test/debugger/test-debugger-repl.js b/test/debugger/test-debugger-repl.js deleted file mode 100644 index 35bb72832b14c8..00000000000000 --- a/test/debugger/test-debugger-repl.js +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -const common = require('../common'); -const repl = require('./helper-debugger-repl.js'); - -repl.startDebugger('breakpoints.js'); - -const addTest = repl.addTest; - -// Next -addTest('n', [ - /break in .*:11/, - /9/, /10/, /11/, /12/, /13/ -]); - -// Watch -addTest('watch("\'x\'")'); - -// Continue -addTest('c', [ - /break in .*:5/, - /Watchers/, - /0:\s+'x' = "x"/, - /()/, - /3/, /4/, /5/, /6/, /7/ -]); - -// Show watchers -addTest('watchers', [ - /0:\s+'x' = "x"/ -]); - -// Unwatch -addTest('unwatch("\'x\'")'); - -// Step out -addTest('o', [ - /break in .*:12/, - /10/, /11/, /12/, /13/, /14/ -]); - -// Continue -addTest('c', [ - /break in .*:5/, - /3/, /4/, /5/, /6/, /7/ -]); - -// Set breakpoint by function name -addTest('sb("setInterval()", "!(setInterval.flag++)")', [ - /1/, /2/, /3/, /4/, /5/, /6/, /7/, /8/, /9/, /10/ -]); - -// Continue -addTest('c', [ - /break in timers\.js:\d+/, - /\d/, /\d/, /\d/, /\d/, /\d/ -]); - -// Execute -addTest('exec process.title', [ - common.isFreeBSD || common.isOSX || common.isLinux ? /node/ : '' -]); - -// Execute -addTest('exec exec process.title', [ - /SyntaxError: Unexpected identifier/ -]); - -// REPL and process.env regression -addTest('repl', [ - /Ctrl/ -]); - -addTest('for (var i in process.env) delete process.env[i]', []); - -addTest('process.env', [ - /\{\}/ -]); - -addTest('arr = [{foo: "bar"}]', [ - /\[ \{ foo: 'bar' \} \]/ -]); diff --git a/test/debugger/testcfg.py b/test/debugger/testcfg.py deleted file mode 100644 index 4aee90b3eb0154..00000000000000 --- a/test/debugger/testcfg.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys, os -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) -import testpy - -def GetConfiguration(context, root): - return testpy.SimpleTestConfiguration(context, root, 'debugger') diff --git a/test/fixtures/break-in-module/main.js b/test/fixtures/break-in-module/main.js deleted file mode 100644 index cfb44c766abac3..00000000000000 --- a/test/fixtures/break-in-module/main.js +++ /dev/null @@ -1,4 +0,0 @@ -const mod = require('./mod.js'); -mod.hello(); -mod.hello(); -debugger; diff --git a/test/fixtures/break-in-module/mod.js b/test/fixtures/break-in-module/mod.js deleted file mode 100644 index 57bf58bb31aa11..00000000000000 --- a/test/fixtures/break-in-module/mod.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -exports.hello = function() { - return 'hello from module'; -}; diff --git a/test/fixtures/breakpoints.js b/test/fixtures/breakpoints.js deleted file mode 100644 index 43cfca1c9b11ab..00000000000000 --- a/test/fixtures/breakpoints.js +++ /dev/null @@ -1,23 +0,0 @@ -debugger; -function a(x) { - var i = 10; - while (--i != 0); - debugger; - return i; -} -function b() { - return ['hello', 'world'].join(' '); -} -a(); -debugger; -a(1); -b(); -b(); - - -setInterval(function() { -}, 5000); - - -now = new Date(); -debugger; diff --git a/test/fixtures/breakpoints_utf8.js b/test/fixtures/breakpoints_utf8.js deleted file mode 100644 index 8f0eb9dfc117e6..00000000000000 --- a/test/fixtures/breakpoints_utf8.js +++ /dev/null @@ -1,23 +0,0 @@ -debugger; -function a(x) { - var i = 10; - while (--i != 0); - debugger; - return i; -} -function b() { - return ['こんにち', 'わ'].join(' '); -} -a(); -a(1); -b(); -b(); - - - -setInterval(function() { -}, 5000); - - -now = new Date(); -debugger;