The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
test: guard broken-symlink tests so the suite passes on Windows (#2176)
Johnson K C40673a89fa14
diff --git a/tests/ci/validators.test.js b/tests/ci/validators.test.jsindex 0e6810849..0a06fc8fd 100644--- a/tests/ci/validators.test.js+++ b/tests/ci/validators.test.js@@ -2577,7 +2577,21 @@ function runTests() {fs.mkdirSync(validSkill, { recursive: true });// Broken symlink: target does not exist — statSync will throw ENOENTconst brokenLink = path.join(skillsDir, 'broken-skill');- fs.symlinkSync('/nonexistent/target/path', brokenLink);+ try {+ fs.symlinkSync('/nonexistent/target/path', brokenLink);+ } catch (err) {+ // Skip only where symlink creation is blocked (e.g. Windows without+ // Developer Mode / admin rights → EPERM/EACCES); rethrow anything else+ // so real failures aren't masked.+ if (err && (err.code === 'EPERM' || err.code === 'EACCES')) {+ console.log(' (skipped — symlinks not supported)');+ cleanupTestDir(testDir);+ cleanupTestDir(agentsDir);+ fs.rmSync(skillsDir, { recursive: true, force: true });+ return;+ }+ throw err;+ }// Command that references the valid skill (should resolve)fs.writeFileSync(path.join(testDir, 'cmd.md'),diff --git a/tests/lib/session-manager.test.js b/tests/lib/session-manager.test.jsindex e39b0a878..a34447d7c 100644--- a/tests/lib/session-manager.test.js+++ b/tests/lib/session-manager.test.js@@ -1384,7 +1384,19 @@ src/main.ts// Create a broken symlink that matches the session filename patternconst brokenSymlink = '2026-02-10-deadbeef-session.tmp';- fs.symlinkSync('/nonexistent/path/that/does/not/exist', path.join(sessionsDir, brokenSymlink));+ try {+ fs.symlinkSync('/nonexistent/path/that/does/not/exist', path.join(sessionsDir, brokenSymlink));+ } catch (err) {+ // Skip only where symlink creation is blocked (e.g. Windows without+ // Developer Mode / admin rights → EPERM/EACCES); rethrow anything else+ // so real failures aren't masked.+ if (err && (err.code === 'EPERM' || err.code === 'EACCES')) {+ console.log(' (skipped — symlinks not supported)');+ fs.rmSync(isoHome, { recursive: true, force: true });+ return;+ }+ throw err;+ }const origHome = process.env.HOME;const origUserProfile = process.env.USERPROFILE;@@ -1421,7 +1433,19 @@ src/main.ts// Create a broken symlink that matches a session ID patternconst brokenFile = '2026-02-11-deadbeef-session.tmp';- fs.symlinkSync('/nonexistent/target/that/does/not/exist', path.join(sessionsDir, brokenFile));+ try {+ fs.symlinkSync('/nonexistent/target/that/does/not/exist', path.join(sessionsDir, brokenFile));+ } catch (err) {+ // Skip only where symlink creation is blocked (e.g. Windows without+ // Developer Mode / admin rights → EPERM/EACCES); rethrow anything else+ // so real failures aren't masked.+ if (err && (err.code === 'EPERM' || err.code === 'EACCES')) {+ console.log(' (skipped — symlinks not supported)');+ fs.rmSync(isoHome, { recursive: true, force: true });+ return;+ }+ throw err;+ }const origHome = process.env.HOME;const origUserProfile = process.env.USERPROFILE;diff --git a/tests/lib/utils.test.js b/tests/lib/utils.test.jsindex a85758e42..3217567a2 100644--- a/tests/lib/utils.test.js+++ b/tests/lib/utils.test.js@@ -1415,7 +1415,19 @@ function runTests() {const realFile = path.join(tmpDir, 'real.txt');fs.writeFileSync(realFile, 'content');const brokenLink = path.join(tmpDir, 'broken.txt');- fs.symlinkSync('/nonexistent/path/does/not/exist', brokenLink);+ try {+ fs.symlinkSync('/nonexistent/path/does/not/exist', brokenLink);+ } catch (err) {+ // Skip only where symlink creation is blocked (e.g. Windows without+ // Developer Mode / admin rights → EPERM/EACCES); rethrow anything else+ // so real failures aren't masked.+ if (err && (err.code === 'EPERM' || err.code === 'EACCES')) {+ console.log(' (skipped — symlinks not supported)');+ fs.rmSync(tmpDir, { recursive: true, force: true });+ return;+ }+ throw err;+ }try {const results = utils.findFiles(tmpDir, '*.txt');