From 7c32e63c7c7075957be1ad2c48b49edc0675bbe4 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Wed, 5 Mar 2025 13:05:01 +0100 Subject: [PATCH 1/3] fix: tests --- test/utils/getDebuggerStartCommand.ts | 29 +++++++++++++++++++++++++ test/utils/removeInfra.ts | 7 ++---- test/utils/startDebugger.ts | 31 +++------------------------ 3 files changed, 34 insertions(+), 33 deletions(-) create mode 100644 test/utils/getDebuggerStartCommand.ts diff --git a/test/utils/getDebuggerStartCommand.ts b/test/utils/getDebuggerStartCommand.ts new file mode 100644 index 00000000..6cd9387c --- /dev/null +++ b/test/utils/getDebuggerStartCommand.ts @@ -0,0 +1,29 @@ +export function getDebuggerStartCommand(folder: string, args: string[]) { + let testMonorepo = process.env.TEST_MONOREPO === 'true'; + if (testMonorepo) { + testMonorepo = true; + // just the last two part of the folder + const folderParts = folder.split('/'); + const testProjectFolder = + folderParts[folderParts.length - 2] + + '/' + + folderParts[folderParts.length - 1]; + args.push(`-m ${testProjectFolder}`); + } + + if (process.env.OBSERVABLE_MODE === 'true') { + args.push('-o'); + } + + args.push('-v'); + + let command = `node ${testMonorepo ? '' : '../../'}dist/lldebugger.mjs ${args?.join(' ')}`; + + if (process.env.REAL_NPM === 'true') { + console.log('Running the debugger with the real NPM'); + command = `lld ${args?.join(' ')}`; + } else { + console.log('Running the debugger with just genereted code'); + } + return command; +} diff --git a/test/utils/removeInfra.ts b/test/utils/removeInfra.ts index 29c61145..da12b399 100644 --- a/test/utils/removeInfra.ts +++ b/test/utils/removeInfra.ts @@ -1,5 +1,6 @@ import { ChildProcess, execSync } from 'child_process'; import { setTimeout } from 'timers/promises'; +import { getDebuggerStartCommand } from './getDebuggerStartCommand.js'; export async function removeInfra( lldProcess: ChildProcess | undefined, @@ -8,11 +9,7 @@ export async function removeInfra( ) { lldProcess?.kill(); - let command = `node ../../dist/lldebugger.mjs --remove ${args?.join(' ')}`; - - if (process.env.REAL_NPM === 'true') { - command = `lld --remove ${args?.join(' ')}`; - } + const command = getDebuggerStartCommand(folder, [...args, '--remove']); await execSync(command, { cwd: folder, diff --git a/test/utils/startDebugger.ts b/test/utils/startDebugger.ts index d4a1dffd..8feef6c7 100644 --- a/test/utils/startDebugger.ts +++ b/test/utils/startDebugger.ts @@ -2,6 +2,7 @@ import { spawn } from 'child_process'; import { setTimeout } from 'timers/promises'; import { exec } from 'child_process'; import { promisify } from 'util'; +import { getDebuggerStartCommand } from './getDebuggerStartCommand.js'; export const execAsync = promisify(exec); @@ -18,34 +19,8 @@ export async function startDebugger(folder: string, args: string[] = []) { async function startDebuggerInternal(folder: string, args: string[] = []) { console.log('Starting LLD...'); - let testMonorepo = false; - if (process.env.TEST_MONOREPO === 'true') { - testMonorepo = true; - // just the last two part of the folder - const folderParts = folder.split('/'); - const testProjectFolder = - folderParts[folderParts.length - 2] + - '/' + - folderParts[folderParts.length - 1]; - args.push(`-m ${testProjectFolder}`); - } - - if (process.env.OBSERVABLE_MODE === 'true') { - args.push('-o'); - } - - args.push('-v'); - - let command = `node ${ - testMonorepo ? '' : '../../' - }dist/lldebugger.mjs ${args?.join(' ')}`; - - if (process.env.REAL_NPM === 'true') { - console.log('Running the debugger with the real NPM'); - command = `lld ${args?.join(' ')}`; - } else { - console.log('Running the debugger with just genereted code'); - } + const testMonorepo = process.env.TEST_MONOREPO === 'true'; + const command = getDebuggerStartCommand(folder, args); const lldProcess = spawn(command, { cwd: !testMonorepo ? folder : undefined, From 823071dce70d18629da4860c71f7da81185400e8 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Wed, 5 Mar 2025 13:06:38 +0100 Subject: [PATCH 2/3] chore: cleaning --- test/opentofu-basic/.terraform/modules/test-js-commonjs_3 | 1 - 1 file changed, 1 deletion(-) delete mode 160000 test/opentofu-basic/.terraform/modules/test-js-commonjs_3 diff --git a/test/opentofu-basic/.terraform/modules/test-js-commonjs_3 b/test/opentofu-basic/.terraform/modules/test-js-commonjs_3 deleted file mode 160000 index 84dfbfdd..00000000 --- a/test/opentofu-basic/.terraform/modules/test-js-commonjs_3 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 84dfbfddf9483bc56afa0aff516177c03652f0c7 From aef03ddaf4a722cd558b6ee3b167165f7f3d6a1e Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Wed, 5 Mar 2025 13:59:29 +0100 Subject: [PATCH 3/3] WIP --- test/utils/getDebuggerStartCommand.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/utils/getDebuggerStartCommand.ts b/test/utils/getDebuggerStartCommand.ts index 6cd9387c..9cfb0bfe 100644 --- a/test/utils/getDebuggerStartCommand.ts +++ b/test/utils/getDebuggerStartCommand.ts @@ -17,13 +17,17 @@ export function getDebuggerStartCommand(folder: string, args: string[]) { args.push('-v'); - let command = `node ${testMonorepo ? '' : '../../'}dist/lldebugger.mjs ${args?.join(' ')}`; + let command: string; if (process.env.REAL_NPM === 'true') { console.log('Running the debugger with the real NPM'); command = `lld ${args?.join(' ')}`; } else { + command = `node ${testMonorepo ? '' : '../../'}dist/lldebugger.mjs ${args?.join(' ')}`; console.log('Running the debugger with just genereted code'); } + console.log(`Command to run LLD: ${command}`); + console.log(`Current folder: ${import.meta.dirname}`); + return command; }