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

Enable code coverage when "Code Coverage;arg1=val1;arg2=val2" is provided in cli #3172

Merged
merged 14 commits into from
Nov 16, 2021

Conversation

fhnaseer
Copy link
Member

This will enable code coverage for the given command and will also append testAdapterPath to child dotnet process.

dotnet test --collect:"Code Coverage;arg1=val1"

will call

"dotnet" exec vstest.console.dll D:\TestProject\bin\Debug\net6.0\TestProject.dll --collect:"Code Coverage;arg1=val1" --testAdapterPath:D:\NuGetFeed\microsoft.codecoverage\16.9.4\build\netstandard1.0\

fhnaseer and others added 12 commits November 10, 2021 17:32
e.g.
Input:
--collect:"Code Coverage;CLRIEInstrumentationNetCore=true;CLRIEInstrumentationNetFramework=false"

Output:
      <DataCollector friendlyName="Code Coverage" enabled="True">
        <Configuration>
          <CLRIEInstrumentationNetCore>true</CLRIEInstrumentationNetCore>
          <CLRIEInstrumentationNetFramework>false</CLRIEInstrumentationNetFramework>
        </Configuration>
      </DataCollector>
…code-coverage build 20211111.1

Microsoft.Internal.CodeCoverage
 From Version 17.1.0-beta.21560.1 -> To Version 17.1.0-beta.21561.1
…d-8f377d0f6c72' into dev/fhnaseer/cc-commandline-config
…llowing command,

dotnet test --collect:"Code Coverage;arg1=val1;arg2=val2"
@@ -368,7 +368,12 @@ private List<string> AddArgs()
{
foreach (var arg in this.VSTestCollect)
{
if (arg.Equals("Code Coverage", StringComparison.OrdinalIgnoreCase))
// Argument value could be CodeCoverage;a=b;c=d.
Copy link
Contributor

@MarcoRossignoli MarcoRossignoli Nov 16, 2021

Choose a reason for hiding this comment

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

Suggested change
// Argument value could be CodeCoverage;a=b;c=d.
// Argument value could be 'Code Coverage;a=b;c=d'.

// Split arg with ; and compare with the first token.
var tokens = arg.Split(';');

if (arg.Equals("Code Coverage", StringComparison.OrdinalIgnoreCase) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better to have const string with value = "Code Coverage" for correctness. If someone changes the value in future we will not get misspelling.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

Copy link
Contributor

@MarcoRossignoli MarcoRossignoli left a comment

Choose a reason for hiding this comment

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

LGTM

@ghost
Copy link

ghost commented Nov 16, 2021

Hello @fhnaseer!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@@ -20,6 +20,7 @@ public class VSTestTask : Task, ICancelableTask
private VSTestForwardingApp vsTestForwardingApp;

private const string vsTestAppName = "vstest.console.dll";
private const string CodeCovergaeString = "Code Coverage";
Copy link
Contributor

Choose a reason for hiding this comment

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

nit : misspelling

Suggested change
private const string CodeCovergaeString = "Code Coverage";
private const string CodeCoverageString= "Code Coverage";

@jakubch1 jakubch1 enabled auto-merge (squash) November 16, 2021 17:20
@jakubch1 jakubch1 merged commit 011aeee into main Nov 16, 2021
@jakubch1 jakubch1 deleted the dev/fhnaseer/cc-commandline-config branch November 16, 2021 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants