Skip to content

Unit test failures when run from VS #8313

Closed

Description

@JanKrivanek

Issue Description

Some of the unit tests are failing when run from VS (e.g. UnusedEnvironmentVariablesDoNotAppearInBinaryLog).

Steps to Reproduce

Run UnusedEnvironmentVariablesDoNotAppearInBinaryLog unit test in VS

Expected Behavior

Test passes

Actual Behavior

Test fails

Analysis

This is caused by the fact that those tests are supposed to execute msbuild and fail to do so due to attempts to interpret the test runner as the dotnet host process:

/// <summary>
/// Resolve the platform specific path to the runtime executable that msbuild.exe needs to be run in (unix-mono, {unix, windows}-corerun).
/// </summary>
private static string ResolveRuntimeExecutableName()
{
// Run the child process with the same host as the currently-running process.
using (Process currentProcess = Process.GetCurrentProcess())
{
return currentProcess.MainModule.FileName;
}
}

Proposal

This is how sdk achieves similar thing: https://github.com/dotnet/sdk/blob/main/src/Resolvers/Microsoft.DotNet.NativeWrapper/EnvironmentProvider.cs#L65-L94

Although it's sdk specific, it should be sufficient, since the code is supposed to run only for core:

<DefineConstants>$(DefineConstants);FEATURE_RUN_EXE_IN_TESTS</DefineConstants>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugneeds-triageHave yet to determine what bucket this goes in.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions