Skip to content

Disable the MTP testhost by default - #16337

Merged
Jakub Jareš (nohwnd) merged 3 commits into
microsoft:mainfrom
nohwnd:nohwnd-gate-mtp-under-vstest
Aug 4, 2026
Merged

Jakub Jareš (nohwnd) merged 3 commits into
microsoft:mainfrom
nohwnd:nohwnd-gate-mtp-under-vstest

Conversation

@nohwnd

@nohwnd Jakub Jareš (nohwnd) commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

The MTP under vstest path is still experimental, but it was enabled for every MTP-marked source.

Use a single VSTEST_DISABLE_MTP_TESTHOST flag. FeatureFlag defaults it to true, the environment value takes precedence, and setting it to 0 opts in. This avoids conflicting enable and disable flags.

Verified the Release pack build, FeatureFlag tests on net11.0 and net481, and all 16 MTP acceptance cases.

🤖

Copilot Bot review requested due to automatic review settings August 3, 2026 12:10

ghost 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 makes the “MTP under vstest” execution path explicitly opt-in (via VSTEST_OPTIN_MTP), so Microsoft.Testing.Platform-marked sources no longer select the MTP runtime provider by default. This aligns the implementation with the stated “experimental” status by gating provider selection and ensuring test coverage and documentation reflect the opt-in contract.

Changes:

  • Gate MtpTestRuntimeProvider source-aware selection behind FeatureFlag.VSTEST_OPTIN_MTP.
  • Update MTP acceptance tests to explicitly opt in for their runs.
  • Document the new opt-in environment variable and add unit tests for the provider gating behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/MtpTestRuntimeProviderTests.cs Adds unit tests validating opt-in gating and short-circuiting of MTP detection when disabled.
test/Microsoft.TestPlatform.Acceptance.IntegrationTests/MtpUnderVstestTests.cs Ensures MTP acceptance scenarios set VSTEST_OPTIN_MTP for all vstest invocations.
src/Microsoft.TestPlatform.TestHostProvider/Hosting/MtpTestRuntimeProvider.cs Implements the opt-in gate in provider selection and improves testability via injected detector/feature flag.
src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs Introduces VSTEST_OPTIN_MTP constant and clarifies feature-flag usage guidance for experimental opt-ins.
docs/Overview.md Updates overview text to reflect opt-in requirement for the experimental MTP path.
docs/environment-variables.md Documents VSTEST_OPTIN_MTP semantics and default behavior.

Copilot Bot review requested due to automatic review settings August 3, 2026 13:06

ghost 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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs:82

  • This introduces an opt-in enable flag, but the header comment in this file strongly recommends never using flags to enable functionality. Without an explicit rationale here, future maintainers may treat this as accidental/inconsistent and rename/remove it incorrectly. Consider clarifying that this is a deliberate exception to keep the MTP path off-by-default while experimental.
    // Opt-in to running Microsoft.Testing.Platform applications under vstest while the integration is experimental.
    public const string VSTEST_ENABLE_MTP_TESTHOST = nameof(VSTEST_ENABLE_MTP_TESTHOST);

src/Microsoft.TestPlatform.TestHostProvider/Hosting/MtpTestRuntimeProvider.cs:83

  • With the feature flag off, this provider declines MTP sources and the run falls back to generic host resolution, which appears to surface a generic "Could not find testhost for test source" error for MTP apps. That message is misleading in this scenario; consider emitting an actionable error that explicitly mentions VSTEST_ENABLE_MTP_TESTHOST when MTP sources are detected but the feature is disabled.
    bool ISourceAwareTestRuntimeProvider.CanExecuteCurrentRunConfiguration(string? runsettingsXml, IEnumerable<string> sources)
        => FeatureFlag.Instance.IsSet(FeatureFlag.VSTEST_ENABLE_MTP_TESTHOST) && AllSourcesAreMicrosoftTestingPlatform(sources);

Copilot Bot review requested due to automatic review settings August 3, 2026 14:02
@nohwnd Jakub Jareš (nohwnd) changed the title Gate MTP under vstest behind an opt-in flag Disable the MTP testhost by default Aug 3, 2026

ghost 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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@nohwnd
Jakub Jareš (nohwnd) enabled auto-merge (squash) August 3, 2026 15:45
This was referenced Oct 20, 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