Repository navigation
Disable the MTP testhost by default - #16337
Conversation
left a comment
There was a problem hiding this comment.
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
MtpTestRuntimeProvidersource-aware selection behindFeatureFlag.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. |
left a comment
There was a problem hiding this comment.
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_TESTHOSTwhen 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);
The MTP under vstest path is still experimental, but it was enabled for every MTP-marked source.
Use a single
VSTEST_DISABLE_MTP_TESTHOSTflag.FeatureFlagdefaults it totrue, the environment value takes precedence, and setting it to0opts 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.
🤖