Skip to content

Commit e595642

Browse files
committed
fix build
1 parent d4a01a7 commit e595642

File tree

2 files changed

+81
-79
lines changed

2 files changed

+81
-79
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<PackageVersion Include="NuGet.Packaging" Version="6.6.1" />
3636
<PackageVersion Include="ReportGenerator.Core" Version="5.1.23" />
3737
<PackageVersion Include="LinqKit.Microsoft.EntityFrameworkCore" Version="7.1.4" />
38+
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
3839
<PackageVersion Include="System.Collections.Immutable" Version="7.0.0" />
3940
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
4041
<!--

test/coverlet.integration.tests/DotnetTool.cs

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,95 @@
33

44
using System.IO;
55
using System.Linq;
6+
using Coverlet.Tests.Xunit.Extensions;
67
using Xunit;
78

89
namespace Coverlet.Integration.Tests
910
{
10-
public class DotnetGlobalTools : BaseTest
11+
public class DotnetGlobalTools : BaseTest
12+
{
13+
private string InstallTool(string projectPath)
1114
{
12-
private string InstallTool(string projectPath)
13-
{
14-
_ = DotnetCli($"tool install coverlet.console --version {GetPackageVersion("*console*.nupkg")} --tool-path \"{Path.Combine(projectPath, "coverletTool")}\"", out string standardOutput, out _, projectPath);
15-
Assert.Contains("was successfully installed.", standardOutput);
16-
return Path.Combine(projectPath, "coverletTool", "coverlet");
17-
}
15+
_ = DotnetCli($"tool install coverlet.console --version {GetPackageVersion("*console*.nupkg")} --tool-path \"{Path.Combine(projectPath, "coverletTool")}\"", out string standardOutput, out _, projectPath);
16+
Assert.Contains("was successfully installed.", standardOutput);
17+
return Path.Combine(projectPath, "coverletTool", "coverlet");
18+
}
1819

19-
[Fact]
20-
public void DotnetTool()
21-
{
22-
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
23-
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
24-
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
25-
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
26-
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
27-
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError);
28-
Assert.Contains("Passed!", standardOutput);
29-
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
30-
}
20+
[Fact]
21+
public void DotnetTool()
22+
{
23+
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
24+
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
25+
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
26+
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
27+
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
28+
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError);
29+
Assert.Contains("Passed!", standardOutput);
30+
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
31+
}
3132

32-
[Fact]
33-
public void StandAlone()
34-
{
35-
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
36-
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
37-
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
38-
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
39-
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
40-
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError);
41-
Assert.Contains("Hello World!", standardOutput);
42-
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
43-
}
33+
[Fact]
34+
public void StandAlone()
35+
{
36+
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
37+
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
38+
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
39+
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
40+
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
41+
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError);
42+
Assert.Contains("Hello World!", standardOutput);
43+
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
44+
}
4445

45-
[ConditionalFact]
46-
[SkipOnOS(OS.Linux)]
47-
[SkipOnOS(OS.MacOS)]
48-
public void StandAloneThreshold()
49-
{
50-
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
51-
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
52-
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
53-
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
54-
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
55-
Assert.False( RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
56-
Assert.Contains("Hello World!", standardOutput);
57-
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
58-
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
59-
Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
60-
}
46+
[ConditionalFact]
47+
[SkipOnOS(OS.Linux)]
48+
[SkipOnOS(OS.MacOS)]
49+
public void StandAloneThreshold()
50+
{
51+
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
52+
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
53+
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
54+
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
55+
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
56+
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
57+
Assert.Contains("Hello World!", standardOutput);
58+
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
59+
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
60+
Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
61+
}
6162

62-
[ConditionalFact]
63-
[SkipOnOS(OS.Linux)]
64-
[SkipOnOS(OS.MacOS)]
65-
public void StandAloneThresholdLine()
66-
{
67-
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
68-
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
69-
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
70-
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
71-
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
72-
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
73-
Assert.Contains("Hello World!", standardOutput);
74-
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
75-
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
76-
Assert.DoesNotContain("The minimum method coverage is below the specified 80", standardOutput);
77-
}
63+
[ConditionalFact]
64+
[SkipOnOS(OS.Linux)]
65+
[SkipOnOS(OS.MacOS)]
66+
public void StandAloneThresholdLine()
67+
{
68+
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
69+
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
70+
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
71+
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
72+
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
73+
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
74+
Assert.Contains("Hello World!", standardOutput);
75+
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
76+
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
77+
Assert.DoesNotContain("The minimum method coverage is below the specified 80", standardOutput);
78+
}
7879

79-
[ConditionalFact]
80-
[SkipOnOS(OS.Linux)]
81-
[SkipOnOS(OS.MacOS)]
82-
public void StandAloneThresholdLineAndMethod ()
83-
{
84-
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
85-
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
86-
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
87-
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
88-
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
89-
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
90-
Assert.Contains("Hello World!", standardOutput);
91-
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
92-
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
93-
Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
94-
}
80+
[ConditionalFact]
81+
[SkipOnOS(OS.Linux)]
82+
[SkipOnOS(OS.MacOS)]
83+
public void StandAloneThresholdLineAndMethod()
84+
{
85+
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
86+
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
87+
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
88+
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
89+
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
90+
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
91+
Assert.Contains("Hello World!", standardOutput);
92+
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
93+
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
94+
Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
9595
}
96+
}
9697
}

0 commit comments

Comments
 (0)