A batch no longer waits for its slowest function: once some of its functions are approved and the rest wait for review, the approved ones merge as their own batch (the pending functions put back as they are on the base commit), and the rest is rebased onto that commit. The merge re-verifies the split; if anything breaks, the batch merges as a whole as before. Comparing compiler output against the original runs in worker threads. A check that recompiled dozens of units (a header change) blocked the coordinator's event loop for minutes, so the website stopped responding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RNwtXPYqFu3oKaaXwYwNWW
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { functionRegions, withoutFunctions } from '../src/server/split.js';
|
|
|
|
const file = `#include "a.h"
|
|
|
|
// FUNCTION: fn_00001
|
|
int a() {
|
|
const char* s = "}";
|
|
return 1; // }
|
|
}
|
|
|
|
// FUNCTION: fn_00002
|
|
// FUNCTION: fn_00003
|
|
int folded() { /* { */ return 2; }
|
|
|
|
// FUNCTION: fn_00004
|
|
int b() {
|
|
return 4;
|
|
}
|
|
`;
|
|
|
|
test('function regions run from the annotations to the closing brace', () => {
|
|
const r = functionRegions(file);
|
|
assert.deepEqual([r.get('fn_00001').start, r.get('fn_00001').end], [2, 7]);
|
|
assert.equal(r.get('fn_00002'), r.get('fn_00003'));
|
|
assert.deepEqual([r.get('fn_00004').start, r.get('fn_00004').end], [12, 16]);
|
|
});
|
|
|
|
test('withoutFunctions restores pending functions from the base, or drops new ones', () => {
|
|
const base = file.replace('return 4;', 'return 0; // old');
|
|
const out = withoutFunctions({ 'a.cpp': file }, ['fn_00004'], () => base);
|
|
assert.equal(out['a.cpp'], base);
|
|
const dropped = withoutFunctions({ 'a.cpp': file }, ['fn_00004'], () => null);
|
|
assert.doesNotMatch(dropped['a.cpp'], /int b\(\)/);
|
|
assert.match(dropped['a.cpp'], /int folded\(\)/);
|
|
// One definition shared by a pending and a finished function can't be split.
|
|
assert.equal(withoutFunctions({ 'a.cpp': file }, ['fn_00002'], () => null), null);
|
|
});
|