Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 44 additions & 1 deletion TestPlatform.sln
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Exte
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests", "test\Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests\Microsoft.TestPlatform.Extensions.HtmlLogger.UnitTests.csproj", "{41248B96-6E15-4E5E-A78F-859897676814}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.collector", "test\coverlet.collector\coverlet.collector.csproj", "{074F5BD6-DC05-460B-B78F-044D125FD787}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "coverlet.collector", "test\TestAssets\coverlet.collector\coverlet.collector.csproj", "{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectFileRunSettingsTestProject", "test\TestAssets\ProjectFileRunSettingsTestProject\ProjectFileRunSettingsTestProject.csproj", "{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoverletCoverageTestProject", "test\TestAssets\CoverletCoverageTestProject\CoverletCoverageTestProject.csproj", "{700CE03D-926C-4166-900E-143A353F3E58}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -769,6 +773,42 @@ Global
{41248B96-6E15-4E5E-A78F-859897676814}.Release|x64.Build.0 = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|x86.ActiveCfg = Release|Any CPU
{41248B96-6E15-4E5E-A78F-859897676814}.Release|x86.Build.0 = Release|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Debug|x64.ActiveCfg = Debug|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Debug|x64.Build.0 = Debug|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Debug|x86.ActiveCfg = Debug|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Debug|x86.Build.0 = Debug|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Release|Any CPU.Build.0 = Release|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Release|x64.ActiveCfg = Release|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Release|x64.Build.0 = Release|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Release|x86.ActiveCfg = Release|Any CPU
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3}.Release|x86.Build.0 = Release|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Debug|x64.ActiveCfg = Debug|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Debug|x64.Build.0 = Debug|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Debug|x86.ActiveCfg = Debug|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Debug|x86.Build.0 = Debug|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Release|Any CPU.Build.0 = Release|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Release|x64.ActiveCfg = Release|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Release|x64.Build.0 = Release|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Release|x86.ActiveCfg = Release|Any CPU
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5}.Release|x86.Build.0 = Release|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Debug|x64.ActiveCfg = Debug|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Debug|x64.Build.0 = Debug|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Debug|x86.ActiveCfg = Debug|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Debug|x86.Build.0 = Debug|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Release|Any CPU.Build.0 = Release|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Release|x64.ActiveCfg = Release|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Release|x64.Build.0 = Release|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Release|x86.ActiveCfg = Release|Any CPU
{700CE03D-926C-4166-900E-143A353F3E58}.Release|x86.Build.0 = Release|Any CPU
{074F5BD6-DC05-460B-B78F-044D125FD787}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{074F5BD6-DC05-460B-B78F-044D125FD787}.Debug|Any CPU.Build.0 = Debug|Any CPU
{074F5BD6-DC05-460B-B78F-044D125FD787}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -847,6 +887,9 @@ Global
{E7D4921C-F12D-4E1C-85AC-8B7F91C59B0E} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
{236A71E3-01DA-4679-9DFF-16A8E079ACFF} = {5E7F18A8-F843-4C8A-AB02-4C7D9205C6CF}
{41248B96-6E15-4E5E-A78F-859897676814} = {020E15EA-731F-4667-95AF-226671E0C3AE}
{F1D8630D-97D5-4CD7-BC18-A5E1779FA6E3} = {8DA7CBD9-F17E-41B6-90C4-CFF55848A25A}
{8E87F6E4-E884-4404-B2E5-CBFB28038AE5} = {8DA7CBD9-F17E-41B6-90C4-CFF55848A25A}
{700CE03D-926C-4166-900E-143A353F3E58} = {8DA7CBD9-F17E-41B6-90C4-CFF55848A25A}
{074F5BD6-DC05-460B-B78F-044D125FD787} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
4 changes: 4 additions & 0 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ function Publish-PatchedDotnet {
Write-Log "Publish-PatchedDotnet: Copy VSTest task artifacts to local dotnet installation to allow `dotnet test` to run with it"
$buildArtifactsPath = "$env:TP_ROOT_DIR\src\Microsoft.TestPlatform.Build\bin\$TPB_Configuration\$TPB_TargetFrameworkNS2_0\*"
Copy-Item $buildArtifactsPath $dotnetTestArtifactsSdkPath -Force

Write-Log "Publish-PatchedDotnet: Copy vstest.console.dll artifact to local dotnet installation to allow `dotnet test` to run with it"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During my current work on the acceptance tests I found that this is falling short, because I am patching the task definition and the build but not the console and testhost. Would this be able to run via the InvokeVstest (or the other alike methods that run vsconsole but not dotnet test)? I tried taking the contents of the package that we ultimately insert into dotnet test (the CLI package), and it broke the runner, and I would rather avoid copying "random" dlls into the local copy of dotnet because then we can't really be sure about what we are testing against and if it reflects the real world.

Copy link
Contributor Author

@MarcoRossignoli MarcoRossignoli Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot use InvokeVsTest...because the base path of coverlet directory(nuget package) is injected through msbuild prop https://github.com/tonerdo/coverlet/blob/master/src/coverlet.collector/build/netstandard1.0/coverlet.collector.targets
I should pass /testadapterpath: with path #2278 (comment) but it depends on where we run tests and on which plat(this is a less important issue, coverlet pack at the moment has got only one tfm netstandard1.0)
Do you know a way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's figure that out later, imho finding the adapter should not be that hard, there will be some tests already doing it. But I would definitely love to get the dotnet test working with the currently built taks + console + testhost, because testing dotnet test more extensively would be nice. Maybe I was just doing something wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look if InvokeVstest is used by other tests.

$buildArtifactsPath = "$env:TP_ROOT_DIR\src\vstest.console\bin\$TPB_Configuration\$TPB_TargetFrameworkCore20\vstest.console.dll"
Copy-Item $buildArtifactsPath $dotnetTestArtifactsSdkPath -Force
}

function Publish-Package
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.TestPlatform.SmokeTests
{
using Microsoft.TestPlatform.TestUtilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using System.Linq;
using System.Reflection;

[TestClass]
public class DataCollectorTestsCoverlets : IntegrationTestBase
{
[TestMethod]
public void RunCoverletCoverage()
{
string projectFileName = this.GetProjectAssetFullPath("CoverletCoverageTestProject.csproj", "CoverletCoverageTestProject.csproj");
string logId = Guid.NewGuid().ToString("N");
this.InvokeDotnetTest($"--collect:\"XPlat Code Coverage\" {projectFileName} --diag:coverletcoverage.{logId}.log");
var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

// Verify vstest.console.dll CollectArgumentProcessor fix codeBase for coverlet package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this comment means, could you rephrase it to be more concrete, or explain to me what it means in a comment here?

Copy link
Contributor Author

@MarcoRossignoli MarcoRossignoli Feb 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this PR #2288 we removed custom code to allow coverlet lib to load in-proc collector.
That PR added some code inside CollectArgumentProcessor where we looking for "base path" of coverlet.collector.dll expected inside nuget package default folder, passed with VSTestTestAdapterPath https://github.com/tonerdo/coverlet/blob/master/src/coverlet.collector/build/netstandard1.0/coverlet.collector.targets#L21
When we find the lib we'll emit a log https://github.com/microsoft/vstest/pull/2288/files#diff-6f2506b5205b023825192043bd33a256R138
This assert check that we're sure that we've updated collector setting code base with full path, otherwise without "custom coverlet code" inside ProxyExecutionManager coverlet dll won't be resolved inside testhost.
https://github.com/microsoft/vstest/pull/2288/files#diff-3e65931fa6e723b1e2669b6ac7d6bcddL44
https://github.com/microsoft/vstest/pull/2288/files#diff-3e65931fa6e723b1e2669b6ac7d6bcddL272

var log = Directory.GetFiles(currentDir, $"coverletcoverage.{logId}.log").Single();
Assert.IsTrue(File.ReadAllText(log).Contains("CoverletDataCollector in-process codeBase path"));

// Verify out-of-proc coverlet collector load
var dataCollectorLog = Directory.GetFiles(currentDir, $"coverletcoverage.{logId}.datacollector*log").Single();
Assert.IsTrue(File.ReadAllText(dataCollectorLog).Contains("[coverlet]Initializing CoverletCoverageDataCollector"));

// Verify in-proc coverlet collector load
var hostLog = Directory.GetFiles(currentDir, $"coverletcoverage.{logId}.host*log").Single();
Assert.IsTrue(File.ReadAllText(hostLog).Contains("[coverlet]Initialize CoverletInProcDataCollector"));

// Verify default coverage file is generated
this.StdOutputContains("coverage.cobertura.xml");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,7 @@ private void ExecutePatchedDotnet(string command, string args, out string stdOut
var environmentVariables = new Dictionary<string, string> {
["DOTNET_MULTILEVEL_LOOKUP"] = "0"
};

var patchedDotnetPath = Path.Combine(this.testEnvironment.TestArtifactsDirectory, @"dotnet\dotnet.exe"); ;
var patchedDotnetPath = Path.Combine(this.testEnvironment.TestArtifactsDirectory, @"dotnet\dotnet.exe");
this.ExecuteApplication(patchedDotnetPath, string.Join(" ", command, args), out stdOut, out stdError, out exitCode, environmentVariables);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Imports Common TestAssets props. -->
<Import Project="..\..\..\scripts\build\TestAssets.props" />
<Import Project="..\..\..\scripts\build\TestPlatform.Dependencies.props" />
<!-- Package dependency versions -->

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the variables from the TestPlatform.Dependencies to keep the versions up to date. I am currently making changes to run the acceptance tests against the version that is built in the repo, not against the previous version. We will need to rebase this on top of the other change to allow this test to pass, othewise it would use a way old version of the dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll rebase when update will be in place...or do you want that I create a new prop NETTestSdkBuildVersion and for now fix the version and you'll update with var?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not necessary I would have to go and remove that variable afterwards. I am fighting with the acceptance tests to pass on the server, but hopefully it won't take more than a day more to get it to pass... 🤞 (or at least I hope because it is boring and exhausting 😁 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 🤞

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2340 is now in master

Copy link
Contributor Author

@MarcoRossignoli MarcoRossignoli Feb 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great rebasing!Any news on strange error #2330 (comment)?

<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions test/TestAssets/CoverletCoverageTestProject/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Xunit;

namespace CoverletCoverageTestProject
{
public class UnitTest1
{
[Fact]
public void Test1()
{

}
}
}