Skip to content

Commit 60ff772

Browse files
authored
Parallelize unit tests on CI server (Travis) (#1251)
Fixes #1247 Temporary work around for #1250 (didn't add a news entry for the work around)
1 parent 6ec4b50 commit 60ff772

File tree

6 files changed

+105
-17
lines changed

6 files changed

+105
-17
lines changed

.travis.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ matrix:
55
include:
66
- os: linux
77
python: "2.7"
8+
env: DEBUGGER_TEST=true
9+
- os: linux
10+
python: "2.7"
11+
env: SINGLE_WORKSPACE_TEST=true
12+
- os: linux
13+
python: "2.7"
14+
env: MULTIROOT_WORKSPACE_TEST=true
15+
- os: linux
16+
python: "3.6-dev"
17+
env: DEBUGGER_TEST=true
818
- os: linux
919
python: "3.6-dev"
20+
env: SINGLE_WORKSPACE_TEST=true
21+
- os: linux
22+
python: "3.6-dev"
23+
env: MULTIROOT_WORKSPACE_TEST=true
1024
before_install: |
1125
if [ $TRAVIS_OS_NAME == "linux" ]; then
1226
export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0;
@@ -30,7 +44,9 @@ script:
3044
- yarn run clean
3145
- yarn run vscode:prepublish
3246
- yarn run cover:enable
33-
- yarn run testDebugger --silent
47+
- if [ $DEBUGGER_TEST == "true" ]; then
48+
yarn run testDebugger --silent;
49+
fi
3450
- yarn run debugger-coverage
3551
- if [ $TRAVIS_UPLOAD_COVERAGE == "true" ]; then
3652
bash <(curl -s https://codecov.io/bash);
@@ -44,14 +60,18 @@ script:
4460
- yarn run clean
4561
- yarn run vscode:prepublish
4662
- yarn run cover:enable
47-
- yarn run testSingleWorkspace --silent
63+
- if [ $SINGLE_WORKSPACE_TEST == "true" ]; then
64+
yarn run testSingleWorkspace --silent;
65+
fi
4866
- if [ $TRAVIS_UPLOAD_COVERAGE == "true" ]; then
4967
bash <(curl -s https://codecov.io/bash);
5068
fi
5169
- yarn run clean
5270
- yarn run vscode:prepublish
5371
- yarn run cover:enable
54-
- yarn run testMultiWorkspace --silent
72+
- if [ $MULTIROOT_WORKSPACE_TEST == "true" ]; then
73+
yarn run testMultiWorkspace --silent;
74+
fi
5575
- if [ $TRAVIS_UPLOAD_COVERAGE == "true" ]; then
5676
bash <(curl -s https://codecov.io/bash);
5777
fi

appveyor.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ environment:
88
PYTHON_ARCH: "32"
99
nodejs_version: "8.9.1"
1010
APPVEYOR: "true"
11+
DEBUGGER_TEST: "true"
12+
- PYTHON: "C:\\Python36"
13+
PYTHON_VERSION: "3.6.3"
14+
PYTHON_ARCH: "32"
15+
nodejs_version: "8.9.1"
16+
APPVEYOR: "true"
17+
SINGLE_WORKSPACE_TEST: "true"
18+
- PYTHON: "C:\\Python36"
19+
PYTHON_VERSION: "3.6.3"
20+
PYTHON_ARCH: "32"
21+
nodejs_version: "8.9.1"
22+
APPVEYOR: "true"
23+
MULTIROOT_WORKSPACE_TEST: "true"
24+
- PYTHON: "C:\\Python36"
25+
PYTHON_VERSION: "3.6.3"
26+
PYTHON_ARCH: "32"
27+
nodejs_version: "8.9.1"
28+
APPVEYOR: "true"
29+
ANALYSIS_TEST: "true"
1130

1231
init:
1332
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"
@@ -37,9 +56,11 @@ build: off
3756
test_script:
3857
- yarn run clean
3958
- yarn run vscode:prepublish
40-
- yarn run testDebugger --silent
41-
- yarn run testSingleWorkspace --silent
42-
- yarn run testMultiWorkspace --silent
43-
# - yarn run testAnalysisEngine --silent
44-
45-
59+
- if [%DEBUGGER_TEST%]==[true] (
60+
yarn run testDebugger --silent)
61+
- if [%SINGLE_WORKSPACE_TEST%]==[true] (
62+
yarn run testSingleWorkspace --silent)
63+
- if [%MULTIROOT_WORKSPACE_TEST%]==[true] (
64+
yarn run testMultiWorkspace --silent)
65+
# - if [%ANALYSIS_TEST%]==[true] (
66+
# yarn run testAnalysisEngine --silent)

news/3 Code Health/1247.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Parallelize jobs (unit tests) on CI server.

src/test/debugger/common/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
'use strict';
55

66
// Sometimes PTVSD can take a while for thread & other events to be reported.
7-
export const DEBUGGER_TIMEOUT = 10000;
7+
export const DEBUGGER_TIMEOUT = 20000;

src/test/debugger/misc.test.ts

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
// tslint:disable:no-suspicious-comment max-func-body-length no-invalid-this no-var-requires no-require-imports no-any
55

6-
import { expect, use } from 'chai';
7-
import * as chaiAsPromised from 'chai-as-promised';
6+
import { expect } from 'chai';
87
import * as path from 'path';
98
import { ThreadEvent } from 'vscode-debugadapter';
109
import { DebugClient } from 'vscode-debugadapter-testsupport';
@@ -22,8 +21,6 @@ import { DebugClientEx } from './debugClient';
2221

2322
const isProcessRunning = require('is-running') as (number) => boolean;
2423

25-
use(chaiAsPromised);
26-
2724
const debugFilesPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'pythonFiles', 'debugging');
2825

2926
const DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'debugger', 'Main.js');
@@ -445,12 +442,20 @@ let testCounter = 0;
445442
const pauseLocation = { path: path.join(debugFilesPath, 'sample3WithEx.py'), line: 5 };
446443
await debugClient.assertStoppedLocation('exception', pauseLocation);
447444
});
448-
test('Test multi-threaded debugging', async () => {
445+
test('Test multi-threaded debugging', async function () {
446+
if (debuggerType !== 'python') {
447+
// See GitHub issue #1250
448+
this.skip();
449+
return;
450+
}
449451
await Promise.all([
450452
debugClient.configurationSequence(),
451453
debugClient.launch(buildLauncArgs('multiThread.py', false)),
452454
debugClient.waitForEvent('initialized')
453455
]);
456+
457+
// Add a delay for debugger to start (sometimes it takes a long time for new debugger to break).
458+
await sleep(3000);
454459
const pythonFile = path.join(debugFilesPath, 'multiThread.py');
455460
const breakpointLocation = { path: pythonFile, column: 1, line: 11 };
456461
await debugClient.setBreakpointsRequest({
@@ -459,8 +464,49 @@ let testCounter = 0;
459464
source: { path: breakpointLocation.path }
460465
});
461466

462-
// hit breakpoint.
463467
await debugClient.assertStoppedLocation('breakpoint', breakpointLocation);
468+
const threads = await debugClient.threadsRequest();
469+
expect(threads.body.threads).of.lengthOf(2, 'incorrect number of threads');
470+
for (const thread of threads.body.threads) {
471+
expect(thread.id).to.be.lessThan(MAX_SIGNED_INT32 + 1, 'ThreadId is not an integer');
472+
}
473+
});
474+
test('Test multi-threaded debugging', async function () {
475+
this.timeout(30000);
476+
await Promise.all([
477+
debugClient.launch(buildLauncArgs('multiThread.py', false)),
478+
debugClient.waitForEvent('initialized')
479+
]);
480+
481+
const pythonFile = path.join(debugFilesPath, 'multiThread.py');
482+
const breakpointLocation = { path: pythonFile, column: 1, line: 11 };
483+
const breakpointRequestArgs = {
484+
lines: [breakpointLocation.line],
485+
breakpoints: [{ line: breakpointLocation.line, column: breakpointLocation.column }],
486+
source: { path: breakpointLocation.path }
487+
};
488+
489+
function waitForStoppedEventFromTwoThreads() {
490+
return new Promise((resolve, reject) => {
491+
let numberOfStops = 0;
492+
debugClient.addListener('stopped', (event: DebugProtocol.StoppedEvent) => {
493+
numberOfStops += 1;
494+
if (numberOfStops < 2) {
495+
return;
496+
}
497+
resolve(event);
498+
});
499+
setTimeout(() => reject(new Error('Timeout waiting for two threads to stop at breakpoint')), DEBUGGER_TIMEOUT);
500+
});
501+
}
502+
503+
await Promise.all([
504+
debugClient.setBreakpointsRequest(breakpointRequestArgs),
505+
debugClient.setExceptionBreakpointsRequest({ filters: [] }),
506+
debugClient.configurationDoneRequest(),
507+
waitForStoppedEventFromTwoThreads(),
508+
debugClient.assertStoppedLocation('breakpoint', breakpointLocation)
509+
]);
464510

465511
const threads = await debugClient.threadsRequest();
466512
expect(threads.body.threads).of.lengthOf(2, 'incorrect number of threads');

src/test/pythonFiles/debugging/multiThread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def bar():
66
time.sleep(2)
7-
print("abcdef")
7+
print('bar')
88

99
def foo(x):
1010
while True:

0 commit comments

Comments
 (0)