Skip to content

Commit 0d681a9

Browse files
committed
wait before setting brkpoint and increate test timeout
1 parent 6528944 commit 0d681a9

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

src/test/debugger/misc.test.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { noop } from '../../client/common/core.utils';
1414
import { IS_WINDOWS } from '../../client/common/platform/constants';
1515
import { FileSystem } from '../../client/common/platform/fileSystem';
1616
import { PlatformService } from '../../client/common/platform/platformService';
17-
import { StopWatch } from '../../client/common/stopWatch';
1817
import { DebugOptions, LaunchRequestArguments } from '../../client/debugger/Common/Contracts';
1918
import { sleep } from '../common';
2019
import { IS_MULTI_ROOT_TEST, TEST_DEBUGGER } from '../initialize';
@@ -42,7 +41,6 @@ let testCounter = 0;
4241
if (!IS_MULTI_ROOT_TEST || !TEST_DEBUGGER) {
4342
this.skip();
4443
}
45-
this.timeout(30000);
4644
await new Promise(resolve => setTimeout(resolve, 1000));
4745
debugClient = createDebugAdapter();
4846
debugClient.defaultTimeout = DEBUGGER_TIMEOUT;
@@ -447,37 +445,30 @@ let testCounter = 0;
447445
const pauseLocation = { path: path.join(debugFilesPath, 'sample3WithEx.py'), line: 5 };
448446
await debugClient.assertStoppedLocation('exception', pauseLocation);
449447
});
450-
test('Test multi-threaded debugging', async () => {
451-
const stopWatch = new StopWatch();
452-
console.log(`step1 ${stopWatch.elapsedTime}`);
448+
test('Test multi-threaded debugging', async function () {
449+
this.timeout(30000);
453450
await Promise.all([
454451
debugClient.configurationSequence(),
455452
debugClient.launch(buildLauncArgs('multiThread.py', false)),
456453
debugClient.waitForEvent('initialized')
457454
]);
458-
debugClient.addListener('output', output => {
459-
console.log(`stepx ${stopWatch.elapsedTime}, ${JSON.stringify(output)}`);
460-
});
461-
console.log(`step2 ${stopWatch.elapsedTime}`);
455+
456+
// Add a delay for debugger to start (sometimes it takes a long time for new debugger to break).
462457
await sleep(3000);
463458
const pythonFile = path.join(debugFilesPath, 'multiThread.py');
464-
const breakpointLocation = { path: pythonFile, column: 1, line: 15 };
459+
const breakpointLocation = { path: pythonFile, column: 1, line: 11 };
465460
await debugClient.setBreakpointsRequest({
466461
lines: [breakpointLocation.line],
467462
breakpoints: [{ line: breakpointLocation.line, column: breakpointLocation.column }],
468463
source: { path: breakpointLocation.path }
469464
});
470-
console.log(`step3 ${stopWatch.elapsedTime}`);
471-
// hit breakpoint.
465+
472466
await debugClient.assertStoppedLocation('breakpoint', breakpointLocation);
473-
console.log(`step4 ${stopWatch.elapsedTime}`);
474467
const threads = await debugClient.threadsRequest();
475-
console.log(`step5 ${stopWatch.elapsedTime}`);
476468
expect(threads.body.threads).of.lengthOf(2, 'incorrect number of threads');
477469
for (const thread of threads.body.threads) {
478470
expect(thread.id).to.be.lessThan(MAX_SIGNED_INT32 + 1, 'ThreadId is not an integer');
479471
}
480-
console.log(`step6 ${stopWatch.elapsedTime}`);
481472
});
482473
test('Test stack frames', async () => {
483474
await Promise.all([
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
print("step1")
21
import sys
32
import threading
43
import time
5-
print("step2")
64

75
def bar():
8-
print("step2-{},bar".format(threading.current_thread().getName()))
96
time.sleep(2)
10-
print("print-{},bar".format(threading.current_thread().getName()))
7+
print('bar')
118

129
def foo(x):
1310
while True:
14-
print("step2-{},foo-loop".format(threading.current_thread().getName()))
1511
bar()
16-
print("step3")
12+
1713
threading.Thread(target=lambda: foo(2), name="foo").start()
18-
print("step4")
1914
foo(1)
20-
print("step5")

0 commit comments

Comments
 (0)