Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import path from 'path';

import { resolveNetworkAddress } from './resolveNetworkAddress';

// Hardcoded in testProcess.js.
// Hardcoded in testProcess.mjs.
const PORT = '1337';

it('returns an error when supplied an unknown protocol', async () => {
const process = fork(path.join(__dirname, 'testProcess.js'), {
const process = fork(path.join(__dirname, 'testProcess.mjs'), {
silent: true,
});

Expand Down Expand Up @@ -56,7 +56,7 @@ describe.each(testSuites)(
'for $name process',
({ requestedAddress, expectedNetworkAddress }) => {
it(`waits for the process to output the matching string`, async () => {
const process = fork(path.join(__dirname, 'testProcess.js'), {
const process = fork(path.join(__dirname, 'testProcess.mjs'), {
silent: true,
});

Expand All @@ -73,7 +73,7 @@ describe.each(testSuites)(
});

it(`times out if the process doesn't return the match in time`, async () => {
const process = fork(path.join(__dirname, 'testProcess.js'), ['100'], {
const process = fork(path.join(__dirname, 'testProcess.mjs'), ['100'], {
silent: true,
});

Expand All @@ -88,7 +88,7 @@ describe.each(testSuites)(

it(`returns an error if the process exits without returning a match`, async () => {
const process = fork(
path.join(__dirname, 'testProcess.js'),
path.join(__dirname, 'testProcess.mjs'),
['10', 'exit-prematurely'],
{
silent: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function waitForMatchInStdout(

const rejectOnExit = (code: number, signal: NodeJS.Signals) => {
const codeOrSignal = [
code && `code ${code}`,
// code can be 0, so we cannot just check it the same way as the signal.
code != null && `code ${code}`,
signal && `signal ${signal}`,
]
.filter(Boolean)
Expand Down
19 changes: 0 additions & 19 deletions web/packages/teleterm/src/mainProcess/testProcess.js

This file was deleted.

33 changes: 33 additions & 0 deletions web/packages/teleterm/src/mainProcess/testProcess.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright 2023 Gravitational, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import process from 'process';

const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

const waitTime = parseInt(process.argv[2]);
if (waitTime) {
await sleep(waitTime);
}

const shouldExit = process.argv[3];
if (shouldExit) {
process.exit(1);
}

console.log('Lorem ipsum dolor sit amet');
console.log('{CONNECT_GRPC_PORT: 1337}');
console.log('Lorem ipsum dolor sit amet');