Skip to content

Commit ba97e02

Browse files
authored
Increase timeouts of the debugger unit tests (#1100)
* 🔨 increase timeout in debugger tests * 🔨 increase timeouts for all debugger tests * 📝 add news entry * Fixes #1094
1 parent 40c924a commit ba97e02

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

news/3 Code Health/1094.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Increase timeouts for the debugger unit tests.

src/test/debugger/attach.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ProcessService } from '../../client/common/process/proc';
1414
import { AttachRequestArguments } from '../../client/debugger/Common/Contracts';
1515
import { sleep } from '../common';
1616
import { initialize, IS_APPVEYOR, IS_MULTI_ROOT_TEST, TEST_DEBUGGER } from '../initialize';
17+
import { DEBUGGER_TIMEOUT } from './common/constants';
1718

1819
const fileToDebug = path.join(__dirname, '..', '..', '..', 'src', 'testMultiRootWkspc', 'workspace5', 'remoteDebugger.py');
1920
const ptvsdPath = path.join(__dirname, '..', '..', '..', 'pythonFiles', 'PythonTools');
@@ -30,6 +31,7 @@ suite('Attach Debugger', () => {
3031
}
3132
await sleep(1000);
3233
debugClient = new DebugClient('node', DEBUG_ADAPTER, 'python');
34+
debugClient.defaultTimeout = DEBUGGER_TIMEOUT;
3335
await debugClient.start();
3436
});
3537
teardown(async () => {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
// Sometimes PTVSD can take a while for thread & other events to be reported.
7+
export const DEBUGGER_TIMEOUT = 10000;

src/test/debugger/misc.test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { PlatformService } from '../../client/common/platform/platformService';
1717
import { LaunchRequestArguments } from '../../client/debugger/Common/Contracts';
1818
import { sleep } from '../common';
1919
import { IS_MULTI_ROOT_TEST, TEST_DEBUGGER } from '../initialize';
20+
import { DEBUGGER_TIMEOUT } from './common/constants';
2021
import { DebugClientEx } from './debugClient';
2122

2223
const isProcessRunning = require('is-running') as (number) => boolean;
@@ -28,7 +29,6 @@ const debugFilesPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'py
2829
const DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'debugger', 'Main.js');
2930
const MAX_SIGNED_INT32 = Math.pow(2, 31) - 1;
3031
const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'debugger', 'mainV2.js');
31-
const THREAD_TIMEOUT = 10000;
3232

3333
let testCounter = 0;
3434
[DEBUG_ADAPTER, EXPERIMENTAL_DEBUG_ADAPTER].forEach(testAdapterFilePath => {
@@ -43,6 +43,7 @@ let testCounter = 0;
4343
}
4444
await new Promise(resolve => setTimeout(resolve, 1000));
4545
debugClient = createDebugAdapter();
46+
debugClient.defaultTimeout = DEBUGGER_TIMEOUT;
4647
await debugClient.start();
4748
});
4849
teardown(async () => {
@@ -137,7 +138,7 @@ let testCounter = 0;
137138
if (debuggerType !== 'python') {
138139
return this.skip();
139140
}
140-
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
141+
const threadIdPromise = debugClient.waitForEvent('thread');
141142

142143
await Promise.all([
143144
debugClient.configurationSequence(),
@@ -156,7 +157,7 @@ let testCounter = 0;
156157
if (debuggerType !== 'python') {
157158
return this.skip();
158159
}
159-
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
160+
const threadIdPromise = debugClient.waitForEvent('thread');
160161

161162
await Promise.all([
162163
debugClient.configurationSequence(),
@@ -183,7 +184,7 @@ let testCounter = 0;
183184
}
184185
const launchArgs = buildLauncArgs('sample2.py', false);
185186
const breakpointLocation = { path: path.join(debugFilesPath, 'sample2.py'), column: 1, line: 5 };
186-
const processPromise = debugClient.waitForEvent('process', THREAD_TIMEOUT) as Promise<DebugProtocol.ProcessEvent>;
187+
const processPromise = debugClient.waitForEvent('process') as Promise<DebugProtocol.ProcessEvent>;
187188
await debugClient.hitBreakpoint(launchArgs, breakpointLocation);
188189
const processInfo = await processPromise;
189190
const processId = processInfo.body.systemProcessId;
@@ -196,7 +197,7 @@ let testCounter = 0;
196197
expect(isProcessRunning(processId)).to.be.equal(false, 'Python (debugee) Process is still alive');
197198
});
198199
test('Test conditional breakpoints', async () => {
199-
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
200+
const threadIdPromise = debugClient.waitForEvent('thread');
200201

201202
await Promise.all([
202203
debugClient.configurationSequence(),
@@ -227,7 +228,7 @@ let testCounter = 0;
227228
expect(vari.value).to.be.equal('3');
228229
});
229230
test('Test variables', async () => {
230-
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
231+
const threadIdPromise = debugClient.waitForEvent('thread');
231232
await Promise.all([
232233
debugClient.configurationSequence(),
233234
debugClient.launch(buildLauncArgs('sample2.py', false)),
@@ -297,7 +298,7 @@ let testCounter = 0;
297298
expect(response.body.value).to.be.equal('1234');
298299
});
299300
test('Test evaluating expressions', async () => {
300-
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
301+
const threadIdPromise = debugClient.waitForEvent('thread');
301302

302303
await Promise.all([
303304
debugClient.configurationSequence(),
@@ -323,7 +324,7 @@ let testCounter = 0;
323324
expect(response.body.result).to.be.equal('6', 'expression value is incorrect');
324325
});
325326
test('Test stepover', async () => {
326-
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
327+
const threadIdPromise = debugClient.waitForEvent('thread');
327328

328329
await Promise.all([
329330
debugClient.configurationSequence(),
@@ -361,7 +362,7 @@ let testCounter = 0;
361362
]);
362363
});
363364
test('Test stepin and stepout', async () => {
364-
const threadIdPromise = debugClient.waitForEvent('thread', THREAD_TIMEOUT);
365+
const threadIdPromise = debugClient.waitForEvent('thread');
365366

366367
await Promise.all([
367368
debugClient.configurationSequence(),
@@ -418,7 +419,7 @@ let testCounter = 0;
418419
debugClient.configurationSequence(),
419420
debugClient.launch(buildLauncArgs('forever.py', false)),
420421
debugClient.waitForEvent('initialized'),
421-
debugClient.waitForEvent('process', THREAD_TIMEOUT)
422+
debugClient.waitForEvent('process')
422423
]);
423424

424425
await sleep(3);

src/test/debugger/portAndHost.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { DebugClient } from 'vscode-debugadapter-testsupport';
1010
import { noop } from '../../client/common/core.utils';
1111
import { LaunchRequestArguments } from '../../client/debugger/Common/Contracts';
1212
import { IS_MULTI_ROOT_TEST, TEST_DEBUGGER } from '../initialize';
13+
import { DEBUGGER_TIMEOUT } from './common/constants';
1314

1415
use(chaiAsPromised);
1516

@@ -31,6 +32,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
3132
}
3233
await new Promise(resolve => setTimeout(resolve, 1000));
3334
debugClient = new DebugClient('node', testAdapterFilePath, debuggerType);
35+
debugClient.defaultTimeout = DEBUGGER_TIMEOUT;
3436
await debugClient.start();
3537
});
3638
teardown(async () => {

0 commit comments

Comments
 (0)