Skip to content

Only label SOS tests .interpreter when they actually use the interpreter#5857

Merged
max-charlamb merged 1 commit into
dotnet:mainfrom
max-charlamb:fix-interpreter-test-labeling
May 27, 2026
Merged

Only label SOS tests .interpreter when they actually use the interpreter#5857
max-charlamb merged 1 commit into
dotnet:mainfrom
max-charlamb:fix-interpreter-test-labeling

Conversation

@max-charlamb

@max-charlamb max-charlamb commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

Reworks interpreter-test gating so the .interpreter display suffix and the DOTNET_Interpreter debuggee env var apply only to the two SOSInterpreterTests test methods. Previously, setting SOS_TEST_INTERPRETER=true decorated every SOS test name with .interpreter and set DOTNET_Interpreter on every debuggee, even though only SOSInterpreterTests actually exercises the interpreter.

Background

When SOS_TEST_INTERPRETER=true was set globally, two side effects had overly-broad scope:

  1. Test name decoration. TestConfiguration.GetStringViewWithVersion unconditionally appended .interpreter to every config''s display name. Because TestConfiguration is shared across all SOS theory tests, unrelated tests (e.g. SOSScenarioTests.WebApp3) showed up in xUnit results as WebApp3(*.interpreter.11.0.0-preview.5.xxxxx.yyy), misleading triage into thinking the failures were interpreter-related.
  2. Env-var plumbing. SOSRunner set DOTNET_Interpreter=InterpTestMethod* on every debuggee it launched. For non-interpreter debuggees this is functionally a no-op (no method matches the glob), but it''s still incorrect.

The recent runtime-diagnostics WebApp3 R2R-skew failures (a MissingMethodException for AsyncHelpers.CaptureContexts triggered by an unrelated runtime change) were initially mis-attributed to interpreter mode because the test was labeled .interpreter -- that triage friction motivated this cleanup.

Change

Interpreter mode is now a per-TestConfiguration variant -- analogous to PublishSingleFile / TestCDAC -- rather than a global flag observed by every test:

  • TestConfiguration.UseInterpreter is a new per-config bool. It drives both the .interpreter suffix in GetStringViewWithVersion and the DOTNET_Interpreter=InterpTestMethod* env-var emission in SOSRunner.CreateDump / StartDebugger.
  • SOSTestHelpers.InterpreterConfigurations is a new MemberData source. With SOS_TEST_INTERPRETER unset it returns the placeholder TestConfiguration.Empty row (so the theory enumerates one row and skips via SkippableTheory). With the env var set, it clones each default non-single-file, non-x86 configuration with UseInterpreter=true.
  • SOSInterpreterTests.InterpreterStackTest and InterpreterStackInterleavedTest bind to InterpreterConfigurations and check !config.UseInterpreter for the skip message. The x86 / single-file / global-gate checks now live once in InterpreterConfigurations instead of being duplicated per test.
  • TestConfiguration.TestInterpreter (and its initial-dict entry) is removed; nothing other than the new opt-in path needed it.

The interpreter variant is produced in code (cloning AllSettings and adding UseInterpreter=true); no test config XML changes are required.

Net behavior

Test SOS_TEST_INTERPRETER=true Before After
SOSScenarioTests.WebApp3 yes *.interpreter.<ver> + DOTNET_Interpreter set *.<ver>, no env var
SOSInterpreterTests.InterpreterStackTest yes *.interpreter.<ver> *.interpreter.<ver> (only this class)
SOSInterpreterTests.InterpreterStackTest unset skipped skipped

No change for SOS_TEST_INTERPRETER unset.

Note

This PR description and the code changes were authored with assistance from GitHub Copilot.

Validation

runtime-diagnostics pipeline run against this PR: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1435731

Replaces the previous per-test `UseInterpreter` flag on `SOSRunner.TestInformation` with a configuration-level model that follows the same pattern as `PublishSingleFile` / `TestCDAC`.

Key pieces:

* `TestConfiguration.UseInterpreter` is a per-config bool that drives both the `.interpreter` suffix in `GetStringViewWithVersion` and the `DOTNET_Interpreter=InterpTestMethod*` env-var emission in `SOSRunner`.

* `SOSTestHelpers.InterpreterConfigurations` is a new `MemberData` source that returns the placeholder `TestConfiguration.Empty` row when `SOS_TEST_INTERPRETER` is unset (so the theory enumerates one row and the test skips via `SkippableTheory`). When the env var is set, it clones each default non-single-file, non-x86 configuration with `UseInterpreter=true`.

* `SOSInterpreterTests` opt in by binding to `InterpreterConfigurations` and checking `!config.UseInterpreter` for the skip message; the x86 / single-file / per-test `TestInterpreter` gates are now expressed once in `InterpreterConfigurations`.

* `TestConfiguration.TestInterpreter` (and its initial-dict entry) is removed; nothing other than the new opt-in path needed it.

Net effect: only the two interpreter test methods receive `.interpreter`-suffixed configs and have `DOTNET_Interpreter` set on their debuggee. All other SOS tests are unaffected by `SOS_TEST_INTERPRETER`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@max-charlamb max-charlamb force-pushed the fix-interpreter-test-labeling branch from 81a23c5 to b8281b8 Compare May 26, 2026 16:01
@max-charlamb max-charlamb marked this pull request as ready for review May 27, 2026 16:53
@max-charlamb max-charlamb requested a review from a team as a code owner May 27, 2026 16:53
@max-charlamb max-charlamb requested review from Copilot and steveisok May 27, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR narrows “interpreter mode” in the SOS unit test infrastructure so that the .interpreter display-name suffix and DOTNET_Interpreter=InterpTestMethod* are applied only to the dedicated interpreter SOS tests, rather than to all SOS tests when SOS_TEST_INTERPRETER=true.

Changes:

  • Introduces a per-configuration UseInterpreter flag and uses it to control .interpreter name decoration and DOTNET_Interpreter emission.
  • Adds SOSTestHelpers.InterpreterConfigurations to gate/produce interpreter-only configuration variants and updates the two SOSInterpreterTests to consume it.
  • Removes the old global TestInterpreter configuration plumbing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/tests/SOS.UnitTests/SOSRunner.cs Switches interpreter env-var emission to depend on per-config UseInterpreter.
src/tests/SOS.UnitTests/SOS.cs Adds interpreter-only MemberData source and updates interpreter tests to use it.
src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs Replaces global TestInterpreter with per-config UseInterpreter and updates display-name suffixing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +581 to +585
/// Returns true if this configuration runs its debuggee on the CoreCLR interpreter.
/// Set only on the dedicated interpreter-variant configurations cloned by
/// SOSTestHelpers.InterpreterConfigurations; opt-in tests consume those via their
/// own MemberData source. When set, SOSRunner launches the debuggee with
/// DOTNET_Interpreter=InterpTestMethod*
@max-charlamb max-charlamb requested a review from hoyosjs May 27, 2026 19:59
@max-charlamb max-charlamb merged commit f28745a into dotnet:main May 27, 2026
19 checks passed
@max-charlamb max-charlamb deleted the fix-interpreter-test-labeling branch May 27, 2026 19:59
@hoyosjs hoyosjs mentioned this pull request Jun 9, 2026
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.

3 participants