test: Make test resource acquisition and cleanup safe (#37923)

This commit is contained in:
Declan Carroll
2026-09-16 13:58:30 +00:00
committed by GitHub
parent a24f8ae999
commit 07fcc835cd
22 changed files with 337 additions and 120 deletions
+12 -3
View File
@@ -24,7 +24,11 @@ import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
const write = process.argv.includes('--write');
const baselineFile = join(dirname(fileURLToPath(import.meta.url)), '..', '.boundaries-baseline.json');
const baselineFile = join(
dirname(fileURLToPath(import.meta.url)),
'..',
'.boundaries-baseline.json',
);
const baseline = JSON.parse(readFileSync(baselineFile, 'utf8')).issues;
// turbo exits non-zero when issues exist; we read the output regardless.
@@ -44,6 +48,11 @@ if (!match) {
const exemptedHarness = (output.match(/import `@nodes-testing\/[^`]+` leaves the package/g) ?? [])
.length;
// Container tests use this path to share the test-only stack implementation.
const exemptedContainerHarness = (
output.match(/import `\.\.\/\.\.\/\.\.\/containers\/[^`]+` leaves the package/g) ?? []
).length;
// The editor's browser shim for `@n8n/expression-runtime` re-exports that package's
// source directly: the barrel reaches IsolatedVmBridge, which requires isolated-vm, a
// native Node module that cannot be bundled for a browser. The shim is the sanctioned
@@ -67,7 +76,7 @@ const exemptedBrowserShim = (
) ?? []
).length;
const exempted = exemptedHarness + exemptedBrowserShim;
const exempted = exemptedHarness + exemptedContainerHarness + exemptedBrowserShim;
const current = Number(match[1]) - exempted;
if (write) {
@@ -77,7 +86,7 @@ if (write) {
}
console.log(
`turbo boundaries: ${current} issues (baseline ${baseline}, ${exemptedHarness} node-test-harness + ${exemptedBrowserShim} browser-shim imports exempted)`,
`turbo boundaries: ${current} issues (baseline ${baseline}, ${exemptedHarness} node-test-harness + ${exemptedContainerHarness} container-harness + ${exemptedBrowserShim} browser-shim imports exempted)`,
);
if (current > baseline) {