Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
npm-debug.log
/tmp
/.vs
13 changes: 13 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
environment:
nodejs_version: "6"

install:
- ps: Install-Product node $env:nodejs_version
- npm install

test_script:
- node --version
- npm --version
- npm test

build: off
2 changes: 1 addition & 1 deletion lib/internal/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function isNativeUrl(url) {
}

function getRelativePath(filename) {
const dir = `${Path.resolve()}/`;
const dir = Path.join(Path.resolve(), 'x').slice(0, -1);

// Change path to relative, if possible
if (filename.indexOf(dir) === 0) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"scripts": {
"pretest": "eslint --rulesdir=tools/eslint-rules lib test",
"test": "tap 'test/**/*.test.js'",
"test": "tap \"test/**/*.test.js\"",
"posttest": "nlm verify"
},
"nlm": {
Expand All @@ -28,7 +28,7 @@
"dependencies": {},
"devDependencies": {
"eslint": "^3.10.2",
"nlm": "^2.0.0",
"nlm": "^3.0.0",
"tap": "^7.1.2"
},
"author": {
Expand Down
9 changes: 6 additions & 3 deletions test/cli/backtrace.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';
const Path = require('path');

const { test } = require('tap');

const startCLI = require('./start-cli');

test('display and navigate backtrace', (t) => {
const cli = startCLI(['examples/backtrace.js']);
const script = Path.join('examples', 'backtrace.js');
const cli = startCLI([script]);

function onFatal(error) {
cli.quit();
Expand All @@ -16,11 +19,11 @@ test('display and navigate backtrace', (t) => {
.then(() => cli.stepCommand('c'))
.then(() => cli.command('bt'))
.then(() => {
t.match(cli.output, '#0 topFn examples/backtrace.js:8:2');
t.match(cli.output, `#0 topFn ${script}:8:2`);
})
.then(() => cli.command('backtrace'))
.then(() => {
t.match(cli.output, '#0 topFn examples/backtrace.js:8:2');
t.match(cli.output, `#0 topFn ${script}:8:2`);
})
.then(() => cli.quit())
.then(null, onFatal);
Expand Down
40 changes: 23 additions & 17 deletions test/cli/break.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';
const Path = require('path');

const { test } = require('tap');

const startCLI = require('./start-cli');

test('stepping through breakpoints', (t) => {
const cli = startCLI(['examples/break.js']);
const script = Path.join('examples', 'break.js');
const cli = startCLI([script]);

function onFatal(error) {
cli.quit();
Expand All @@ -16,7 +19,7 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/break.js:1',
`break in ${script}:1`,
'pauses in the first line of the script');
t.match(
cli.output,
Expand All @@ -27,7 +30,7 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/break.js:2',
`break in ${script}:2`,
'pauses in next line of the script');
t.match(
cli.output,
Expand All @@ -38,7 +41,7 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/break.js:3',
`break in ${script}:3`,
'pauses in next line of the script');
t.match(
cli.output,
Expand All @@ -49,7 +52,7 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/break.js:10',
`break in ${script}:10`,
'pauses on the next breakpoint');
t.match(
cli.output,
Expand All @@ -65,8 +68,8 @@ test('stepping through breakpoints', (t) => {
.then(() => t.notMatch(cli.output, 'Could not resolve breakpoint'))
.then(() => cli.command('breakpoints'))
.then(() => {
t.match(cli.output, '#0 examples/break.js:6');
t.match(cli.output, '#1 examples/break.js:16');
t.match(cli.output, `#0 ${script}:6`);
t.match(cli.output, `#1 ${script}:16`);
})

.then(() => cli.command('list()'))
Expand Down Expand Up @@ -98,29 +101,31 @@ test('stepping through breakpoints', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/break.js:16',
`break in ${script}:16`,
'found breakpoint we set above w/ line number only');
})
.then(() => cli.stepCommand('cont'))
.then(() => {
t.match(
cli.output,
'break in examples/break.js:6',
`break in ${script}:6`,
'found breakpoint we set above w/ line number & script');
})
.then(() => cli.stepCommand(''))
.then(() => {
t.match(
cli.output,
'debugCommand in examples/break.js:14',
`debugCommand in ${script}:14`,
'found function breakpoint we set above');
})
.then(() => cli.quit())
.then(null, onFatal);
});

test('sb before loading file', (t) => {
const cli = startCLI(['examples/cjs/index.js']);
const script = Path.join('examples', 'cjs', 'index.js');
const otherScript = Path.join('examples', 'cjs', 'other.js');
const cli = startCLI([script]);

function onFatal(error) {
cli.quit();
Expand All @@ -140,15 +145,16 @@ test('sb before loading file', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/cjs/other.js:3',
`break in ${otherScript}:3`,
'found breakpoint in file that was not loaded yet');
})
.then(() => cli.quit())
.then(null, onFatal);
});

test('clearBreakpoint', (t) => {
const cli = startCLI(['examples/break.js']);
const script = Path.join('examples', 'break.js');
const cli = startCLI([script]);

function onFatal(error) {
cli.quit();
Expand All @@ -161,8 +167,8 @@ test('clearBreakpoint', (t) => {
.then(() => cli.command('sb("break.js", 9)'))
.then(() => cli.command('breakpoints'))
.then(() => {
t.match(cli.output, '#0 examples/break.js:3');
t.match(cli.output, '#1 examples/break.js:9');
t.match(cli.output, `#0 ${script}:3`);
t.match(cli.output, `#1 ${script}:9`);
})
.then(() => cli.command('clearBreakpoint("break.js", 4)'))
.then(() => {
Expand All @@ -175,13 +181,13 @@ test('clearBreakpoint', (t) => {
.then(() => cli.command('clearBreakpoint("break.js", 3)'))
.then(() => cli.command('breakpoints'))
.then(() => {
t.match(cli.output, '#0 examples/break.js:9');
t.match(cli.output, `#0 ${script}:9`);
})
.then(() => cli.stepCommand('cont'))
.then(() => {
t.match(
cli.output,
'break in examples/break.js:9',
`break in ${script}:9`,
'hits the 2nd breakpoint because the 1st was cleared');
})
.then(() => cli.quit())
Expand Down
19 changes: 11 additions & 8 deletions test/cli/exceptions.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';
const Path = require('path');

const { test } = require('tap');

const startCLI = require('./start-cli');

test('break on (uncaught) exceptions', (t) => {
const cli = startCLI(['examples/exceptions.js']);
const script = Path.join('examples', 'exceptions.js');
const cli = startCLI([script]);

function onFatal(error) {
cli.quit();
Expand All @@ -14,7 +17,7 @@ test('break on (uncaught) exceptions', (t) => {
return cli.waitFor(/break/)
.then(() => cli.waitForPrompt())
.then(() => {
t.match(cli.output, 'break in examples/exceptions.js:1');
t.match(cli.output, `break in ${script}:1`);
})
// making sure it will die by default:
.then(() => cli.command('c'))
Expand All @@ -23,34 +26,34 @@ test('break on (uncaught) exceptions', (t) => {
// Next run: With `breakOnException` it pauses in both places
.then(() => cli.stepCommand('r'))
.then(() => {
t.match(cli.output, 'break in examples/exceptions.js:1');
t.match(cli.output, `break in ${script}:1`);
})
.then(() => cli.command('breakOnException'))
.then(() => cli.stepCommand('c'))
.then(() => {
t.match(cli.output, 'exception in examples/exceptions.js:4');
t.match(cli.output, `exception in ${script}:4`);
})
.then(() => cli.stepCommand('c'))
.then(() => {
t.match(cli.output, 'exception in examples/exceptions.js:10');
t.match(cli.output, `exception in ${script}:10`);
})

// Next run: With `breakOnUncaught` it only pauses on the 2nd exception
.then(() => cli.command('breakOnUncaught'))
.then(() => cli.stepCommand('r')) // also, the setting survives the restart
.then(() => {
t.match(cli.output, 'break in examples/exceptions.js:1');
t.match(cli.output, `break in ${script}:1`);
})
.then(() => cli.stepCommand('c'))
.then(() => {
t.match(cli.output, 'exception in examples/exceptions.js:10');
t.match(cli.output, `exception in ${script}:10`);
})

// Next run: Back to the initial state! It should die again.
.then(() => cli.command('breakOnNone'))
.then(() => cli.stepCommand('r'))
.then(() => {
t.match(cli.output, 'break in examples/exceptions.js:1');
t.match(cli.output, `break in ${script}:1`);
})
.then(() => cli.command('c'))
.then(() => cli.waitFor(/disconnect/))
Expand Down
22 changes: 15 additions & 7 deletions test/cli/launch.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';
const Path = require('path');

const { test } = require('tap');

const startCLI = require('./start-cli');

test('examples/empty.js', (t) => {
const cli = startCLI(['examples/empty.js']);
const script = Path.join('examples', 'empty.js');
const cli = startCLI([script]);
return cli.waitForPrompt()
.then(() => {
t.match(cli.output, 'debug>', 'prints a prompt');
Expand Down Expand Up @@ -32,7 +35,8 @@ test('examples/empty.js', (t) => {
});

test('run after quit / restart', (t) => {
const cli = startCLI(['examples/three-lines.js']);
const script = Path.join('examples', 'three-lines.js');
const cli = startCLI([script]);

function onFatal(error) {
cli.quit();
Expand All @@ -45,7 +49,7 @@ test('run after quit / restart', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/three-lines.js:2',
`break in ${script}:2`,
'steps to the 2nd line');
})
.then(() => cli.command('cont'))
Expand All @@ -56,6 +60,10 @@ test('run after quit / restart', (t) => {
'Waiting for the debugger to disconnect',
'the child was done');
})
.then(() => {
// On windows the socket won't close by itself
return cli.command('kill');
})
.then(() => cli.command('cont'))
.then(() => cli.waitFor(/start the app/))
.then(() => {
Expand All @@ -66,21 +74,21 @@ test('run after quit / restart', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/three-lines.js:1',
`break in ${script}:1`,
'is back at the beginning');
})
.then(() => cli.stepCommand('n'))
.then(() => {
t.match(
cli.output,
'break in examples/three-lines.js:2',
`break in ${script}:2`,
'steps to the 2nd line');
})
.then(() => cli.stepCommand('restart'))
.then(() => {
t.match(
cli.output,
'break in examples/three-lines.js:1',
`break in ${script}:1`,
'is back at the beginning');
})
.then(() => cli.command('kill'))
Expand All @@ -94,7 +102,7 @@ test('run after quit / restart', (t) => {
.then(() => {
t.match(
cli.output,
'break in examples/three-lines.js:1',
`break in ${script}:1`,
'is back at the beginning');
})
.then(() => cli.quit())
Expand Down
3 changes: 2 additions & 1 deletion test/cli/low-level.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const startCLI = require('./start-cli');

test('Debugger agent direct access', (t) => {
const cli = startCLI(['examples/empty.js']);
const scriptPattern = /^\* (\d+): examples(?:\/|\\)empty.js/;

function onFatal(error) {
cli.quit();
Expand All @@ -15,7 +16,7 @@ test('Debugger agent direct access', (t) => {
.then(() => cli.waitForPrompt())
.then(() => cli.command('scripts'))
.then(() => {
const [, scriptId] = cli.output.match(/^\* (\d+): examples\/empty.js/);
const [, scriptId] = cli.output.match(scriptPattern);
return cli.command(
`Debugger.getScriptSource({ scriptId: '${scriptId}' })`
);
Expand Down
Loading