Fix test flakiness on bp verification

This commit is contained in:
Rob Lourens 2017-01-30 11:19:31 -08:00
Родитель 30e2c605fb
Коммит 0154d5f818
3 изменённых файлов: 45 добавлений и 3 удалений

Просмотреть файл

@ -33,3 +33,39 @@ export function setBreakpoint(dc: DebugClient, bps: DebugProtocol.SourceBreakpoi
if (typeof expCol === 'number') assert.equal(bp.column, expCol, 'breakpoint verification mismatch: column');
})
}
/**
* This is a copy of DebugClient's hitBreakpoint, except that it doesn't assert 'verified' by default. In the Chrome debugger, a bp may be verified or unverified at launch,
* depending on whether it's randomly received before or after the 'scriptParsed' event for its script. So we can't always check this prop.
*/
export function hitBreakpoint(dc: DebugClient, launchArgs: any, location: { path: string, line: number, column?: number, verified?: boolean }, expected?: { path?: string, line?: number, column?: number, verified?: boolean }) : Promise<any> {
return Promise.all([
dc.waitForEvent('initialized').then(event => {
return dc.setBreakpointsRequest({
lines: [ location.line ],
breakpoints: [ { line: location.line, column: location.column } ],
source: { path: location.path }
});
}).then(response => {
const bp = response.body.breakpoints[0];
if (typeof location.verified === 'boolean') {
assert.equal(bp.verified, location.verified, 'breakpoint verification mismatch: verified');
}
if (bp.source && bp.source.path) {
dc.assertPath(bp.source.path, location.path, 'breakpoint verification mismatch: path');
}
if (typeof bp.line === 'number') {
assert.equal(bp.line, location.line, 'breakpoint verification mismatch: line');
}
if (typeof location.column === 'number' && typeof bp.column === 'number') {
assert.equal(bp.column, location.column, 'breakpoint verification mismatch: column');
}
return dc.configurationDoneRequest();
}),
dc.launch(launchArgs),
dc.assertStoppedLocation('breakpoint', expected || location)
]);
}

Просмотреть файл

@ -74,7 +74,7 @@ suite('Stepping', () => {
// Skip the full B generated script via launch config
const skipFiles = ['sourceB.js'];
const bpLineA = 5;
await dc.hitBreakpoint({ url, sourceMaps: false, skipFiles, webRoot: testProjectRoot }, { path: sourceA, line: bpLineA, verified: false });
await testUtils.hitBreakpoint(dc, { url, sourceMaps: false, skipFiles, webRoot: testProjectRoot }, { path: sourceA, line: bpLineA });
// Step in, verify B sources are skipped
await dc.stepInRequest({ threadId: THREAD_ID });
@ -101,14 +101,19 @@ suite('Stepping', () => {
// Skip the full B generated script via launch config
const bpLineA = 6;
const skipFiles = ['b.js'];
await dc.hitBreakpoint({ url, skipFiles, webRoot: testProjectRoot }, { path: sourceA, line: bpLineA, verified: false });
await testUtils.hitBreakpoint(dc, { url, skipFiles, webRoot: testProjectRoot }, { path: sourceA, line: bpLineA });
await Promise.all([
dc.stepInRequest({ threadId: THREAD_ID }),
dc.waitForEvent('stopped')
]);
// Un-skip b2 and refresh the page
await dc.send('toggleSkipFileStatus', { path: sourceB2 });
await Promise.all([
// Wait for extra pause event sent after toggling skip status
dc.waitForEvent('stopped'),
dc.send('toggleSkipFileStatus', { path: sourceB2 })
]);
await Promise.all([
dc.send('restart'),
dc.assertStoppedLocation('breakpoint', { path: sourceA, line: bpLineA })

Просмотреть файл

@ -5,6 +5,7 @@
"removeComments": false,
"target": "ES6",
"sourceMap": true,
"noImplicitThis": true,
"outDir": "../out"
},
"include": [