Skip to content
Closed
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
1 change: 0 additions & 1 deletion test/opentofu-basic/.terraform/modules/test-js-commonjs_3
Submodule test-js-commonjs_3 deleted from 84dfbf
33 changes: 33 additions & 0 deletions test/utils/getDebuggerStartCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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: 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;
}
7 changes: 2 additions & 5 deletions test/utils/removeInfra.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down
31 changes: 3 additions & 28 deletions test/utils/startDebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
Expand Down