mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-23 01:32:40 +00:00
fix(server): measure degraded watchers through physical temp paths
Git canonicalizes the checkout root. Match that spelling in the benchmark fixture so a symlinked temporary directory still triggers the simulated watcher failure and degraded polling.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
@@ -191,7 +191,11 @@ async function closeMeasuredService(input: {
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const tempDir = mkdtempSync(path.join(tmpdir(), "paseo-git-observation-measurement-"));
|
||||
// Git reports physical roots; keep watcher-failure injection in that same
|
||||
// spelling when the system temporary directory is a symlink.
|
||||
const tempDir = realpathSync(
|
||||
mkdtempSync(path.join(tmpdir(), "paseo-git-observation-measurement-")),
|
||||
);
|
||||
const repoDir = path.join(tempDir, "repo");
|
||||
const paseoHome = path.join(tempDir, "paseo-home");
|
||||
const trackedPath = path.join(repoDir, "tracked.txt");
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
||||
import {
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
rmSync,
|
||||
symlinkSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { execFile, execFileSync } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
import { fileURLToPath } from "node:url";
|
||||
@@ -529,7 +537,14 @@ test("Git observation measurement separates startup from idle and reaches its de
|
||||
const script = fileURLToPath(
|
||||
new URL("../../scripts/measure-git-observation.ts", import.meta.url),
|
||||
);
|
||||
const root = realpathSync(mkdtempSync(path.join(tmpdir(), "paseo-measurement-test-")));
|
||||
const actualTemp = path.join(root, "actual");
|
||||
const aliasedTemp = path.join(root, "alias");
|
||||
mkdirSync(actualTemp);
|
||||
symlinkSync(actualTemp, aliasedTemp, "junction");
|
||||
cleanup.push(async () => rmSync(root, { recursive: true, force: true }));
|
||||
const { stdout } = await promisify(execFile)(process.execPath, ["--import", "tsx", script], {
|
||||
env: { ...process.env, TMPDIR: aliasedTemp, TMP: aliasedTemp, TEMP: aliasedTemp },
|
||||
timeout: 30_000,
|
||||
maxBuffer: 1024 * 1024,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user