Skip to content

Add ProfileMigration version-migration coverage tests#45

Open
anagnorisis2peripeteia wants to merge 1 commit into
hbashton:mainfrom
anagnorisis2peripeteia:tests/profilemigration-coverage
Open

Add ProfileMigration version-migration coverage tests#45
anagnorisis2peripeteia wants to merge 1 commit into
hbashton:mainfrom
anagnorisis2peripeteia:tests/profilemigration-coverage

Conversation

@anagnorisis2peripeteia

@anagnorisis2peripeteia anagnorisis2peripeteia commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

A follow-up to #37. ProfileMigration upgrades old controller-profile XML to the current format (config_version 5) through a chain of steps, but only two tests cover it — and one of those (CheckJaysProfileRead) is excluded from CI for snapshot fragility — so the per-step migration logic is largely unasserted.

This adds six tests that assert migration behaviour with targeted attribute/element checks (deliberately not full-document string diffs, which is what got the existing test excluded):

  • RequiresMigration for old (config_version=1), absent, and current (=5) profiles.
  • After Migrate(), config_version reaches the current version and UsedMigration is set — and stays false for an already-current profile.
  • Version0002: a non-positive LSDeadZone is normalized to the default deadzone; a positive value passes through.
  • Version0004: legacy GyroSmoothing* nodes become the GyroMouseSmoothingSettings / GyroMouseStickSmoothingSettings groups (with the conditional SmoothingMethod).
  • Version0005: UseTPforControls remaps to TouchpadOutputMode.
  • DetermineProfileVersion: a version-absent profile containing LSAntiDeadZone is detected as v2 (its LSDeadZone is preserved, not v1-normalized).

Test-only; no behaviour change.


Local review history: https://gist.github.com/fc75801ef643a30731c2b87394c3a935

Proof manifest

Before / After (same command, same machine)

dotnet test DS4WindowsTests\DS4WindowsTests.csproj -c Release -p:Platform=x64 --filter "Name!=CheckSettingsSave&Name!=CheckWriteProfile&Name!=CheckJaysProfileRead&Name!=CheckSettingsRead"
Run Result
Base + injected fault (Version0005 writes Mouse instead of Controls) ✅ suite passes — fault missed (the coverage gap)
This branch + the same fault Migrate_TransformsVersion0005_UseTPforControls fails — fault caught
This branch, clean ✅ suite passes

Fault-injection proof (test-only PR): made Version0005 write TouchpadOutMode.Mouse instead of Controls, identically on base and this branch. Base + fault: suite passes (fault missed). This branch + fault: Migrate_TransformsVersion0005_UseTPforControls fails (fault caught). Clean branch: suite passes. Mutation delta on ProfileMigration.cs: 28.0% -> 59.2%, posted above.

Manifest + raw run outputs: https://gist.github.com/anagnorisis2peripeteia/f78f8b91812cb8d3b6009be38c42b2df

Assert the migration-step behaviour that mutation testing (issue hbashton#37) showed was
largely unasserted: RequiresMigration for old/absent/current config_version, the
migrated config_version reaching 5 with UsedMigration set, the Version0002 deadzone
normalization, the Version0004 gyro-smoothing regrouping, the Version0005
UseTPforControls -> TouchpadOutputMode remap, and DetermineProfileVersion's
LSAntiDeadZone-based v1-vs-v2 detection. Targeted attribute/element assertions
rather than full-document string diffs.
@anagnorisis2peripeteia

Copy link
Copy Markdown
Contributor Author

Before/after behavioral evidence — mutation testing (Stryker.NET) of ProfileMigration.cs:

Killed Survived No coverage Score
Before (existing tests only) 37 95 57 28.0%
After (with these six tests) 100 69 8 59.2%

The new tests kill 63 previously-surviving mutants and drop no-coverage mutants from 57 to 8 — the per-step migration logic (Version0002/0004/0005, DetermineProfileVersion) that previously had no behavioural assertions. Measured on **/ProfileMigration.cs, both runs on the same base.

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