Skip to content

Commit 5b93e6e

Browse files
committed
fix argument name (dotnet tool integration test)
1 parent b0170ef commit 5b93e6e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<AnalysisLevel>preview</AnalysisLevel>
1414
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
1515
<LangVersion>preview</LangVersion>
16-
<NoWarn>$(NoWarn);NU5105</NoWarn>
16+
<NoWarn>$(NoWarn);NU5105;CS1591</NoWarn>
1717
<RestoreSources>
1818
https://api.nuget.org/v3/index.json;
1919
</RestoreSources>

src/coverlet.console/Program.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ public static async Task<int> Main(string[] args)
5353
new Option<bool>("--use-source-link", "Specifies whether to use SourceLink URIs in place of file system paths.") { Arity = ArgumentArity.Zero },
5454
new Option<string[]>("--does-not-return-attribute", "Attributes that mark methods that do not return"){Arity = ArgumentArity.ZeroOrMore},
5555
new Option<string>("--exclude-assemblies-without-sources", "Specifies behaviour of heuristic to ignore assemblies with missing source documents."){ Arity = ArgumentArity.ZeroOrOne }
56-
}.WithHandler(nameof(HandleCommandAsync));
56+
}.WithHandler(nameof(HandleCommand));
5757

5858
root.Description = "Cross platform .NET Core code coverage tool";
5959
return await root.InvokeAsync(args);
6060
}
61-
private static async Task<int> HandleCommandAsync(string moduleOrAppDirectory,
61+
private static Task<int> HandleCommand(string path,
6262
string target,
6363
string targetargs,
6464
string output,
@@ -102,6 +102,10 @@ string excludeAssembliesWithoutSources
102102
// Adjust log level based on user input.
103103
logger.Level = verbosity;
104104
int exitCode = (int)CommandExitCodes.Success;
105+
106+
if (string.IsNullOrEmpty(path) || string.IsNullOrWhiteSpace(path))
107+
throw new ArgumentException("No test assembly or application directory specified.");
108+
105109
try
106110
{
107111
CoverageParameters parameters = new()
@@ -121,7 +125,7 @@ string excludeAssembliesWithoutSources
121125
};
122126
ISourceRootTranslator sourceRootTranslator = serviceProvider.GetRequiredService<ISourceRootTranslator>();
123127

124-
Coverage coverage = new(moduleOrAppDirectory,
128+
Coverage coverage = new(path,
125129
parameters,
126130
logger,
127131
serviceProvider.GetRequiredService<IInstrumentationHelper>(),
@@ -308,20 +312,20 @@ string excludeAssembliesWithoutSources
308312
throw new Exception(exceptionMessageBuilder.ToString());
309313
}
310314

311-
return exitCode;
315+
return Task.FromResult(exitCode);
312316

313317

314318
}
315319

316320
catch (Win32Exception we) when (we.Source == "System.Diagnostics.Process")
317321
{
318322
logger.LogError($"Start process '{target}' failed with '{we.Message}'");
319-
return exitCode > 0 ? exitCode : (int)CommandExitCodes.Exception;
323+
return Task.FromResult(exitCode > 0 ? exitCode : (int)CommandExitCodes.Exception);
320324
}
321325
catch (Exception ex)
322326
{
323327
logger.LogError(ex.Message);
324-
return exitCode > 0 ? exitCode : (int)CommandExitCodes.Exception;
328+
return Task.FromResult(exitCode > 0 ? exitCode : (int)CommandExitCodes.Exception);
325329
}
326330

327331
}

0 commit comments

Comments
 (0)