Skip to content

Commit 580a33d

Browse files
committed
enable dotnetTool integration tests for linux and MayOs
1 parent 7c8c6fa commit 580a33d

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

eng/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ steps:
4545
mergeTestResults: false
4646
publishRunAttachments: true
4747
failTaskOnFailedTests: true
48+
condition: succeededOrFailed()
4849

4950
- template: publish-coverlet-result-files.yml
5051

test/coverlet.integration.tests/DotnetTool.cs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.Linq;
66
using Coverlet.Tests.Utils;
7-
using Coverlet.Tests.Xunit.Extensions;
87
using Xunit;
98
using Xunit.Abstractions;
109

@@ -61,64 +60,79 @@ public void StandAlone()
6160
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
6261
}
6362

64-
[ConditionalFact]
65-
[SkipOnOS(OS.Linux)]
66-
[SkipOnOS(OS.MacOS)]
63+
[Fact]
6764
public void StandAloneThreshold()
6865
{
6966
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
7067
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
7168
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
69+
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
7270
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
7371
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
74-
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
72+
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --output \"{outputPath}\"", out standardOutput, out standardError));
7573
if (!string.IsNullOrEmpty(standardError))
7674
{
7775
_output.WriteLine(standardError);
7876
}
77+
else
78+
{
79+
// make standard output available in trx file
80+
_output.WriteLine(standardOutput);
81+
}
7982
Assert.Contains("Hello World!", standardOutput);
83+
Assert.True(File.Exists($"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json"));
8084
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
8185
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
8286
Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);
8387
}
8488

85-
[ConditionalFact]
86-
[SkipOnOS(OS.Linux)]
87-
[SkipOnOS(OS.MacOS)]
89+
[Fact]
8890
public void StandAloneThresholdLine()
8991
{
9092
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
9193
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
9294
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
95+
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
9396
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
9497
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
95-
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError));
98+
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --output \"{outputPath}\"", out standardOutput, out standardError));
9699
if (!string.IsNullOrEmpty(standardError))
97100
{
98101
_output.WriteLine(standardError);
99102
}
103+
else
104+
{
105+
// make standard output available in trx file
106+
_output.WriteLine(standardOutput);
107+
}
100108
Assert.Contains("Hello World!", standardOutput);
109+
Assert.True(File.Exists($"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json"));
101110
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
102111
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
103112
Assert.DoesNotContain("The minimum method coverage is below the specified 80", standardOutput);
104113
}
105114

106-
[ConditionalFact]
107-
[SkipOnOS(OS.Linux)]
108-
[SkipOnOS(OS.MacOS)]
115+
[Fact]
109116
public void StandAloneThresholdLineAndMethod()
110117
{
111118
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
112119
UpdateNugetConfigWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
113120
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
121+
string outputPath = $"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json";
114122
DotnetCli($"build -f {_buildTargetFramework} {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
115123
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
116-
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));
124+
Assert.False(RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --threshold 80 --threshold-type line --threshold-type method --output \"{outputPath}\"", out standardOutput, out standardError));
117125
if (!string.IsNullOrEmpty(standardError))
118126
{
119127
_output.WriteLine(standardError);
120128
}
129+
else
130+
{
131+
// make standard output available in trx file
132+
_output.WriteLine(standardOutput);
133+
}
121134
Assert.Contains("Hello World!", standardOutput);
135+
Assert.True(File.Exists($"{clonedTemplateProject.ProjectRootPath}{Path.DirectorySeparatorChar}coverage.json"));
122136
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
123137
Assert.Contains("The minimum line coverage is below the specified 80", standardOutput);
124138
Assert.Contains("The minimum method coverage is below the specified 80", standardOutput);

test/coverlet.tests.utils/TestUtils.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public static BuildConfiguration GetAssemblyBuildConfiguration()
3333

3434
public static string GetAssemblyTargetFramework()
3535
{
36+
#if NET6_0
37+
return "net6.0";
38+
#endif
3639
#if NET7_0
3740
return "net7.0";
3841
#endif

0 commit comments

Comments
 (0)