Skip to content

Affected tests: follow NuGet package references; narrow Directory.Packages.props changes - #49

Merged
csa7mdm merged 4 commits into
mainfrom
feat/nuget-edges
Sep 25, 2026
Merged

csa7mdm merged 4 commits into
mainfrom
feat/nuget-edges

Conversation

@csa7mdm

@csa7mdm csa7mdm commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Closes known gap 3 of the roadmap: dotnet_test_affected's project fallback now follows NuGet package references, not just ProjectReferences.

Behavior

  • Package edges (only add, never remove): a solution project's package id comes from a literal <PackageId>, the nearest Directory.Build.props, or its assembly name. When a test project's restored obj/project.assets.json references that id, it now counts as depending on that project. Test projects that were never restored are named in the note.

  • Narrowing for Directory.Packages.props: the tool runs only the test projects that use the packages whose version changed. Every condition must hold, otherwise it runs the whole solution and the note says why:

    • it is the only changed file;
    • only Version attributes changed (comments and whitespace aside);
    • every project has a readable assets file;
    • git can show the previous version.

    Packages used only by source projects, such as analyzers with PrivateAssets=all, are traced through the project graph. Helper projects with no tests are never selected.

  • Also fixed (a bug since 0.3.3): a changed .txt or image inside a project folder, such as TestData/expected.txt, used to be ignored and run nothing. It now runs that project's tests. .md files, docs outside every project, and a solution-root project owning docs/ don't count.

Review

Three Opus rounds.

  • Round 1: 1 blocker (the narrowing could replace other selections), 4 majors and 5 minors. All fixed.
  • Round 2: 1 major (an unreadable assets file read as "uses no packages") and 5 minors. Fixed by the lead session.
  • Round 3: approved; 3 minors fixed.

Tests

172 in the solution; Testing.Tests went from 32 to 62. Every review scenario was written as a test and shown failing on the pre-fix code first.

Benchmark gate

The gate FAILED by its own rule. This is why it's not a regression.

  • Method: both builds replayed Polly's last 40 source commits sequentially with maxSelectionSeconds: 120, then compared selected test names on commits that completed in both runs.
  • Completion (22 of 40, rule needs 30): 17 commits don't complete within 120 s on either build. The threshold was set without knowing Polly well; that's my mistake, not the branch's.
  • One difference, pre-existing: 8ba491d7 (RandomUtil.cs) gave 121 tests on main and 118 here. In fresh sessions, main gives 118 every time too. It's a bug in main: seeding from one TFM variant of a file with #if branches. It's fixed in its own PR (fix/tfm-variant-seeding), which should merge first.
  • The other 21 commits are identical: 7,487 selected tests compared.
  • Code touched: this branch doesn't modify FindAsync. Selection timing is unchanged (median 0.8 s vs 0.7 s).

🤖 Generated with Claude Code

csa7mdm and others added 4 commits September 24, 2026 17:29
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- An unreadable or unexpectedly shaped project.assets.json is 'unknown',
  not 'uses no packages', so it blocks Directory.Packages.props narrowing.
- git show output is decoded as UTF-8 (non-ASCII props no longer defeat
  narrowing); BOM trimmed.
- Note distinguishes 'used, but no runnable test project reaches it'.
- Reading Directory.Packages.props: UnauthorizedAccessException falls back.
- Documentation extensions are ignored only outside every project folder:
  test data inside a project (TestData/expected.txt) now selects its tests.
- Doc comments and README wording match the behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- .md files never count as changes; other documentation extensions count
  only inside a project that isn't at the solution root (a root-level
  project owns every file by folder).
- Tests: root README.md, a .md inside a project, and docs/*.png under a
  root-level project all run nothing.
- Doc comments and notes say 'not restored or unreadable'; BOM literal
  written as an escape; PackageChangeImpact.UsingProjects documented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@csa7mdm
csa7mdm merged commit 2507646 into main Sep 25, 2026
6 of 7 checks passed
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