Skip to content

Add round-trip test harness for project split and unify - #433

Open
hahn-kev wants to merge 3 commits into
fix-duplicate-custom-fieldsfrom
split-unify-round-trip-tests
Open

hahn-kev wants to merge 3 commits into
fix-duplicate-custom-fieldsfrom
split-unify-round-trip-tests

Conversation

@hahn-kev

@hahn-kev hahn-kev commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

I'm not sure I love the approach taken in CustomPropertyCacheTests to build the fwdata file, I started working on some simple e2e split/unify tests and those are using the same approach. Do we keep doing this? or do we build up the fwdata file some other way for these tests? Maybe via LCM?

copied from my note on #432


AI summary

Summary

Split and unify had only argument-check tests. This adds a small harness so a round-trip test for a new edge case is a few lines. Stacked on #432.

src/LibFLExBridge-ChorusPluginTests/Infrastructure/
├── CustomPropertyCacheTests.cs   # now builds its project with FwdataBuilder
└── RoundTrip/
    ├── FwdataBuilder.cs          # stub LangProject + AddCustomField / AddUnownedObject / AddOwnedObject
    ├── SplitUnifyHarness.cs      # temp folder, fresh MetadataCache, Split / EditSplitObject / Unify
    ├── FwdataAssert.cs           # compares objects by guid, not bytes
    └── SplitUnifyRoundTripTests.cs

Adding an edge-case test:

var fwdata = new FwdataBuilder()
    .AddCustomField("LexEntry", "Rank", "Integer")
    .AddUnownedObject("LexEntry", EntryGuid, CustomInteger("Rank", 3));
using (var project = new SplitUnifyHarness(fwdata))
{
    project.Split();
    project.EditSplitObject(EntryGuid, entry => entry.Element("Custom").Attribute("val").Value = "7");
    var entry = SplitUnifyHarness.ObjectsByGuid(project.Unify())[EntryGuid];
    // assert on entry
}

Found while building the stub, by removing each LangProject-owned object one at a time. These look like latent bugs, not real requirements:

  • GenreList, TextMarkupTags, TranslationTags missing: the split succeeds (WriteNestedListFileIfItExists), but TextCorpusBoundedContextService.FlattenContext always loads all three list files, so the unify throws FileNotFoundException.
  • ResearchNotebook missing: the split writes DataNotebook.ntbk with an empty header, and the unify throws ArgumentNullException in CmObjectFlatteningService.

LexDb, MorphologicalData, MsFeatureSystem, PhFeatureSystem, PhonologicalData and the AnalyzingAgents element make the split throw (NRE or Sequence contains no elements). Every real project has them, so those are real requirements, though the errors could be clearer.

Evidence

RoundTrip_MinimalProject_KeepsObjectsAndCustomFields   same guids, classes, owners, custom fields
RoundTrip_MinimalProject_KeepsObjectContents           same properties per object, order-insensitive
RoundTrip_LexEntryCustomFieldValue_Survives            <Custom name='Rank' val='3'/> comes back
RoundTrip_NestedOwnedObjects_KeepTheirOwners           sense and subsense keep ownerguid + owner objsur
Unify_EditedSplitObject_ReachesFwdata                  edit in the split .lexdb shows up in the .fwdata

Merge Danger

Door: two-way

Test code only.

Blast Radius: none

No production code changes.

Test plan

  • dotnet test src/LibFLExBridge-ChorusPluginTests/LibFLExBridge-ChorusPluginTests.csproj -c Release "-p:SolutionDir=<repo root>\": 528 passed

🤖 Generated with Claude Code


This change is Reviewable

hahn-kev and others added 3 commits November 20, 2026 13:44
Split and unify had only argument-check tests; round trips were checked
by hand with an external app. FwdataBuilder and SplitUnifyHarness make a
test for a new edge case a few lines: build a small .fwdata, split,
optionally edit the split files, unify, and compare objects by guid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stub LangProject that split and unify need now lives in one place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Callers no longer have to match the lowercase string format of guids in
fwdata files; the harness parses and formats them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hahn-kev
hahn-kev added this pull request to stack #434 November 20, 2026 07:02
@github-actions

Copy link
Copy Markdown

Test Results

568 tests  +5   568 ✅ +5   3m 28s ⏱️ -9s
  6 suites ±0     0 💤 ±0 
  6 files   ±0     0 ❌ ±0 

Results for commit ef43650. ± Comparison against base commit 71ce1bb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant