Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix: stabilize windows project metadata assertions

Affaan Mustafab981c765ae27
diff --git a/tests/hooks/hooks.test.js b/tests/hooks/hooks.test.js
index e264cdf55..19b7526d3 100644
--- a/tests/hooks/hooks.test.js
+++ b/tests/hooks/hooks.test.js
@@ -57,6 +57,27 @@ function fromBashPath(filePath) {
return rawPath;
}
+function normalizeComparablePath(filePath) {
+ const nativePath = fromBashPath(filePath);
+ if (!nativePath) {
+ return nativePath;
+ }
+
+ let comparablePath = nativePath;
+ try {
+ comparablePath = fs.realpathSync.native ? fs.realpathSync.native(nativePath) : fs.realpathSync(nativePath);
+ } catch {
+ comparablePath = path.resolve(nativePath);
+ }
+
+ comparablePath = comparablePath.replace(/[\\/]+/g, '/');
+ if (comparablePath.length > 1 && !/^[A-Za-z]:\/$/.test(comparablePath)) {
+ comparablePath = comparablePath.replace(/\/+$/, '');
+ }
+
+ return process.platform === 'win32' ? comparablePath.toLowerCase() : comparablePath;
+}
+
function sleepMs(ms) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
}
@@ -2361,7 +2382,12 @@ async function runTests() {
const shellCommand = [`cd "${toBashPath(repoDir)}"`, `source "${toBashPath(detectProjectPath)}" >/dev/null 2>&1`, 'printf "%s\\n" "$PROJECT_ID"', 'printf "%s\\n" "$PROJECT_DIR"'].join('; ');
const proc = spawn('bash', ['-lc', shellCommand], {
- env: { ...process.env, HOME: homeDir, USERPROFILE: homeDir },
+ env: {
+ ...process.env,
+ HOME: homeDir,
+ USERPROFILE: homeDir,
+ CLAUDE_PROJECT_DIR: ''
+ },
stdio: ['ignore', 'pipe', 'pipe']
});
@@ -2395,19 +2421,26 @@ async function runTests() {
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
const metadata = JSON.parse(fs.readFileSync(projectMetadataPath, 'utf8'));
- const nativeMetadataRoot = fromBashPath(metadata.root);
- const nativeProjectDir = fromBashPath(projectDir);
+ const comparableMetadataRoot = normalizeComparablePath(metadata.root);
+ const comparableRepoDir = normalizeComparablePath(repoDir);
+ const comparableProjectDir = normalizeComparablePath(projectDir);
+ const comparableExpectedProjectDir = normalizeComparablePath(expectedProjectDir);
assert.ok(registry[projectId], 'registry should contain the detected project');
assert.strictEqual(metadata.id, projectId, 'project.json should include the detected id');
assert.strictEqual(metadata.name, path.basename(repoDir), 'project.json should include the repo name');
- assert.strictEqual(fs.realpathSync(nativeMetadataRoot), fs.realpathSync(repoDir), 'project.json should include the repo root');
+ assert.strictEqual(
+ comparableMetadataRoot,
+ comparableRepoDir,
+ `project.json should include the repo root (expected ${comparableRepoDir}, got ${comparableMetadataRoot})`
+ );
assert.strictEqual(metadata.remote, 'https://github.com/example/ecc-test.git', 'project.json should include the sanitized remote');
assert.ok(metadata.created_at, 'project.json should include created_at');
assert.ok(metadata.last_seen, 'project.json should include last_seen');
- assert.ok(
- nativeProjectDir.endsWith(path.join('projects', projectId)),
- `PROJECT_DIR should point at the project storage directory, got: ${projectDir}`
+ assert.strictEqual(
+ comparableProjectDir,
+ comparableExpectedProjectDir,
+ `PROJECT_DIR should point at the project storage directory (expected ${comparableExpectedProjectDir}, got ${comparableProjectDir})`
);
} finally {
cleanupTestDir(testRoot);