diff --git a/packages/internal/testing/src/lib/testing.ts b/packages/internal/testing/src/lib/testing.ts index 5658197b9..27035d07b 100644 --- a/packages/internal/testing/src/lib/testing.ts +++ b/packages/internal/testing/src/lib/testing.ts @@ -129,7 +129,7 @@ export function runNxCommandUntil( const KILL_PORT_DELAY = 5000; -export async function killPort(port: number): Promise { +async function killPort(port: number): Promise { if (await portCheck(port)) { try { logInfo(`Attempting to close port ${port}`); @@ -184,16 +184,24 @@ export function logError(title: string, body?: string) { return e2eConsoleLogger(message, body); } -export async function killPorts(port?: number): Promise { - return port - ? await killPort(port) - : (await killPort(3333)) && (await killPort(4200)); -} +const promisifiedTreeKill: (pid: number, signal: string) => Promise = + promisify(treeKill); -export const promisifiedTreeKill: ( - pid: number, - signal: string, -) => Promise = promisify(treeKill); +export async function killProcessAndPorts( + pid: number | undefined, + ...ports: number[] +): Promise { + try { + if (pid) { + await promisifiedTreeKill(pid, 'SIGKILL'); + } + for (const port of ports) { + await killPort(port); + } + } catch (err) { + // ignore err + } +} export function checkFilesDoNotExist(...expectedFiles: string[]) { expectedFiles.forEach((f) => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut-kt.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut-kt.spec.ts index 0dbf2329b..1476a939a 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut-kt.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut-kt.spec.ts @@ -3,8 +3,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -170,12 +169,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should build-image of a java application', async () => { @@ -270,12 +264,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should generate an app with a simple package name', async () => { @@ -357,12 +346,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a kotlin application', async () => { @@ -441,12 +425,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); xit('should build-image of a kotlin application', async () => { @@ -541,12 +520,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('directory with dash', async () => { @@ -581,12 +555,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library', async () => { @@ -1119,12 +1088,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library with a simple name', async () => { @@ -1222,12 +1186,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a minimal kotlin application', async () => { @@ -1267,12 +1226,7 @@ describe('nx-gradle micronaut kotlin dsl e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should skip starter code when generating a java library with skipStarterCode option', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut.spec.ts index 931234582..4ed513e98 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-gradle/micronaut.spec.ts @@ -3,8 +3,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -170,12 +169,7 @@ describe('nx-gradle micronaut e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should build-image of a java application', async () => { @@ -270,12 +264,7 @@ describe('nx-gradle micronaut e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should generate an app with a simple package name', async () => { @@ -357,12 +346,7 @@ describe('nx-gradle micronaut e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a kotlin application', async () => { @@ -441,12 +425,7 @@ describe('nx-gradle micronaut e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); xit('should build-image of a kotlin application', async () => { @@ -541,12 +520,7 @@ describe('nx-gradle micronaut e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('directory with dash', async () => { @@ -581,12 +555,7 @@ describe('nx-gradle micronaut e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library', async () => { @@ -1119,12 +1088,7 @@ describe('nx-gradle micronaut e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library with a simple name', async () => { @@ -1222,12 +1186,7 @@ describe('nx-gradle micronaut e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a minimal kotlin application', async () => { @@ -1267,12 +1226,7 @@ describe('nx-gradle micronaut e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should skip starter code when generating a java library with skipStarterCode option', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus-kt.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus-kt.spec.ts index d5b14f0ef..fde88d803 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus-kt.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus-kt.spec.ts @@ -4,8 +4,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -177,12 +176,7 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 360000); it('should build-image a java application', async () => { @@ -272,12 +266,7 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should generate an app with a simple package name', async () => { @@ -345,12 +334,7 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a kotlin application', async () => { @@ -430,12 +414,7 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 360000); it('should build-image a kotlin application', async () => { @@ -525,12 +504,7 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('directory with dash', async () => { @@ -565,12 +539,7 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library', async () => { @@ -1106,12 +1075,7 @@ describe('nx-gradle quarkus kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a simple name library', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus.spec.ts index 4e5d86c15..bd9314d28 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-gradle/quarkus.spec.ts @@ -4,8 +4,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -177,12 +176,7 @@ describe('nx-gradle quarkus e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should build-image a java application', async () => { @@ -272,12 +266,7 @@ describe('nx-gradle quarkus e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should generate an app with a simple package name', async () => { @@ -345,12 +334,7 @@ describe('nx-gradle quarkus e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a kotlin application', async () => { @@ -430,12 +414,7 @@ describe('nx-gradle quarkus e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should build-image a kotlin application', async () => { @@ -525,12 +504,7 @@ describe('nx-gradle quarkus e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('directory with dash', async () => { @@ -565,12 +539,7 @@ describe('nx-gradle quarkus e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library', async () => { @@ -1106,12 +1075,7 @@ describe('nx-gradle quarkus e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a library with simple name', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot-kt.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot-kt.spec.ts index 6e3dfc8f5..dbb0615e6 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot-kt.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot-kt.spec.ts @@ -1,3 +1,11 @@ +import { normalizeName } from '@jnxplus/common'; +import { + checkFilesDoNotExist, + createTestWorkspace, + getData, + killProcessAndPorts, + runNxCommandUntil, +} from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; import { checkFilesExist, @@ -8,20 +16,10 @@ import { uniq, updateFile, } from '@nx/plugin/testing'; -import * as fse from 'fs-extra'; -import * as path from 'path'; - -import { normalizeName } from '@jnxplus/common'; -import { - checkFilesDoNotExist, - createTestWorkspace, - getData, - killPorts, - promisifiedTreeKill, - runNxCommandUntil, -} from '@jnxplus/internal/testing'; import { execSync } from 'child_process'; import { rmSync } from 'fs'; +import * as fse from 'fs-extra'; +import * as path from 'path'; describe('nx-gradle spring-boot kotlin dsl e2e', () => { let workspaceDirectory: string; @@ -172,12 +170,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('should build-image a java application', async () => { @@ -277,12 +270,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should generate an app with a simple package name', async () => { @@ -369,12 +357,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a kotlin application', async () => { @@ -457,12 +440,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should build-image a kotlin application', async () => { @@ -562,12 +540,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('directory with dash', async () => { @@ -602,12 +575,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library', async () => { @@ -1165,12 +1133,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library with a simple name', async () => { @@ -1279,12 +1242,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a minimal kotlin application', async () => { @@ -1333,12 +1291,7 @@ describe('nx-gradle spring-boot kotlin dsl e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should skip starter code when generating a java library with skipStarterCode option', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot.spec.ts index 9a2b5f45f..57d00af6d 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-gradle/spring-boot.spec.ts @@ -3,8 +3,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -171,12 +170,7 @@ describe('nx-gradle spring-boot e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 120000); it('should build-image a java application', async () => { @@ -287,12 +281,7 @@ describe('nx-gradle spring-boot e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should generate an app with a simple package name', async () => { @@ -379,12 +368,7 @@ describe('nx-gradle spring-boot e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a kotlin application', async () => { @@ -479,12 +463,7 @@ describe('nx-gradle spring-boot e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should build-image a kotlin application', async () => { @@ -584,12 +563,7 @@ describe('nx-gradle spring-boot e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('directory with dash', async () => { @@ -624,12 +598,7 @@ describe('nx-gradle spring-boot e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library', async () => { @@ -1210,12 +1179,7 @@ describe('nx-gradle spring-boot e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a library with a simple name', async () => { @@ -1324,12 +1288,7 @@ describe('nx-gradle spring-boot e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should create a minimal kotlin application', async () => { @@ -1378,12 +1337,7 @@ describe('nx-gradle spring-boot e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 120000); it('should skip starter code when generating a java library with skipStarterCode option', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-maven/maven-root-directory.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-maven/maven-root-directory.spec.ts index 013a7e7ef..2e11fa12d 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-maven/maven-root-directory.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-maven/maven-root-directory.spec.ts @@ -3,8 +3,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -376,12 +375,7 @@ describe('nx-maven maven-root-directory e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('should use specified options to create a quarkus application', async () => { @@ -432,12 +426,7 @@ describe('nx-maven maven-root-directory e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); const testResult = await runNxCommandAsync(`test ${appName}`); expect(testResult.stdout).toContain('Executor ran for Test'); @@ -807,12 +796,7 @@ describe('nx-maven maven-root-directory e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('should create a micronaut library', async () => { @@ -955,11 +939,6 @@ describe('nx-maven maven-root-directory e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); }); diff --git a/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-bom.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-bom.spec.ts index f8a1548c8..a60b02766 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-bom.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-bom.spec.ts @@ -1,8 +1,7 @@ import { createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -152,12 +151,7 @@ describe('nx-maven micronaut bom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('should create a micronaut library', async () => { @@ -288,12 +282,7 @@ describe('nx-maven micronaut bom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('micronaut: should add a lib to an app dependencies', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-parent-pom.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-parent-pom.spec.ts index 893dc6ba4..6d927c58c 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-parent-pom.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-maven/micronaut-parent-pom.spec.ts @@ -3,8 +3,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -176,12 +175,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('should build-image a java application', async () => { @@ -272,12 +266,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a kotlin application', async () => { @@ -353,12 +342,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should build-image a kotlin application', async () => { @@ -449,12 +433,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should generate an app with a simple package name', async () => { @@ -533,12 +512,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('directory with dash', async () => { @@ -573,12 +547,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a library', async () => { @@ -1507,12 +1476,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a library with a simple name', async () => { @@ -1612,12 +1576,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a minimal kotlin application', async () => { @@ -1658,12 +1617,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should skip starter code when generating a java library with skipStarterCode option', async () => { @@ -1749,12 +1703,7 @@ describe('nx-maven micronaut-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should generate java nested sub-projects', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-maven/quarkus-bom.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-maven/quarkus-bom.spec.ts index a36adbe82..93d652ee2 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-maven/quarkus-bom.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-maven/quarkus-bom.spec.ts @@ -3,8 +3,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -175,12 +174,7 @@ describe('nx-maven quarkus bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should build-image a java app', async () => { @@ -263,12 +257,7 @@ describe('nx-maven quarkus bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); const testResult = await runNxCommandAsync(`test ${appName}`); expect(testResult.stdout).toContain('Executor ran for Test'); @@ -339,12 +328,7 @@ describe('nx-maven quarkus bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); const testResult = await runNxCommandAsync(`test ${appName}`); expect(testResult.stdout).toContain('Executor ran for Test'); @@ -489,12 +473,7 @@ describe('nx-maven quarkus bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should generate an app with a simple package name', async () => { @@ -571,12 +550,7 @@ describe('nx-maven quarkus bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('directory with dash', async () => { @@ -616,12 +590,7 @@ describe('nx-maven quarkus bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a library', async () => { @@ -1604,12 +1573,7 @@ describe('nx-maven quarkus bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a library with a simple name', async () => { diff --git a/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-bom.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-bom.spec.ts index 3a7749660..d575f839d 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-bom.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-bom.spec.ts @@ -2,8 +2,7 @@ import { normalizeName } from '@jnxplus/common'; import { createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -195,12 +194,7 @@ describe('nx-maven spring-boot bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('spring-boot: should add a lib to an app dependencies', async () => { @@ -444,11 +438,6 @@ describe('nx-maven spring-boot bom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); }); diff --git a/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-parent-pom.spec.ts b/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-parent-pom.spec.ts index ae8badbe2..fd5087bd6 100644 --- a/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-parent-pom.spec.ts +++ b/testing-projects/jnxplus-e2e/tests/nx-maven/spring-boot-parent-pom.spec.ts @@ -3,8 +3,7 @@ import { checkFilesDoNotExist, createTestWorkspace, getData, - killPorts, - promisifiedTreeKill, + killProcessAndPorts, runNxCommandUntil, } from '@jnxplus/internal/testing'; import { names } from '@nx/devkit'; @@ -176,12 +175,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(8080); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, 8080); }, 240000); it('should build-image a java application', async () => { @@ -277,12 +271,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a kotlin application', async () => { @@ -327,12 +316,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); const testResult = await runNxCommandAsync(`test ${appName}`); expect(testResult.stdout).toContain('Executor ran for Test'); @@ -434,12 +418,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); const testResult = await runNxCommandAsync(`test ${appName}`); expect(testResult.stdout).toContain('Executor ran for Test'); @@ -550,12 +529,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('directory with dash', async () => { @@ -590,12 +564,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a library', async () => { @@ -975,12 +944,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); const testResult = await runNxCommandAsync(`test ${appName}`); expect(testResult.stdout).toContain('Executor ran for Test'); @@ -1625,12 +1589,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a library with a simple name', async () => { @@ -1736,12 +1695,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should create a minimal kotlin application', async () => { @@ -1790,12 +1744,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { ); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should skip starter code when generating a java library with skipStarterCode option', async () => { @@ -1885,12 +1834,7 @@ describe('nx-maven spring-boot-parent-pom e2e', () => { expect(dataResult.message).toMatch('Hello World!'); // port and process cleanup - try { - await promisifiedTreeKill(process.pid, 'SIGKILL'); - await killPorts(port); - } catch (err) { - // ignore err - } + await killProcessAndPorts(process.pid, port); }, 240000); it('should generate java nested sub-projects', async () => {