Skip to content

Commit 23b9c38

Browse files
int19hDonJayamanne
authored andcommitted
Fix microsoft/ptvsd#78 Fixes #794 Wait for `process` event before requesting pause. Increase timeouts when waiting for `process` and `thread`, due to pydevd delay in thread reporting.
1 parent 951ceda commit 23b9c38

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/test/debugger/misc.test.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const debugFilesPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'py
2222
const DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'debugger', 'Main.js');
2323
const MAX_SIGNED_INT32 = Math.pow(2, 31) - 1;
2424
const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'debugger', 'mainV2.js');
25+
const THREAD_TIMEOUT = 10000;
2526

2627
[DEBUG_ADAPTER, EXPERIMENTAL_DEBUG_ADAPTER].forEach(testAdapterFilePath => {
2728
const debugAdapterFileName = path.basename(testAdapterFilePath);
@@ -119,7 +120,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
119120
if (debuggerType !== 'python') {
120121
return this.skip();
121122
}
122-
const threadIdPromise = debugClient.waitForEvent('thread');
123+
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
123124

124125
await Promise.all([
125126
debugClient.configurationSequence(),
@@ -138,7 +139,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
138139
if (debuggerType !== 'python') {
139140
return this.skip();
140141
}
141-
const threadIdPromise = debugClient.waitForEvent('thread');
142+
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
142143

143144
await Promise.all([
144145
debugClient.configurationSequence(),
@@ -165,7 +166,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
165166
}
166167
const launchArgs = buildLauncArgs('sample2.py', false);
167168
const breakpointLocation = { path: path.join(debugFilesPath, 'sample2.py'), column: 1, line: 5 };
168-
const processPromise = debugClient.waitForEvent('process') as Promise<DebugProtocol.ProcessEvent>;
169+
const processPromise = debugClient.waitForEvent('process', THREAD_TIMEOUT) as Promise<DebugProtocol.ProcessEvent>;
169170
await debugClient.hitBreakpoint(launchArgs, breakpointLocation);
170171
const processInfo = await processPromise;
171172
const processId = processInfo.body.systemProcessId;
@@ -178,7 +179,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
178179
expect(isProcessRunning(processId)).to.be.equal(false, 'Python (debugee) Process is still alive');
179180
});
180181
test('Test conditional breakpoints', async () => {
181-
const threadIdPromise = debugClient.waitForEvent('thread');
182+
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
182183

183184
await Promise.all([
184185
debugClient.configurationSequence(),
@@ -209,7 +210,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
209210
expect(vari.value).to.be.equal('3');
210211
});
211212
test('Test variables', async () => {
212-
const threadIdPromise = debugClient.waitForEvent('thread');
213+
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
213214
await Promise.all([
214215
debugClient.configurationSequence(),
215216
debugClient.launch(buildLauncArgs('sample2.py', false)),
@@ -279,7 +280,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
279280
expect(response.body.value).to.be.equal('1234');
280281
});
281282
test('Test evaluating expressions', async () => {
282-
const threadIdPromise = debugClient.waitForEvent('thread');
283+
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
283284

284285
await Promise.all([
285286
debugClient.configurationSequence(),
@@ -305,7 +306,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
305306
expect(response.body.result).to.be.equal('6', 'expression value is incorrect');
306307
});
307308
test('Test stepover', async () => {
308-
const threadIdPromise = debugClient.waitForEvent('thread');
309+
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
309310

310311
await Promise.all([
311312
debugClient.configurationSequence(),
@@ -337,7 +338,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
337338
await debugClient.assertStoppedLocation('step', printLocation);
338339
});
339340
test('Test stepin and stepout', async () => {
340-
const threadIdPromise = debugClient.waitForEvent('thread');
341+
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
341342

342343
await Promise.all([
343344
debugClient.configurationSequence(),
@@ -376,14 +377,16 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
376377
await debugClient.assertStoppedLocation('step', printLocation);
377378
});
378379
test('Test pausing', async function () {
379-
if (debuggerType !== 'python') {
380+
// TODO: re-enable for new debugger once it's running on CI
381+
if (debuggerType !== 'pythonExperimental' || IS_CI_SERVER) {
380382
return this.skip();
381383
}
382384

383385
await Promise.all([
384386
debugClient.configurationSequence(),
385387
debugClient.launch(buildLauncArgs('forever.py', false)),
386-
debugClient.waitForEvent('initialized')
388+
debugClient.waitForEvent('initialized'),
389+
debugClient.waitForEvent('process', THREAD_TIMEOUT)
387390
]);
388391

389392
await sleep(3);
@@ -399,6 +402,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
399402
if (debuggerType !== 'python') {
400403
return this.skip();
401404
}
405+
402406
await Promise.all([
403407
debugClient.configurationSequence(),
404408
debugClient.launch(buildLauncArgs('sample3WithEx.py', false)),

0 commit comments

Comments
 (0)