Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2 remote testing and MSTest seems broken on Visual Studio? #4445

Open
markm77 opened this issue Dec 24, 2024 · 0 comments
Open

WSL2 remote testing and MSTest seems broken on Visual Studio? #4445

markm77 opened this issue Dec 24, 2024 · 0 comments

Comments

@markm77
Copy link

markm77 commented Dec 24, 2024

Hi there,

Something seems to have gone wrong with Visual Studio/MS Test tooling which means that remote tests on WSL2 that used to work now don't. I don't believe it's my code as I have tried tests that previously worked with earlier versions of Visual Studio a couple of months ago or less. I hoped rolling back Visual Studio (which I believe is linked to a .NET SDK version) would fix the issue but it doesn't (and it doesn't seem easy to roll back further than the previous version). So I'm reporting the issue here in the hope of getting guidance in isolating it further.

I've created a minimal repro (see below) to demo the issue so perhaps that can help in working out where to go from here.

I appreciate any help as this has completely broken my test system.

BR,
Mark

Steps To Reproduce

Create a simple test project in latest version of Visual Studio (17.12.3) as follows.

Project file:

<Project Sdk="MSTest.Sdk/3.7.0">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

testEnvironments.json file (configures remote testing):

{
  "version": "1",
  "environments": [
    {
      "name": "WSL-Ubuntu",
      "type": "wsl",
      "wslDistribution": "Ubuntu"
    }
  ]
}

Test method file:

namespace RemoteTestRepro;

public class TestData
{
    public required string MyValue { get; init; }

    public override string ToString() => MyValue;
}

[TestClass]
public sealed class Test1
{
    public static IEnumerable<object[]> GetNewTestCases()
    {
        return
        [
            [new TestData { MyValue = "1" }], [new TestData { MyValue = "2" }], [new TestData { MyValue = "3" }]
        ];
    }

    [DataTestMethod]
    [DynamicData(nameof(GetNewTestCases), DynamicDataSourceType.Method)]
    [DoNotParallelize]
    public Task TestMethod1(TestData data) => Task.CompletedTask;

}

Expected behaviour

There are three trivial tests and they should pass in both Windows and WSL2 (remote testing) environments.

Actual behaviour

Tests pass fine in Windows envrionment.

Tests will not run in WSL2 environment and errors like the following turn up in the output from Tests:

JsonRpc Error: 10 : 
Exception thrown from request "(not specified)" for method testing/testUpdates/tests: System.AggregateException: One or more errors occurred. (Path C:\Repos\RemoteTestRepro\RemoteTestRepro\bin\Debug\net8.0\RemoteTestRepro.dll must begin with the input root /mnt/c/Repos/RemoteTestRepro/.)
 ---> System.ArgumentException: Path C:\Repos\RemoteTestRepro\RemoteTestRepro\bin\Debug\net8.0\RemoteTestRepro.dll must begin with the input root /mnt/c/Repos/RemoteTestRepro/.
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestAgentBridge.PathTranslator.StripRoot(String root, String path, Boolean caseInsensitive) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestAgentBridge\PathTranslator.cs:line 44
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestAgentBridge.PathTranslator.TranslatePath(String inPath) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestAgentBridge\PathTranslator.cs:line 82
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.RemoteTestAgentBridge.TranslateRemoteToLocal(String source) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestAgentBridge\RemoteTestAgentBridge.cs:line 48
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestingPlatform.Parsers.BaseMessageParser.CreateTestResultRecord(Node node, TestCaseRecord testCase, String source, ITestRunDataSink dataSink) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestingPlatform\Parsers\BaseMessageParser.cs:line 181
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestingPlatform.TestingPlatformCallbackHandler.GenerateTestResults(IEnumerable`1 resultNodes) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestingPlatform\TestingPlatformCallbackHandler.cs:line 227
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestingPlatform.TestingPlatformCallbackHandler.GetTestRunEventArguments(IEnumerable`1 nodes) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestingPlatform\TestingPlatformCallbackHandler.cs:line 210
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestingPlatform.TestingPlatformCallbackHandler.TestsUpdateAsync(TestingPlatformOperationContext context, IEnumerable`1 nodes) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestingPlatform\TestingPlatformCallbackHandler.cs:line 190
   at Microsoft.VisualStudio.TestWindow.Internal.RemoteAgent.TestingPlatform.TestingPlatformCallbackHandler.TestsUpdateAsync(TestsUpdates testsUpdate) in D:\a\_work\1\s\src\TestWindow\Internal\RemoteAgent\TestingPlatform\TestingPlatformCallbackHandler.cs:line 170
   --- End of inner exception stack trace ---

If I try to debug the WSL2 tests in Visual Studio, the tests do not complete and the "Cancel" button becomes unresponsive.

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

No branches or pull requests

2 participants