Skip to content

Commit

Permalink
Test error
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Apr 18, 2024
1 parent e0fa281 commit c66fe2c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
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.48.0",
"node-pty": "1.0.0",
"node-pty": "1.1.0-beta5",
"string-argv": "^0.1.1",
"tslib": "^2.6.2"
},
Expand Down
1 change: 1 addition & 0 deletions packages/process/src/common/process-manager-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface IProcessExitEvent {
* Data emitted when a process has been successfully started.
*/
export interface IProcessStartEvent {
readonly pid?: number;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/process/src/node/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export abstract class Process implements ManagedProcess {
return this.closeEmitter.event;
}

protected emitOnStarted(): void {
this.startEmitter.fire({});
protected emitOnStarted(event?: IProcessStartEvent): void {
this.startEmitter.fire(event ?? {});
}

/**
Expand Down
34 changes: 27 additions & 7 deletions packages/process/src/node/terminal-process.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,34 @@ 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);
});
try {
const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
try {
const proc = terminalProcessFactory({ command: '/non-existent' });
proc.onStart(e => {
console.log('onStart', e);
reject(e);
});
proc.onError(e => {
console.log('onError', e);
resolve(e);
});
proc.onExit(e => {
console.log('onExit', e);
reject(e);
});
} catch (err) {
reject(err);
}
});

console.log('test error on non existent path', error);
expect(error.code).eq('ENOENT');
} catch (err) {
console.log('test error on non existent path', err);
expect(err.code).eq('ENOENT');
}

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

it('test implicit .exe (Windows only)', async function (): Promise<void> {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8594,10 +8594,10 @@ node-preload@^0.2.1:
dependencies:
process-on-spawn "^1.0.0"

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==
node-pty@1.1.0-beta5:
version "1.1.0-beta5"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-1.1.0-beta5.tgz#364386b7058a93070234064f13164ec1ef914993"
integrity sha512-j3QdgFHnLY0JWxztrvM3g67RaQLOGvytv+C6mFu0PqD+JILlzqfwuoyqRqVxdZZjoOTUXPfSRj1qPVCaCH+eOw==
dependencies:
nan "^2.17.0"

Expand Down

0 comments on commit c66fe2c

Please sign in to comment.