test: avoid line count filter allocations

This commit is contained in:
Peter Steinberger
2026-05-08 22:13:41 +01:00
parent 2f26025085
commit edfc5294cb
6 changed files with 58 additions and 8 deletions

View File

@@ -35,6 +35,16 @@ const TS_PATHS = {
const OS_TS_PATHS = [TS_PATHS.linux, TS_PATHS.macos, TS_PATHS.windows];
function countNonEmptyLines(value: string): number {
let count = 0;
for (const line of value.split("\n")) {
if (line) {
count += 1;
}
}
return count;
}
function runTsEval(source: string, env: Record<string, string> = {}) {
return execFileSync("node", ["--import", "tsx", "--input-type=module", "--eval", source], {
encoding: "utf8",
@@ -79,7 +89,7 @@ describe("Parallels smoke model selection", () => {
} else {
expect(wrapper, wrapperPath).toContain(TS_PATHS[platform as "linux" | "macos" | "windows"]);
}
expect(wrapper.split("\n").filter(Boolean).length).toBeLessThanOrEqual(5);
expect(countNonEmptyLines(wrapper)).toBeLessThanOrEqual(5);
}
});