mirror of
https://github.com/affaan-m/ECC.git
synced 2026-12-01 12:45:15 +09:00
maint: integrate reviewed contribution #3593
This commit is contained in:
2 files changed
+17
-7
No files matched your search
@@ -32,8 +32,8 @@ EOF
|
||||
|
||||
mkdir -p "$(dirname "$handoff_file")" "$(dirname "$status_file")"
|
||||
|
||||
if [[ ! -r "$task_file" ]]; then
|
||||
write_status "failed" "- Error: task file is missing or unreadable (\`$task_file\`)"
|
||||
if [[ ! -f "$task_file" || ! -r "$task_file" ]]; then
|
||||
write_status "failed" "- Error: task file is missing, unreadable, or not a regular file (\`$task_file\`)"
|
||||
{
|
||||
echo "# Handoff"
|
||||
echo
|
||||
@@ -41,7 +41,7 @@ if [[ ! -r "$task_file" ]]; then
|
||||
echo "- Branch: \`$(git rev-parse --abbrev-ref HEAD)\`"
|
||||
echo "- Worktree: \`$(pwd)\`"
|
||||
echo
|
||||
echo "Task file is missing or unreadable: \`$task_file\`"
|
||||
echo "Task file is missing, unreadable, or not a regular file: \`$task_file\`"
|
||||
} > "$handoff_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -24,7 +24,7 @@ function test(desc, fn) {
|
||||
}
|
||||
}
|
||||
|
||||
function runWorker({ policy, exitCode = 0, outsideTask = false, relativeTask = false } = {}) {
|
||||
function runWorker({ policy, exitCode = 0, outsideTask = false, relativeTask = false, directoryTask = false } = {}) {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-orch-worker-'));
|
||||
const binDir = path.join(tempRoot, 'bin');
|
||||
const captureFile = path.join(tempRoot, 'args.json');
|
||||
@@ -34,7 +34,8 @@ function runWorker({ policy, exitCode = 0, outsideTask = false, relativeTask = f
|
||||
|
||||
try {
|
||||
fs.mkdirSync(binDir);
|
||||
fs.writeFileSync(taskFile, 'Make a focused change.');
|
||||
if (directoryTask) fs.mkdirSync(taskFile);
|
||||
else fs.writeFileSync(taskFile, 'Make a focused change.');
|
||||
fs.writeFileSync(path.join(binDir, 'codex'), `#!/usr/bin/env node
|
||||
const fs = require('fs');
|
||||
const args = process.argv.slice(2);
|
||||
@@ -96,6 +97,15 @@ test('rejects a readable sibling task before invoking Codex', () => {
|
||||
assert.ok(result.workerStatus.includes('task file outside worktree'));
|
||||
});
|
||||
|
||||
test('rejects a directory task before invoking Codex', () => {
|
||||
const result = runWorker({ directoryTask: true });
|
||||
assert.notStrictEqual(result.status, 0);
|
||||
assert.strictEqual(result.args, null);
|
||||
assert.ok(result.workerStatus.includes('- State: failed'));
|
||||
assert.ok(result.handoff.includes('Task file is missing, unreadable, or not a regular file'));
|
||||
assert.ok(result.workerStatus.includes('task file is missing, unreadable, or not a regular file'));
|
||||
});
|
||||
|
||||
test('forwards the explicit supported approval policy', () => {
|
||||
const result = runWorker({ policy: 'on-request' });
|
||||
assert.strictEqual(result.status, 0, result.stderr);
|
||||
@@ -140,11 +150,11 @@ test('fails fast for an unreadable task file and records failure artifacts', ()
|
||||
|
||||
assert.ok(statusContent.includes('- State: failed'), 'Status file should record the failure state');
|
||||
assert.ok(
|
||||
statusContent.includes('task file is missing or unreadable'),
|
||||
statusContent.includes('task file is missing, unreadable, or not a regular file'),
|
||||
'Status file should explain the task-file failure'
|
||||
);
|
||||
assert.ok(
|
||||
handoffContent.includes('Task file is missing or unreadable'),
|
||||
handoffContent.includes('Task file is missing, unreadable, or not a regular file'),
|
||||
'Handoff file should explain the task-file failure'
|
||||
);
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user