mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 12:00:46 +00:00
test: avoid line count filter allocations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user