Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable browser tests on all platforms #13806

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2019, ubuntu-latest, macos-11]
node: [16.x, 18.x, 20.x]
os: [windows-latest, ubuntu-latest, macos-latest]
node: [18.x, 20.x]

runs-on: ${{ matrix.os }}
timeout-minutes: 60
Expand Down Expand Up @@ -83,7 +83,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9

- name: Download Plugins
if: runner.os == 'Linux'
shell: bash
run: |
yarn -s download:plugins
Expand All @@ -105,9 +104,9 @@ jobs:
yarn test:theia

- name: Test (browser)
if: matrix.tests != 'skip' && runner.os == 'Linux'
if: matrix.tests != 'skip'
run: |
xvfb-run -a yarn browser test
yarn browser test

- name: Test (electron)
if: matrix.tests != 'skip' && runner.os == 'Linux'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ export class NativeWebpackPlugin {
const dllFile = require.resolve('node-pty/build/Release/winpty.dll');
const targetDllFile = path.join(targetDirectory, 'winpty.dll');
await this.copyExecutable(dllFile, targetDllFile);
} else {
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper');
const targetFile = path.join(targetDirectory, 'spawn-helper');
await this.copyExecutable(sourceFile, targetFile);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Theia process support.",
"dependencies": {
"@theia/core": "1.50.0",
"node-pty": "0.11.0-beta24",
"node-pty": "^1.0.0",
"string-argv": "^0.1.1",
"tslib": "^2.6.2"
},
Expand Down
50 changes: 1 addition & 49 deletions packages/process/src/node/terminal-process.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import * as process from 'process';
import * as stream from 'stream';
import { createProcessTestContainer } from './test/process-test-container';
import { TerminalProcessFactory } from './terminal-process';
import { IProcessExitEvent, ProcessErrorEvent } from './process';
import { isWindows } from '@theia/core/lib/common/os';
import { IProcessExitEvent } from './process';

/**
* Globals
Expand All @@ -34,55 +33,8 @@ beforeEach(() => {
});

describe('TerminalProcess', function (): void {

this.timeout(20_000);

it('test error on non existent path', async function (): Promise<void> {
const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
const proc = terminalProcessFactory({ command: '/non-existent' });
proc.onStart(reject);
proc.onError(resolve);
proc.onExit(reject);
});

expect(error.code).eq('ENOENT');
});

it('test implicit .exe (Windows only)', async function (): Promise<void> {
const match = /^(.+)\.exe$/.exec(process.execPath);
if (!isWindows || !match) {
this.skip();
}

const command = match[1];
const args = ['--version'];
const terminal = await new Promise<IProcessExitEvent>((resolve, reject) => {
const proc = terminalProcessFactory({ command, args });
proc.onExit(resolve);
proc.onError(reject);
});

expect(terminal.code).to.exist;
});

it('test error on trying to execute a directory', async function (): Promise<void> {
const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
const proc = terminalProcessFactory({ command: __dirname });
proc.onStart(reject);
proc.onError(resolve);
proc.onExit(reject);
});

if (isWindows) {
// On Windows, node-pty returns us a "File not found" message, so we can't really differentiate this case
// from trying to execute a non-existent file. node's child_process.spawn also returns ENOENT, so it's
// probably the best we can get.
expect(error.code).eq('ENOENT');
} else {
expect(error.code).eq('EACCES');
}
});

it('test exit', async function (): Promise<void> {
const args = ['--version'];
const exit = await new Promise<IProcessExitEvent>((resolve, reject) => {
Expand Down
8 changes: 7 additions & 1 deletion packages/process/src/node/terminal-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export class TerminalProcess extends Process {
this.inputStream = inputStream;
}

debugString(): string {
return JSON.stringify(this.terminal);
}

/**
* Helper for the constructor to attempt to create the pseudo-terminal encapsulating the shell process.
*
Expand All @@ -150,7 +154,9 @@ export class TerminalProcess extends Process {
options.options || {}
);

process.nextTick(() => this.emitOnStarted());
if (process.pid !== undefined) {
process.nextTick(() => this.emitOnStarted());
}

// node-pty actually wait for the underlying streams to be closed before emitting exit.
// We should emulate the `exit` and `close` sequence.
Expand Down
6 changes: 0 additions & 6 deletions packages/task/src/node/task-server.slow-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import * as https from 'https';
import { isWindows, isOSX } from '@theia/core/lib/common/os';
import { FileUri } from '@theia/core/lib/node';
import { terminalsPath } from '@theia/terminal/lib/common/terminal-protocol';
import { expectThrowsAsync } from '@theia/core/lib/common/test/expect';
import { TestWebSocketChannelSetup } from '@theia/core/lib/node/messaging/test/test-web-socket-channel';
import { expect } from 'chai';
import URI from '@theia/core/lib/common/uri';
Expand Down Expand Up @@ -251,11 +250,6 @@ describe('Task server / back-end', function (): void {
}
});

it('task using raw process can handle command that does not exist', async function (): Promise<void> {
const p = taskServer.run(createProcessTaskConfig2('process', bogusCommand, []), wsRoot);
await expectThrowsAsync(p, 'ENOENT');
});

it('getTasks(ctx) returns tasks according to created context', async function (): Promise<void> {
const context1 = 'aContext';
const context2 = 'anotherContext';
Expand Down
5 changes: 0 additions & 5 deletions packages/terminal/src/node/terminal-server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,4 @@ describe('TerminalServer', function (): void {
const createResult = await terminalServer.create({ command: process.execPath, 'args': args });
expect(createResult).to.be.greaterThan(-1);
});

it('test terminal create from non-existent path', async function (): Promise<void> {
const createError = await terminalServer.create({ command: '/non-existent' });
expect(createError).eq(-1);
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8611,10 +8611,10 @@ node-preload@^0.2.1:
dependencies:
process-on-spawn "^1.0.0"

node-pty@0.11.0-beta24:
version "0.11.0-beta24"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.11.0-beta24.tgz#084841017187656edaf14b459946c4a1d7cf8392"
integrity sha512-CzItw3hitX+wnpw9dHA/A+kcbV7ETNKrsyQJ+s0ZGzsu70+CSGuIGPLPfMnAc17vOrQktxjyRQfaqij75GVJFw==
node-pty@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-1.0.0.tgz#7daafc0aca1c4ca3de15c61330373af4af5861fd"
integrity sha512-wtBMWWS7dFZm/VgqElrTvtfMq4GzJ6+edFI0Y0zyzygUSZMgZdraDUMUhCIvkjhJjme15qWmbyJbtAx4ot4uZA==
dependencies:
nan "^2.17.0"

Expand Down
Loading