mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-16 13:02:10 +00:00
test: skip symlink tests when the OS refuses symlink creation
Adds a trySymlink helper that logs the existing skip notice and returns false on EPERM/EACCES/ENOSYS, and uses it where tests created symlinks unguarded. Non-admin Windows accounts without Developer Mode now skip these cases instead of failing.
This commit is contained in:
1 parent
25278e7d7b
commit
09de2c247a
12 files changed
+52
-21
No files matched your search
@@ -9,6 +9,7 @@ const { pathToFileURL } = require('url');
|
||||
const { createManifestInstallPlan, applyInstallPlan, previewInstallPlan } = require('../../scripts/lib/install-executor');
|
||||
const { withHookConsent } = require('../../scripts/lib/install/hook-consent');
|
||||
const { repairInstalledStates } = require('../../scripts/lib/install-lifecycle');
|
||||
const { trySymlink } = require('../lib/helpers/symlink-support');
|
||||
const repo = path.resolve(__dirname, '../..');
|
||||
let passed = 0;
|
||||
let failed = 0;
|
||||
@@ -186,7 +187,7 @@ for (const scope of ['package.json', 'lib/package.json']) {
|
||||
test(`symlinked ${scope} refuses before mutation`, f => {
|
||||
const file = path.join(f.scripts, scope); const outside = path.join(f.dir, 'user-package.json');
|
||||
f.write(outside, '{"type":"commonjs"}\n'); fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.symlinkSync(outside, file); const before = snapshot(f.dir);
|
||||
if (!trySymlink(outside, file)) return; const before = snapshot(f.dir);
|
||||
assert.notStrictEqual(f.install().status, 0); assert.deepStrictEqual(snapshot(f.dir), before);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ const { normalizeManifest, buildInventory, collectResources, collectTaskFiles, r
|
||||
const now = '2026-09-08T06:30:00.000Z';
|
||||
const task = (id, paths, extra = {}) => ({ id, repoId: 'repo', paths, ...extra });
|
||||
const fixture = () => ({ version: 1, repositories: [{ id: 'repo', sources: { 'src/a.js': "require('../lib/b')", 'lib/b.js': '' } }], tasks: [task('a', ['src/a.js']), task('b', ['lib/b.js'])], leases: [] });
|
||||
const { trySymlink } = require('../lib/helpers/symlink-support');
|
||||
const run = value => buildInventory(value, { now });
|
||||
|
||||
test('direct import warns when exact-path baseline would miss it; deterministic JSON', () => {
|
||||
@@ -87,7 +88,7 @@ test('task file adapter reads structured status, labels mtime, skips symlinks an
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'coordination-test-'));
|
||||
try {
|
||||
fs.mkdirSync(path.join(dir, 'worker')); fs.writeFileSync(path.join(dir, 'worker', 'STATUS.md'), '- State: running\n- Updated: 2026-09-08T06:29:00Z\n');
|
||||
fs.symlinkSync(path.join(dir, 'worker'), path.join(dir, 'linked'));
|
||||
if (!trySymlink(path.join(dir, 'worker'), path.join(dir, 'linked'))) return;
|
||||
const r = collectTaskFiles(dir); assert.equal(r.tasks.length, 1); assert.equal(r.tasks[0].status, 'running');
|
||||
assert.ok(r.tasks[0].statusFileModifiedAt); assert.equal(r.tasks[0].heartbeatAt, '2026-09-08T06:29:00Z');
|
||||
fs.writeFileSync(path.join(dir, 'large.json'), ' '.repeat(1024 * 1024 + 1));
|
||||
|
||||
@@ -7,6 +7,7 @@ const path = require('path');
|
||||
const { spawn, spawnSync } = require('child_process');
|
||||
const { PassThrough } = require('stream');
|
||||
const { pathToFileURL } = require('url');
|
||||
const { trySymlink } = require('../lib/helpers/symlink-support');
|
||||
|
||||
const SERVER = path.join(__dirname, '..', '..', 'scripts', 'memory-mcp.mjs');
|
||||
const {
|
||||
@@ -450,7 +451,7 @@ async function main() {
|
||||
await test('starts when the npm bin invokes the server through a symlink', async () => {
|
||||
const binRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-memory-bin-'));
|
||||
const binPath = path.join(binRoot, 'ecc-memory-mcp');
|
||||
fs.symlinkSync(SERVER, binPath);
|
||||
if (!trySymlink(SERVER, binPath)) return;
|
||||
try {
|
||||
await withClient(async client => {
|
||||
const tools = await client.listTools();
|
||||
|
||||
Reference in new issue
Block a user