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

In-process vstest.console #3728

Merged
merged 28 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions TestPlatform.sln
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "playground", "playground",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestPlatform.Playground", "playground\TestPlatform.Playground\TestPlatform.Playground.csproj", "{545A88D3-1AE2-4D39-9B7C-C691768AD17F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Perfy.TestAdapter", "playground\MSTest1\Perfy.TestAdapter.csproj", "{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AttachmentProcessorDataCollector", "test\TestAssets\AttachmentProcessorDataCollector\AttachmentProcessorDataCollector.csproj", "{B6AF6BCD-64C6-4F4E-ABCA-C8AA2AA66B7B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vstest.ProgrammerTests", "test\vstest.ProgrammerTests\vstest.ProgrammerTests.csproj", "{B1F84FD8-6150-4ECA-9AD7-C316E04E17D8}"
Expand All @@ -187,7 +189,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "testhost.arm64", "src\testh
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DumpMinitool.arm64", "src\DataCollectors\DumpMinitool.arm64\DumpMinitool.arm64.csproj", "{62E9D32B-B989-43CF-81A2-B38B3367FCA3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest1", "playground\MSTest1\MSTest1.csproj", "{4DA57968-F547-4019-8381-03A218B6C385}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -859,6 +860,18 @@ Global
{545A88D3-1AE2-4D39-9B7C-C691768AD17F}.Release|x64.Build.0 = Release|Any CPU
{545A88D3-1AE2-4D39-9B7C-C691768AD17F}.Release|x86.ActiveCfg = Release|Any CPU
{545A88D3-1AE2-4D39-9B7C-C691768AD17F}.Release|x86.Build.0 = Release|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Debug|x64.ActiveCfg = Debug|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Debug|x64.Build.0 = Debug|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Debug|x86.ActiveCfg = Debug|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Debug|x86.Build.0 = Debug|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Release|Any CPU.Build.0 = Release|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Release|x64.ActiveCfg = Release|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Release|x64.Build.0 = Release|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Release|x86.ActiveCfg = Release|Any CPU
{57A61A09-10AD-44BE-8DF4-A6FD108F7DF7}.Release|x86.Build.0 = Release|Any CPU
{B6AF6BCD-64C6-4F4E-ABCA-C8AA2AA66B7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6AF6BCD-64C6-4F4E-ABCA-C8AA2AA66B7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6AF6BCD-64C6-4F4E-ABCA-C8AA2AA66B7B}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -931,18 +944,6 @@ Global
{62E9D32B-B989-43CF-81A2-B38B3367FCA3}.Release|x64.Build.0 = Release|Any CPU
{62E9D32B-B989-43CF-81A2-B38B3367FCA3}.Release|x86.ActiveCfg = Release|Any CPU
{62E9D32B-B989-43CF-81A2-B38B3367FCA3}.Release|x86.Build.0 = Release|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
cvpoienaru marked this conversation as resolved.
Show resolved Hide resolved
{4DA57968-F547-4019-8381-03A218B6C385}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Debug|x64.ActiveCfg = Debug|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Debug|x64.Build.0 = Debug|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Debug|x86.ActiveCfg = Debug|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Debug|x86.Build.0 = Debug|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Release|Any CPU.Build.0 = Release|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Release|x64.ActiveCfg = Release|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Release|x64.Build.0 = Release|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Release|x86.ActiveCfg = Release|Any CPU
{4DA57968-F547-4019-8381-03A218B6C385}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1022,7 +1023,6 @@ Global
{29270853-90DC-4C39-9621-F47AE40A79B6} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
{186069FE-E1E8-4DE1-BEA4-0FF1484D22D1} = {ED0C35EB-7F31-4841-A24F-8EB708FFA959}
{62E9D32B-B989-43CF-81A2-B38B3367FCA3} = {B705537C-B82C-4A30-AFA5-6244D9A7DAEB}
{4DA57968-F547-4019-8381-03A218B6C385} = {6CE2F530-582B-4695-A209-41065E103426}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0541B30C-FF51-4E28-B172-83F5F3934BCD}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TestPlatformRoot Condition="$(TestPlatformRoot) == ''">..\..\</TestPlatformRoot>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />

<PropertyGroup>
<TargetFrameworks>$(TargetFrameworks);net472;net5.0</TargetFrameworks>
<TargetFrameworks>net6.0;net48;net472;net471;net5.0</TargetFrameworks>
<Prefer32Bit>false</Prefer32Bit>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);RS0016</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('net4')) AND '$(OS)' != 'Windows_NT' ">
<Reference Include="System" />
Expand All @@ -24,5 +22,8 @@
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
</ItemGroup>
<Import Project="$(TestPlatformRoot)scripts\build\TestPlatform.targets" />
</Project>
68 changes: 61 additions & 7 deletions playground/MSTest1/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,70 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.VisualStudio.TestTools.UnitTesting;
// This dll is a TestProject as well as a test adapter.We use it as a baseline for performance.
// It does no actual discovery or run.It just returns as many results as we ask it to by TEST_COUNT env variable.
// It has almost no overhead, so all the overhead we see is coming from TestPlatform.

namespace MSTest1;
using System.Data;
using System;
using System.Collections.Generic;
using System.Linq;

[TestClass]
public class UnitTest1
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

namespace PerfyPassing
{
[TestMethod]
public void TestMethod1()
[ExtensionUri(Id)]
[DefaultExecutorUri(Id)]
public class Perfy : ITestDiscoverer, ITestExecutor
{
// Thread.Sleep(1000);
static Perfy()
{
// No meaning to the number, it is just easy to find when it breaks. Better than returning 1000 or 0 which are both
// less suspicious. It could throw, but that is bad for interactive debugging.
Count = int.TryParse(Environment.GetEnvironmentVariable("TEST_COUNT") ?? "10000", out var count) ? count : 356;
}

public const string Id = "executor://perfy.testadapter";
public static readonly Uri Uri = new Uri(Id);

public static int Count { get; }

public void Cancel()
{
// noop
}

public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
var sources = tests.Select(t => t.Source).Distinct().ToList();
RunTests(sources, runContext, frameworkHandle);
}

public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
var location = typeof(Perfy).Assembly.Location;
for (var i = 0; i < Count; i++)
{
var tc = new TestCase($"Test{i}", Uri, location);
frameworkHandle.RecordResult(new TestResult(tc)
{
Outcome = TestOutcome.Passed
});
}
}

public void DiscoverTests(IEnumerable<string> _, IDiscoveryContext _2,
IMessageLogger _3, ITestCaseDiscoverySink discoverySink)
{
var location = typeof(Perfy).Assembly.Location;
for (var i = 0; i < Count; i++)
{
var tc = new TestCase($"Test{i}", Uri, location);
discoverySink.SendTestCase(tc);
}
}
}
}
1 change: 1 addition & 0 deletions playground/TestPlatform.Playground/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal class EnvironmentVariables
["VSTEST_RUNNER_DEBUG_ATTACHVS"] = "0",
["VSTEST_HOST_DEBUG_ATTACHVS"] = "0",
["VSTEST_DATACOLLECTOR_DEBUG_ATTACHVS"] = "0",
["TEST_COUNT"] = "100000"
};

}
Loading