Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 177ab47

Browse files
authored
Make tests green again! (#2273)
* fix tests * update browser for linux agent? * update * update * fix: race in breakpoint verification * log * ty * rm console logs
1 parent 3a4bd76 commit 177ab47

16 files changed

+116
-64
lines changed

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"prepare": "husky install",
3939
"package": "gulp package",
4040
"publish": "gulp publish",
41-
"postinstall": "playwright install chromium",
41+
"postinstall": "playwright install chromium --with-deps --only-shell",
4242
"precommit": "npm-run-all --parallel test:lint test:types",
4343
"updatetypes": "cd src/typings && npx -y @vscode/dts dev && npx -y @vscode/dts master",
4444
"updatenodeapi": "python src/build/getNodePdl.py && dprint fmt",
@@ -143,7 +143,7 @@
143143
"mocha-junit-reporter": "^2.2.1",
144144
"mocha-multi-reporters": "^1.5.1",
145145
"nyc": "^15.1.0",
146-
"playwright": "^1.41.1",
146+
"playwright": "^1.52.0",
147147
"sinon": "^17.0.1",
148148
"stream-buffers": "^3.0.2",
149149
"ts-node": "^10.9.2",

src/adapter/breakpoints.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,13 @@ export class BreakpointManager {
412412
*/
413413
public setThread(thread: Thread) {
414414
this._thread = thread;
415-
this._thread.cdp().Debugger.on('breakpointResolved', event => {
416-
const breakpoint = this._resolvedBreakpoints.get(event.breakpointId);
415+
this._thread.cdp().Debugger.on('breakpointResolved', async event => {
416+
// Sometimes V8 says a breakpoint is unverified and then _immediately_ verifies
417+
// it which, due to event ordering, can happen before before the reply to 'set'
418+
// is processed. Try to find the breakpoint on the next microtask if that
419+
// might have happened.
420+
const breakpoint = this._resolvedBreakpoints.get(event.breakpointId)
421+
|| await delay(0).then(() => this._resolvedBreakpoints.get(event.breakpointId));
417422
if (breakpoint) {
418423
breakpoint.updateUiLocations(thread, event.breakpointId, [event.location]);
419424
}

src/adapter/breakpoints/userDefinedBreakpoint.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Cdp from '../../cdp/api';
77
import { getDeferred } from '../../common/promiseUtil';
88
import Dap from '../../dap/api';
99
import { BreakpointManager } from '../breakpoints';
10+
import { IUiLocation } from '../source';
1011
import { Breakpoint, BreakpointCdpReference, CdpReferenceState } from './breakpointBase';
1112
import { IBreakpointCondition } from './conditions';
1213

@@ -18,6 +19,11 @@ export class UserDefinedBreakpoint extends Breakpoint {
1819
*/
1920
private readonly completedSet = getDeferred<void>();
2021

22+
/**
23+
* Last UI location this breakpoint announced to the wold.
24+
*/
25+
private lastAnnouncedUiLocation: IUiLocation | undefined;
26+
2127
/**
2228
* @param hitCondition - Hit condition for this breakpoint. See
2329
* {@link HitCondition} for more information.
@@ -73,7 +79,10 @@ export class UserDefinedBreakpoint extends Breakpoint {
7379
* resolved, this will be fulfilled with the complete source location.
7480
*/
7581
public async toDap(): Promise<Dap.Breakpoint> {
76-
const location = this.enabled && this.getResolvedUiLocation();
82+
const resolvedUiLocation = this.getResolvedUiLocation();
83+
this.lastAnnouncedUiLocation = resolvedUiLocation;
84+
const location = this.enabled && resolvedUiLocation;
85+
7786
if (location) {
7887
return {
7988
id: this.dapId,
@@ -115,10 +124,9 @@ export class UserDefinedBreakpoint extends Breakpoint {
115124
protected updateCdpRefs(
116125
mutator: (l: ReadonlyArray<BreakpointCdpReference>) => ReadonlyArray<BreakpointCdpReference>,
117126
) {
118-
const previousLocation = this.getResolvedUiLocation();
119127
super.updateCdpRefs(mutator);
120128

121-
if (this.getResolvedUiLocation() !== previousLocation) {
129+
if (this.getResolvedUiLocation() !== this.lastAnnouncedUiLocation) {
122130
this.notifyResolved();
123131
}
124132
}

src/targets/node/nodeSourcePathResolver.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { URL } from 'url';
77
import { IFsUtils } from '../../common/fsUtils';
88
import { ILogger } from '../../common/logging';
99
import { nodeInternalsToken } from '../../common/node15Internal';
10-
import { fixDriveLetterAndSlashes, properResolve } from '../../common/pathUtils';
10+
import { fixDriveLetter, fixDriveLetterAndSlashes, properResolve } from '../../common/pathUtils';
1111
import { SourceMap } from '../../common/sourceMaps/sourceMap';
1212
import {
1313
getComputedSourceRoot,
@@ -76,7 +76,9 @@ export class NodeSourcePathResolver extends SourcePathResolverBase<IOptions> {
7676
// It's possible the source might be using the `sourceURL`, so apply
7777
// any source map overrides now (fixes vscode#204784) and before file
7878
// URIs (vscode-dwarf-debugging-ext#7)
79-
url = this.sourceMapOverrides.apply(url);
79+
const mapped = this.sourceMapOverrides.apply(url);
80+
const wasMapped = mapped !== url;
81+
url = mapped;
8082

8183
// Allow debugging of externally loaded Node internals
8284
// [ by building Node with ./configure --node-builtin-modules-path $(pwd) ]
@@ -90,7 +92,7 @@ export class NodeSourcePathResolver extends SourcePathResolverBase<IOptions> {
9092
}
9193

9294
if (map) {
93-
return this.sourceMapSourceToAbsolute(url, map);
95+
return this.sourceMapSourceToAbsolute(url, map, wasMapped);
9496
}
9597

9698
const absolutePath = urlUtils.fileUrlToAbsolutePath(url);
@@ -102,8 +104,7 @@ export class NodeSourcePathResolver extends SourcePathResolverBase<IOptions> {
102104
// attribute. If this is the case, apply a source map override if it
103105
// applies, otherwise just assume it's relative to the basePath.
104106
if (urlUtils.isValidUrl(url)) {
105-
const mapped = this.sourceMapOverrides.apply(url);
106-
url = mapped === url ? new URL(url).pathname.slice(1) : mapped;
107+
url = wasMapped ? mapped : new URL(url).pathname.slice(1);
107108
} // Node internals are given us us as relative path, for example
108109
// require('cluster') will import a file simply named "cluster". For these
109110
// paths, prefix them as internal.
@@ -148,11 +149,15 @@ export class NodeSourcePathResolver extends SourcePathResolverBase<IOptions> {
148149
);
149150
}
150151

151-
private async sourceMapSourceToAbsolute(url: string, map: SourceMap) {
152+
private async sourceMapSourceToAbsolute(url: string, map: SourceMap, wasMapped: boolean) {
152153
if (!this.shouldResolveSourceMap(map.metadata)) {
153154
return undefined;
154155
}
155156

157+
if (wasMapped) {
158+
return fixDriveLetter(url);
159+
}
160+
156161
const fullSourceEntry = getFullSourceEntry(map.sourceRoot, url);
157162
const mappedFullSourceEntry = this.sourceMapOverrides.apply(fullSourceEntry);
158163
if (mappedFullSourceEntry !== fullSourceEntry) {

src/targets/sourcePathResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export abstract class SourcePathResolverBase<T extends ISourcePathResolverOption
148148
public rebaseRemoteToLocal(remotePath: string) {
149149
if (!this.options.remoteRoot || !this.options.localRoot || !this.canMapPath(remotePath)) {
150150
// path.resolve in a relative path will put the path in VS Code's source folder which is never right
151-
return path.isAbsolute(remotePath) ? path.resolve(remotePath) : remotePath;
151+
return fixDriveLetter(path.isAbsolute(remotePath) ? path.resolve(remotePath) : remotePath);
152152
}
153153

154154
const relativePath = properRelative(this.options.remoteRoot, remotePath);

src/test/breakpoints/breakpoints-deals-with-removed-execution-contexts-1582.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,3 @@
1616
<anonymous> @ ${workspaceFolder}/web/iframe-1582/inner.js:3:3
1717
----setInterval----
1818
<anonymous> @ ${workspaceFolder}/web/iframe-1582/inner.js:2:1
19-
{
20-
allThreadsStopped : false
21-
description : Paused on breakpoint
22-
reason : breakpoint
23-
threadId : <number>
24-
}
25-
<anonymous> @ ${workspaceFolder}/web/iframe-1582/inner.js:3:3
26-
----setInterval----
27-
<anonymous> @ ${workspaceFolder}/web/iframe-1582/inner.js:2:1

src/test/breakpoints/breakpointsTest.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,15 +1378,17 @@ describe('breakpoints', () => {
13781378
};
13791379
p.dap.setBreakpoints({ source, breakpoints: [{ line: 3 }] });
13801380
await waitForPause(p, async () => {
1381-
await p.dap.evaluate({
1382-
expression: 'document.getElementsByTagName("IFRAME")[0].src += ""',
1381+
await p.dap.setBreakpoints({ source, breakpoints: [] });
1382+
p.dap.evaluate({
1383+
expression: 'document.getElementsByTagName("IFRAME")[0].src += "?cool=true"',
13831384
context: 'repl',
13841385
});
13851386
});
13861387

1387-
await waitForPause(p, async () => {
1388-
await p.dap.setBreakpoints({ source, breakpoints: [] });
1389-
});
1388+
await p.dap.once(
1389+
'loadedSource',
1390+
e => e.reason === 'new' && !!e.source.name?.includes('inner.js'),
1391+
);
13901392

13911393
// re-sets the breakpoints in the new script
13921394
p.dap.setBreakpoints({ source, breakpoints: [{ line: 3 }] });

src/test/console/console-format-popular-types.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ stdout> (1) [ƒ]
196196
stdout> > (1) [ƒ]
197197

198198
Evaluating: 'console.log(Object.prototype)'
199-
stdout> {constructor: ƒ, __defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, …}
200-
stdout> > {constructor: ƒ, __defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, …}
199+
stdout> {__defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, __lookupSetter__: ƒ, …}
200+
stdout> > {__defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, __lookupSetter__: ƒ, …}
201201

202202
Evaluating: 'console.log([Object.prototype])'
203203
stdout> (1) [{…}]
@@ -271,14 +271,14 @@ stdout> (1) [{…}]
271271
stdout> > (1) [{…}]
272272

273273
Evaluating: 'console.log(domException())'
274-
stdout> DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. {stack: <accessor>, code: 8, name: 'NotFoundError', message: "Failed to execute 'removeChild' on 'Node': T…e to be removed is not a child of this node."}
274+
stdout> NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. {stack: '', code: 8, name: 'NotFoundError', message: "Failed to execute 'removeChild' on 'Node': T…e to be removed is not a child of this node."}
275275

276276
stdout>
277-
> DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. {stack: <accessor>, code: 8, name: 'NotFoundError', message: "Failed to execute 'removeChild' on 'Node': T…e to be removed is not a child of this node."}
277+
> NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. {stack: '', code: 8, name: 'NotFoundError', message: "Failed to execute 'removeChild' on 'Node': T…e to be removed is not a child of this node."}
278278

279279
Evaluating: 'console.log([domException()])'
280-
stdout> (1) [DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of t…]
281-
stdout> > (1) [DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of t…]
280+
stdout> (1) [NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of …]
281+
stdout> > (1) [NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of …]
282282

283283
Evaluating: 'console.log(bigArray)'
284284
stdout> (200) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …]

src/test/evaluate/evaluate-supports-location-lookup.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
> caller: (...)
99
length: 1
1010
name: 'printArr'
11-
> prototype: {constructor: ƒ}
11+
> prototype: {}
1212
[[FunctionLocation]]: @ ${workspaceFolder}/web/basic.ts:5
1313
> [[Prototype]]: ƒ ()
1414
> [[Scopes]]: Scopes[1]

0 commit comments

Comments
 (0)