Repository navigation
Description
Goal
Split three monolithic .cpp files so each resulting file is under 1,000 LOC. The current files are 4K–6.5K lines each, causing slow re-compiles, large unity-build blast radius (any edit re-builds the whole TU), painful navigation, and brittle merge conflicts on review.
| File | Lines | Size | Proposed split |
|---|---|---|---|
tests/fl/stl/string.cpp |
6,468 | 216 kB | 9 files |
tests/fl/math/fixed_point.cpp |
5,230 | 170 kB | 8 files |
examples/AutoResearch/AutoResearchRemote.cpp |
4,017 | 171 kB | 7 files |
All three files already have clear // SECTION: markers or natural per-type/per-RPC boundaries — the cuts are largely mechanical.
Sub-task 1 — tests/fl/stl/string.cpp (6,468 → 9 files of ~800 LOC)
The file is already self-described as a concatenation of four legacy test files plus four newer sections. Each one becomes its own .cpp. Each new file gets its own FL_TEST_FILE(FL_FILEPATH) block (same pattern every other tests/fl/stl/*.cpp already uses).
| New file | Source range (current line nums) | Approx LOC |
|---|---|---|
tests/fl/stl/string_basic_a.cpp |
1–2283 | ~870 |
tests/fl/stl/string_basic_b.cpp |
2284–3129 | ~840 |
tests/fl/stl/string_comprehensive.cpp |
3130–3896 | ~770 |
tests/fl/stl/string_memory_bugs.cpp |
3897–4271 | ~370 |
tests/fl/stl/string_optimization.cpp |
4272–4727 | ~460 |
tests/fl/stl/string_type_erased.cpp |
4728–4922 (basic_string COW/move/inline-to-heap) | ~195 |
tests/fl/stl/string_append_concat.cpp |
4923–5230 | ~310 |
tests/fl/stl/string_comparison_hash.cpp |
5231–5500 | ~270 |
tests/fl/stl/string_ctor_iterator.cpp |
5501–6468 | ~970 |
All // SECTION: headers in the current file map 1:1 to these targets. The 0–3129 range is the only one that needs an internal split — splitting it at line 2284 (FL_TEST_CASE("string reverse iterators")) lands two ~850-line files.
Sub-task 2 — tests/fl/math/fixed_point.cpp (5,230 → 8 files of ~700 LOC)
The file already documents its structure in the top-of-file comment block (lines 1–102). The natural per-type seams give the cleanest cut. The shared accuracy_bounds<T> template specializations and constexpr/bit-exact infrastructure (lines 104–1262) move into a new private header.
| New file | Content | Source range | Approx LOC |
|---|---|---|---|
tests/fl/math/fixed_point_bounds.h |
accuracy_bounds<T> specializations + helpers (no tests) |
104–810 | ~705 |
tests/fl/math/fixed_point_constexpr.cpp |
constexpr raw / from_raw / arithmetic / math / value verification | 811–1130 | ~320 |
tests/fl/math/fixed_point_bit_exact.cpp |
Bit-exact + Transcendental tests + accuracy reports | 1131–1970 | ~840 |
tests/fl/math/fixed_point_signed_types.cpp |
signed fixed_point<> bit-exact + accuracy bounds (s4x12, s8x8, s12x4, s8x24, s16x16, s24x8) |
1971–2186 + GitHub-#2174 regression at 2084 | ~210 |
tests/fl/math/fixed_point_u4x12_u8x8.cpp |
u4x12 + u8x8 type-specific tests | 2187–3055 | ~870 |
tests/fl/math/fixed_point_u12x4_u16x16.cpp |
u12x4 + u16x16 type-specific tests | 3056–3968 | ~915 |
tests/fl/math/fixed_point_u8x24_u24x8.cpp |
u8x24 + u24x8 type-specific tests | 3969–4817 | ~850 |
tests/fl/math/fixed_point_misc.cpp |
scalar alignment, constexpr scalar ops, integer ctor, pow boundary (#2969) | 4818–5230 | ~410 |
The namespace { ... } anonymous block currently spanning the entire file would be rewritten as namespace fl::test::fp_detail { ... } (or similar) in the shared header, so per-file translation units don't drag in the full bounds table when they only need one type.
Note: the u4x12_u8x8 and u12x4_u16x16 merges land at ~870 and ~915 LOC respectively. If either creeps past 1000 during the actual extraction (extra blank lines, header re-includes), split them per-type — the cut point is obvious in each case.
Sub-task 3 — examples/AutoResearch/AutoResearchRemote.cpp (4,017 → 7 files of ~600 LOC)
This is the dominant compile-time hog. registerFunctions() alone is lines 1302–3919 = 2,617 lines — a single C++ method. Splitting it by RPC family is the win.
Hook policy note: ci/hooks/protect_example_ino.py blocks new .ino files but allows new .cpp companions to an existing .ino. AutoResearch's example sketch is AutoResearch.ino; sibling .cpp files like AutoResearchRemote.cpp already exist, so this split adds more siblings — no override needed.
| New file | Content | Source range | Approx LOC |
|---|---|---|---|
examples/AutoResearch/AutoResearchRemoteCore.cpp |
helpers (printJsonRaw, printStreamRaw, ScopedFastLedBrightness), ctor/dtor, tick(), registerAllMethods() glue, top-level registerFunctions() shell that calls bind*Methods() |
1–310 + 3920–4017 + new dispatch shell | ~480 |
examples/AutoResearch/AutoResearchRemoteRegistry.cpp |
runSingleTestImpl() + simple RPCs (status, debugTest, deliberateHang, drivers, runSingleTest) |
311–1376 | ~870 → split if needed |
examples/AutoResearch/AutoResearchRemoteParallel.cpp |
runParallelTest, flexioObjectFledTest, RX-only bypass paths |
1377–1963 | ~590 |
examples/AutoResearch/AutoResearchRemoteGpio.cpp |
testGpioConnection, setTxPin, pin/driver state RPCs |
1964–2487 | ~525 |
examples/AutoResearch/AutoResearchRemoteSimd.cpp |
testSimd, testSimdBenchmark, parlioStreamValidate |
2488–2844 | ~360 |
examples/AutoResearch/AutoResearchRemoteAsync.cpp |
testAsync, runNetClientTest, runNetLoopback |
2845–3162 | ~320 |
examples/AutoResearch/AutoResearchRemoteCoroutines.cpp |
Coroutine tests (basic, stop-while-running, multi-concurrent, promise then/catch, pipeline) | 3163–3919 | ~760 |
Split mechanism. registerFunctions() stays a thin shell in Core.cpp and calls free helpers defined in each family file:
// In Core.cpp
void AutoResearchRemoteControl::registerFunctions(fl::shared_ptr<AutoResearchState> state) {
mState = state;
bindRegistryMethods(mRemote, mState, this);
bindParallelMethods(mRemote, mState, this);
bindGpioMethods(mRemote, mState);
bindSimdMethods(mRemote, mState);
bindAsyncMethods(mRemote, mState);
bindCoroutineMethods(mRemote, mState);
}Each family file exposes void bind<Family>Methods(fl::Remote*, fl::shared_ptr<AutoResearchState>, ...) from an internal header AutoResearchRemoteFamilies.h. This is the minimal-diff path. Alternative: each family file becomes a .cpp.hpp included once from Core.cpp — discuss in the implementation PR.
Why this matters (cross-cutting)
- Edit-recompile blast radius. Changing one assertion in
string.cpptriggers a 216 kB TU recompile (cold ~8–15 s on Windows, warm ~1–3 s after compiler cache hit). Splitting cuts the edit-recompile loop by 4–8x for the file under active edit. - PCH thrash.
tests/test_pch.hpulls inFastLED.h(~1,170 transitive headers). Smaller TUs mean the per-TU post-PCH compile time drops linearly with the new file size. - Review/navigation. Diffs on a 6.5K-line file are unreviewable in the GitHub UI without clicking "Load more" repeatedly; 1K-line files render in a single page.
- Editor responsiveness. clangd/LSP on 6.5K-line files with deep template instantiation (fixed_point) takes 5–10 s per re-index after every save.
Execution order (recommended)
fixed_point.cppfirst — cleanest cut, per-type seams already exist, lowest risk of regression. Each sub-PR is mechanical extraction. One PR per new file so each is reviewable.string.cppsecond —// SECTION:markers already in the file; cuts are 1:1 with markers. Same one-PR-per-file rhythm.AutoResearchRemote.cpplast — most architectural (factoringregisterFunctionsbody), benefits from learnings on the test files first. Pre-PR: confirm split style with @zackees.
Acceptance criteria
- Every resulting
.cppfile is < 1,000 LOC. - Each new test file has its own
FL_TEST_FILE(FL_FILEPATH)(matches every othertests/fl/stl/*.cpp). -
bash test --cpppasses on all three sets — no test loss, no test rename without justification. -
bash compile uno --examples AutoResearchsucceeds. -
bash autoresearch --parliosmoke test still succeeds against an attached device (or the host CI dry-run). - Build-system source-list cache picks up the new files automatically (
ci/meson/test_discovery.pyscanstests/**/*.cpp). - Each file split lands in its own PR stacked on
master, not bundled.
Out of scope (deliberately deferred)
- Splitting
src/aggregators (separate issue family — touches thesrc/fl/build/*+.cppunity-build design). - Test deduplication / cross-section merges (preserve test content 1:1 in this round).
- Renaming any
FL_TEST_CASEstrings.
Open questions
fixed_point_bounds.h— shouldaccuracy_bounds<T>move to a public-ish detail header undersrc/fl/math/, or stay test-only undertests/fl/math/? Recommendation: test-only.- AutoResearchRemote split style — free-function-per-family vs
.cpp.hppinline-includes. Need maintainer call. - Should
string_basic_a.cpp+string_basic_b.cppget more descriptive names (e.g.,string_construction.cpp,string_search.cpp)? Mechanical names ship faster; semantic names need test-case-by-test-case classification.
cc: @zackees
Generated with Claude Code.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jun 16, 2026
Sub-issues filed for the three file splits, in the recommended execution order:
tests/fl/math/fixed_point.cpp(5,230 LOC → 8 files + 1 shared header). 8 PRs. Start here — cleanest cut.tests/fl/stl/string.cpp(6,468 LOC → 9 files). 9 PRs. Section markers map 1:1.examples/AutoResearch/AutoResearchRemote.cpp(4,017 LOC → 7 files). 7 PRs. Needs maintainer call on split mechanism (free-function helpers vs.cpp.hppaggregator) before PR 1.Total: 24 PRs across the three sub-issues. Working sequentially.
Related: #3129 tracks build-system rebuild workarounds (separate audit, separate fix list).
refactor(tests): extract fixed_point_misc.cpp from fixed_point.cpp (p…
refactor(tests): extract fixed_point_misc.cpp from fixed_point.cpp (p…
refactor(tests): extract fixed_point_constexpr.cpp from fixed_point.c…
refactor(tests): extract fixed_point_constexpr.cpp from fixed_point.c…
refactor(tests): extract fixed_point_bounds.h shared header (part of #…
refactor(tests): extract fixed_point_bounds.h shared header (part of #…
refactor(tests): extract fixed_point_u4x12_u8x8.cpp from fixed_point.…
refactor(tests): extract fixed_point_u4x12_u8x8.cpp from fixed_point.…
refactor(tests): extract fixed_point_u12x4_u16x16.cpp from fixed_poin…
17 remaining items
refactor(tests): extract string_ctor_iterator.cpp from string.cpp (pa…
refactor(tests): extract string_ctor_iterator.cpp from string.cpp (pa…
refactor(tests): extract string_basic_b.cpp from string.cpp (part of #…
refactor(tests): extract string_basic_b.cpp from string.cpp (part of #…
refactor(tests): split string.cpp basic_a section into 3 files + dele…
refactor(tests): split string.cpp basic_a section into 3 files + dele…
zackees commentedon Jun 16, 2026
Meta #3127 — Completion summary
Two of three sub-issues complete; #3132 deferred with documented architectural blocker.
Sub-issue #3130 —
tests/fl/math/fixed_point.cpp(5,230 LOC → all files under 1K) ✅ CLOSED7 PRs merged to master:
ci/hooks/check_test_file_pairing.pysibling-split allowance +fixed_point_misc.cpp(440 LOC)fixed_point_constexpr.cpp(343 LOC)fixed_point_bounds.h(230 LOC, shared header)fixed_point_u4x12_u8x8.cpp(896 LOC)fixed_point_u12x4_u16x16.cpp(935 LOC)fixed_point_u8x24_u24x8.cpp(872 LOC)fixed_point_test_helpers.h(1053 LOC header — closes Split tests/fl/math/fixed_point.cpp (5,230 LOC) into 8 files of <1K LOC each (sub-issue of #3127) #3130, leavesfixed_point.cppat 613 LOC)Sub-issue #3131 —
tests/fl/stl/string.cpp(6,468 LOC → 11 files under 1K, original deleted) ✅ CLOSED9 PRs merged to master:
string_memory_bugs.cpp(389 LOC)string_type_erased.cpp(208 LOC)string_append_concat.cpp(320 LOC)string_comparison_hash.cpp(285 LOC)string_optimization.cpp(474 LOC)string_comprehensive.cpp(786 LOC)string_ctor_iterator.cpp(979 LOC)string_basic_b.cpp(864 LOC)string_basic_ops.cpp(693) +string_search_a.cpp(666) +string_search_b.cpp(953) + originalstring.cppdeleted (closes Split tests/fl/stl/string.cpp (6,468 LOC) into 9 files of <1K LOC each (sub-issue of #3127) #3131)Sub-issue #3132 —
AutoResearchRemote.cppsplit ⏸ DEFERREDClosed as "not planned" — needs a fresh sub-issue once @zackees decides on the split mechanism. Rationale documented in the closing comment on #3132. The file has evolved beyond the original plan with multiple new RPC bindings; updating the plan + getting the architectural call is required before safely starting the work.
Bonus deliverable
Filed #3129 (build-system rebuild workarounds audit + zccache upstream blockers) as a separate meta during this run.
Totals
tests/fl/stl/string.cppconsolidated away; originaltests/fl/math/fixed_point.cppretained at 613 LOC since some bit-exact + transcendental + accuracy report tests remain there per the helper-extraction design)ci/hooks/check_test_file_pairing.py— sibling-split allowance unblocks future test-file splits)Closing meta. Re-open if anything needs follow-up beyond what's already in #3129 or a future #3132-successor.
refactor(examples): split AutoResearchRemote.cpp into 10 files all un…
zackees commentedon Jun 16, 2026
All three sub-issues complete:
Total: 17 PRs merged, 30+ new files, every resulting
.cppunder 1,000 LOC.Closing meta.