mirror of
https://github.com/affaan-m/ECC.git
synced 2026-12-01 20:55:25 +09:00
test(hooks): keep context-gate cwd fixtures inside private sandboxes
Replace the literal /tmp/... cwd values in the context-gate suites with paths under each test's realpath'd mkdtemp sandbox. CodeQL treats /tmp string literals as shared temp sources and traced them through the hook input into readFileTail. The hook only hashes cwd, so assertions are unchanged.
This commit is contained in:
2 files changed
+6
-6
No files matched your search
@@ -61,7 +61,7 @@ function isProposedPathLine(line) {
|
||||
}
|
||||
|
||||
function fire(sandbox, extra = {}) {
|
||||
const input = { cwd: '/tmp/owner-a/project', session_id: 'mysess', transcript_path: sandbox.transcript, ...extra };
|
||||
const input = { cwd: path.join(sandbox.root, 'owner-a', 'project'), session_id: 'mysess', transcript_path: sandbox.transcript, ...extra };
|
||||
const result = spawnSync(process.execPath, [RUNNER, 'user-prompt:context-gate', 'scripts/hooks/context-gate.js', 'standard,strict'], {
|
||||
cwd: REPO_ROOT,
|
||||
env: sandbox.env,
|
||||
@@ -123,7 +123,7 @@ function runTests() {
|
||||
record(test('same-named project roots get distinct proposals', () => {
|
||||
clearResumeDir(sandbox);
|
||||
const a = fire(sandbox);
|
||||
const b = fire(sandbox, { cwd: '/tmp/owner-b/project' });
|
||||
const b = fire(sandbox, { cwd: path.join(sandbox.root, 'owner-b', 'project') });
|
||||
assert.ok(a.target && b.target, `both fires should propose a destination. Got: ${a.target ? b.text : a.text}`);
|
||||
assert.notStrictEqual(a.target, b.target);
|
||||
}));
|
||||
|
||||
@@ -417,8 +417,8 @@ function runTests() {
|
||||
const ctx = JSON.parse(raw).hookSpecificOutput.additionalContext;
|
||||
return ctx.match(/\S*[/\\]resume[/\\]\S*-test\.md/)[0];
|
||||
};
|
||||
const first = extract(run(inputFor(t, { cwd: '/tmp/ecc-demo-proj' }), { env }));
|
||||
const second = extract(run(inputFor(t, { cwd: '/tmp/ecc-demo-proj' }), { env }));
|
||||
const first = extract(run(inputFor(t, { cwd: path.join(FIXTURE_DIR, 'ecc-demo-proj') }), { env }));
|
||||
const second = extract(run(inputFor(t, { cwd: path.join(FIXTURE_DIR, 'ecc-demo-proj') }), { env }));
|
||||
assert.strictEqual(first, second, 'same session must reuse one checkpoint path (idempotent)');
|
||||
})
|
||||
)
|
||||
@@ -448,8 +448,8 @@ function runTests() {
|
||||
delete process.env.CLAUDE_SESSION_ID;
|
||||
// Two different owners, same basename "project", NO session id.
|
||||
const envEnforce = { ECC_CONTEXT_GATE_MODE: 'enforce' };
|
||||
const outA = JSON.parse(run(JSON.stringify({ transcript_path: t, cwd: '/tmp/owner-a/project', prompt: 'go' }), { env: envEnforce }));
|
||||
const outB = JSON.parse(run(JSON.stringify({ transcript_path: t, cwd: '/tmp/owner-b/project', prompt: 'go' }), { env: envEnforce }));
|
||||
const outA = JSON.parse(run(JSON.stringify({ transcript_path: t, cwd: path.join(sandbox, 'owner-a', 'project'), prompt: 'go' }), { env: envEnforce }));
|
||||
const outB = JSON.parse(run(JSON.stringify({ transcript_path: t, cwd: path.join(sandbox, 'owner-b', 'project'), prompt: 'go' }), { env: envEnforce }));
|
||||
for (const out of [outA, outB]) {
|
||||
const ctx = out.hookSpecificOutput.additionalContext;
|
||||
// Enforcement declined: NO checkpoint path is named...
|
||||
|
||||
Reference in new issue
Block a user