Skip to content

Commit fe1a780

Browse files
authored
👷 Change CI test sequence (run debugger tests first and separately) (microsoft#861)
Fixes microsoft#860 Also fixes a test when running Yapf tests on travis
1 parent 5b1c391 commit fe1a780

16 files changed

Lines changed: 83 additions & 36 deletions

File tree

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ script:
2929
- yarn run clean
3030
- yarn run vscode:prepublish
3131
- yarn run cover:enable
32+
- yarn run testDebugger --silent
33+
- if [ $TRAVIS_UPLOAD_COVERAGE == "true" ]; then
34+
bash <(curl -s https://codecov.io/bash);
35+
fi
36+
- yarn run clean
37+
- yarn run vscode:prepublish
38+
- yarn run cover:enable
3239
- yarn run testSingleWorkspace --silent
3340
- if [ $TRAVIS_UPLOAD_COVERAGE == "true" ]; then
3441
bash <(curl -s https://codecov.io/bash);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,7 @@
17551755
"compile": "tsc -watch -p ./",
17561756
"postinstall": "node ./node_modules/vscode/bin/install",
17571757
"test": "node ./out/test/standardTest.js && node ./out/test/multiRootTest.js",
1758+
"testDebugger": "node ./out/test/debuggerTest.js",
17581759
"testSingleWorkspace": "node ./out/test/standardTest.js",
17591760
"testMultiWorkspace": "node ./out/test/multiRootTest.js",
17601761
"precommit": "node gulpfile.js",

src/client/common/net/socket/socketServer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export class SocketServer extends EventEmitter implements ISocketServer {
5656
client.on('data', (data: Buffer) => {
5757
this.emit('data', client, data);
5858
});
59+
client.on('error', (err: Error) => {
60+
this.emit('error', client, err);
61+
});
5962

6063
client.on('timeout', d => {
6164
// let msg = "Debugger client timedout, " + d;

src/client/debugger/DebugClients/LocalDebugClient.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,8 @@ export class LocalDebugClient extends DebugClient<LaunchRequestArguments> {
6666
this.debugServer!.Stop();
6767
this.debugServer = undefined;
6868
}
69-
if (this.args.type === 'pythonExperimental' && this.pyProc) {
70-
this.pyProc.kill();
71-
}
7269
if (this.pyProc) {
73-
try {
74-
this.pyProc!.send('EXIT');
75-
// tslint:disable-next-line:no-empty
76-
} catch { }
77-
try {
78-
this.pyProc!.stdin.write('EXIT');
79-
// tslint:disable-next-line:no-empty
80-
} catch { }
81-
try {
82-
this.pyProc!.disconnect();
83-
// tslint:disable-next-line:no-empty
84-
} catch { }
70+
this.pyProc.kill();
8571
this.pyProc = undefined;
8672
}
8773
}

src/client/debugger/Main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@ export class PythonDebugger extends LoggingDebugSession {
735735
}
736736
}
737737

738+
process.stdin.on('error', () => { });
739+
process.stdout.on('error', () => { });
740+
process.stderr.on('error', () => { });
741+
738742
process.on('uncaughtException', (err: Error) => {
739743
logger.error(`Uncaught Exception: ${err && err.message ? err.message : ''}`);
740744
logger.error(err && err.name ? err.name : '');

src/client/debugger/PythonProcess.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,11 @@ export class PythonProcess extends EventEmitter implements IPythonProcess {
398398
proc.stderr.on('data', (error: string) => {
399399
this.emit("error", error.toString());
400400
});
401+
proc.stderr.on('error', () => { });
401402
proc.stdout.on('data', (d: string) => {
402403
this.emit("output", undefined, d);
403404
});
405+
proc.stdout.on('error', () => { });
404406
proc.on('close', () => {
405407
this.emit('detach');
406408
});

src/test/common/misc.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { isTestExecution } from '../../client/common/constants';
88

99
// Defines a Mocha test suite to group tests of similar kind together
1010
suite('Common - Misc', () => {
11-
test('Ensure its identified that we\re running unit tests', () => {
11+
test('Ensure its identified that we\'re running unit tests', () => {
1212
expect(isTestExecution()).to.be.equal(true, 'incorrect');
1313
});
1414
});

src/test/constants.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// tslint:disable:no-string-literal
5+
import { workspace } from 'vscode';
6+
7+
export const IS_CI_SERVER = (typeof process.env['TRAVIS'] === 'string' ? process.env['TRAVIS'] : '') === 'true';
8+
export const TEST_TIMEOUT = 25000;
9+
export const IS_MULTI_ROOT_TEST = isMultitrootTest();
10+
export const IS_CI_SERVER_TEST_DEBUGGER = process.env['IS_CI_SERVER_TEST_DEBUGGER'] === '1';
11+
// If running on CI server, then run debugger tests ONLY if the corresponding flag is enabled.
12+
export const TEST_DEBUGGER = IS_CI_SERVER ? IS_CI_SERVER_TEST_DEBUGGER : true;
13+
14+
function isMultitrootTest() {
15+
return Array.isArray(workspace.workspaceFolders) && workspace.workspaceFolders.length > 1;
16+
}

src/test/debugger/misc.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { DebugClient } from 'vscode-debugadapter-testsupport';
1111
import { DebugProtocol } from 'vscode-debugprotocol';
1212
import { LaunchRequestArguments } from '../../client/debugger/Common/Contracts';
1313
import { sleep } from '../common';
14-
import { IS_CI_SERVER, IS_MULTI_ROOT_TEST } from '../initialize';
14+
import { IS_CI_SERVER, IS_MULTI_ROOT_TEST, TEST_DEBUGGER } from '../initialize';
1515

1616
const isProcessRunning = require('is-running') as (number) => boolean;
1717

@@ -30,7 +30,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
3030

3131
let debugClient: DebugClient;
3232
setup(async function () {
33-
if (!IS_MULTI_ROOT_TEST) {
33+
if (!IS_MULTI_ROOT_TEST || !TEST_DEBUGGER) {
3434
this.skip();
3535
}
3636
// Temporary, untill new version of PTVSD is bundled we cannot run tests
@@ -134,7 +134,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
134134
debugClient.waitForEvent('terminated')
135135
]);
136136
});
137-
test('Ensure threadid is int32', async () => {
137+
test('Ensure threadid is int32', async function () {
138138
if (debuggerType !== 'python') {
139139
return this.skip();
140140
}

src/test/debugger/portAndHost.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as net from 'net';
88
import * as path from 'path';
99
import { DebugClient } from 'vscode-debugadapter-testsupport';
1010
import { LaunchRequestArguments } from '../../client/debugger/Common/Contracts';
11-
import { IS_MULTI_ROOT_TEST } from '../initialize';
11+
import { IS_MULTI_ROOT_TEST, TEST_DEBUGGER } from '../initialize';
1212

1313
use(chaiAsPromised);
1414

@@ -24,7 +24,7 @@ const EXPERIMENTAL_DEBUG_ADAPTER = path.join(__dirname, '..', '..', 'client', 'd
2424
suite(`Standard Debugging of ports and hosts: ${debuggerType}`, () => {
2525
let debugClient: DebugClient;
2626
setup(async function () {
27-
if (!IS_MULTI_ROOT_TEST) {
27+
if (!IS_MULTI_ROOT_TEST || !TEST_DEBUGGER) {
2828
// tslint:disable-next-line:no-invalid-this
2929
this.skip();
3030
}

0 commit comments

Comments
 (0)