Skip to content

Commit

Permalink
fix: connection error on node 8, check sanity in 8 in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Jul 13, 2020
1 parent ad278b7 commit 7b1380e
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .ci/common-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
- task: NodeTool@0
displayName: Use Node
inputs:
versionSpec: 12.13.0
versionSpec: $(node_version)
checkLatest: true

- bash: |
Expand Down Expand Up @@ -45,12 +45,13 @@ steps:
env:
FRAMEWORK_TESTS: 1
DISPLAY: ':99.0'
ONLY_MINSPEC: $(only_minspec)

- task: Gulp@0
displayName: gulp lint
inputs:
targets: lint
condition: eq(${{ parameters.runTests }}, true)
condition: and(eq(${{ parameters.runTests }}, true), ne(variables.only_minspec, true))

- task: PublishTestResults@2
displayName: Publish Tests Results
Expand Down
15 changes: 15 additions & 0 deletions .ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ jobs:
vmImage: 'macOS-10.15'
steps:
- template: common-validation.yml
variables:
node_version: 12.13.0

- job: Linux
pool:
vmImage: 'ubuntu-18.04'
steps:
- template: common-validation.yml
variables:
node_version: 12.13.0

- job: LinuxMinspec
pool:
vmImage: 'ubuntu-18.04'
steps:
- template: common-validation.yml
variables:
node_version: 12.13.0
only_minspec: true

- job: Windows
pool:
Expand All @@ -31,3 +44,5 @@ jobs:
Remove-Item $InstallerExe
displayName: Install Edge Canary
- template: common-validation.yml
variables:
node_version: 12.13.0
10 changes: 9 additions & 1 deletion src/common/cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ export function timeoutPromise<T>(
didTimeout.promise.then(() => {
throw new TaskCancelledError(message || 'Task cancelled');
}),
promise.finally(() => disposable.dispose()),
promise
.then(r => {
disposable.dispose();
return r;
})
.catch(err => {
disposable.dispose();
throw err;
}),
]);
}

Expand Down
8 changes: 7 additions & 1 deletion src/targets/node/nodeBinaryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import { injectable } from 'inversify';
import { injectable, inject } from 'inversify';
import { basename, isAbsolute } from 'path';
import { EnvironmentVars } from '../../common/environmentVars';
import { ILogger, LogTag } from '../../common/logging';
import { findInPath } from '../../common/pathUtils';
import { spawnAsync } from '../../common/processUtils';
import { cannotFindNodeBinary, ErrorCodes, nodeBinaryOutOfDate } from '../../dap/errors';
Expand Down Expand Up @@ -62,6 +63,8 @@ export class NodeBinaryProvider {
*/
private readonly knownGoodMappings = new Map<string, NodeBinary>();

constructor(@inject(ILogger) private readonly logger: ILogger) {}

/**
* Validates the path and returns an absolute path to the Node binary to run.
*/
Expand All @@ -71,6 +74,7 @@ export class NodeBinaryProvider {
explicitVersion?: number,
): Promise<NodeBinary> {
const location = this.resolveBinaryLocation(executable, env);
this.logger.info(LogTag.RuntimeLaunch, 'Using binary at', { location, executable });
if (!location) {
throw new ProtocolError(cannotFindNodeBinary(executable));
}
Expand Down Expand Up @@ -105,6 +109,8 @@ export class NodeBinaryProvider {

// match the "12" in "v12.34.56"
const version = await this.getVersionText(location);
this.logger.info(LogTag.RuntimeLaunch, 'Discovered version', { version: version.trim() });

const majorVersionMatch = /v([0-9]+)\./.exec(version);
if (!majorVersionMatch) {
throw new ProtocolError(nodeBinaryOutOfDate(version.trim(), location));
Expand Down
3 changes: 2 additions & 1 deletion src/test/node/node-binary-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ErrorCodes } from '../../dap/errors';
import { ProtocolError } from '../../dap/protocolError';
import { NodeBinaryProvider } from '../../targets/node/nodeBinaryProvider';
import { testWorkspace } from '../test';
import { Logger } from '../../common/logging/logger';

describe('NodeBinaryProvider', () => {
let p: NodeBinaryProvider;
Expand All @@ -23,7 +24,7 @@ describe('NodeBinaryProvider', () => {
process.platform === 'win32' ? `${binary}.exe` : binary,
);

beforeEach(() => (p = new NodeBinaryProvider()));
beforeEach(() => (p = new NodeBinaryProvider(Logger.null)));

it('rejects not found', async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import { runTests } from 'vscode-test';
import minimist from 'minimist';
import * as path from 'path';
import { runTests } from 'vscode-test';

async function main() {
try {
Expand Down
10 changes: 7 additions & 3 deletions src/test/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import Mocha from 'mocha';
import * as glob from 'glob';
import 'reflect-metadata';
import { use } from 'chai';
import * as glob from 'glob';
import Mocha from 'mocha';
import { join } from 'path';
import 'reflect-metadata';

use(require('chai-subset'));
use(require('chai-as-promised'));
Expand Down Expand Up @@ -38,6 +38,10 @@ export async function run(): Promise<void> {
...JSON.parse(process.env.PWA_TEST_OPTIONS || '{}'),
};

if (process.env.ONLY_MINSPEC === 'true') {
mochaOpts.grep = 'node runtime'; // may eventually want a more dynamic system
}

const grep = mochaOpts.grep || mochaOpts.g;
if (grep) {
mochaOpts.grep = new RegExp(grep, 'i');
Expand Down
3 changes: 2 additions & 1 deletion src/ui/autoAttach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export function registerAutoAttach(
}

launcher = (async () => {
const inst = new AutoAttachLauncher(new NodeBinaryProvider(), new ProxyLogger(), context, fs);
const logger = new ProxyLogger();
const inst = new AutoAttachLauncher(new NodeBinaryProvider(logger), logger, context, fs);
await launchVirtualTerminalParent(delegate, inst);

inst.onTargetListChanged(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/ui/debugTerminalUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export function registerDebugTerminalUI(
workspaceFolder?: vscode.WorkspaceFolder,
defaultConfig?: Partial<ITerminalLaunchConfiguration>,
) {
const launcher = new TerminalNodeLauncher(new NodeBinaryProvider(), new ProxyLogger(), fs);
const logger = new ProxyLogger();
const launcher = new TerminalNodeLauncher(new NodeBinaryProvider(logger), logger, fs);
launcher.onTerminalCreated(terminal => {
linkHandler.enableHandlingInTerminal(terminal);
});
Expand Down

0 comments on commit 7b1380e

Please sign in to comment.