Skip to content

Commit 95b5cdf

Browse files
authored
Make tests run on all platforms (#1492)
1 parent 26bd50b commit 95b5cdf

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

test/coverlet.core.tests/Instrumentation/InstrumenterTests.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Toni Solarin-Sodara
1+
// Copyright (c) Toni Solarin-Sodara
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System;
@@ -34,9 +34,7 @@ public void Dispose()
3434
_disposeAction?.Invoke();
3535
}
3636

37-
[ConditionalFact]
38-
[SkipOnOS(OS.Linux)]
39-
[SkipOnOS(OS.MacOS)]
37+
[Fact]
4038
public void TestCoreLibInstrumentation()
4139
{
4240
DirectoryInfo directory = Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), nameof(TestCoreLibInstrumentation)));
@@ -55,7 +53,7 @@ public void TestCoreLibInstrumentation()
5553
partialMockFileSystem.CallBase = true;
5654
partialMockFileSystem.Setup(fs => fs.OpenRead(It.IsAny<string>())).Returns((string path) =>
5755
{
58-
if (Path.GetFileName(path) == files[1])
56+
if (Path.GetFileName(path.Replace(@"\", @"/")) == files[1])
5957
{
6058
return File.OpenRead(Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), "TestAssets"), files[1]));
6159
}
@@ -66,7 +64,7 @@ public void TestCoreLibInstrumentation()
6664
});
6765
partialMockFileSystem.Setup(fs => fs.Exists(It.IsAny<string>())).Returns((string path) =>
6866
{
69-
if (Path.GetFileName(path) == files[1])
67+
if (Path.GetFileName(path.Replace(@"\", @"/")) == files[1])
7068
{
7169
return File.Exists(Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), "TestAssets"), files[1]));
7270
}
@@ -446,9 +444,7 @@ public void SkipEmbeddedPpdbWithoutLocalSource()
446444
loggerMock.VerifyNoOtherCalls();
447445
}
448446

449-
[ConditionalFact]
450-
[SkipOnOS(OS.MacOS)]
451-
[SkipOnOS(OS.Linux)]
447+
[Fact]
452448
public void SkipPpdbWithoutLocalSource()
453449
{
454450
string dllFileName = "75d9f96508d74def860a568f426ea4a4.dll";
@@ -458,7 +454,7 @@ public void SkipPpdbWithoutLocalSource()
458454
partialMockFileSystem.CallBase = true;
459455
partialMockFileSystem.Setup(fs => fs.OpenRead(It.IsAny<string>())).Returns((string path) =>
460456
{
461-
if (Path.GetFileName(path) == pdbFileName)
457+
if (Path.GetFileName(path.Replace(@"\", @"/")) == pdbFileName)
462458
{
463459
return File.OpenRead(Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), "TestAssets"), pdbFileName));
464460
}
@@ -469,7 +465,7 @@ public void SkipPpdbWithoutLocalSource()
469465
});
470466
partialMockFileSystem.Setup(fs => fs.Exists(It.IsAny<string>())).Returns((string path) =>
471467
{
472-
if (Path.GetFileName(path) == pdbFileName)
468+
if (Path.GetFileName(path.Replace(@"\", @"/")) == pdbFileName)
473469
{
474470
return File.Exists(Path.Combine(Path.Combine(Directory.GetCurrentDirectory(), "TestAssets"), pdbFileName));
475471
}

test/coverlet.integration.tests/DotnetTool.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,31 @@ private string InstallTool(string projectPath)
1414
{
1515
_ = DotnetCli($"tool install coverlet.console --version {GetPackageVersion("*console*.nupkg")} --tool-path \"{Path.Combine(projectPath, "coverletTool")}\"", out string standardOutput, out _, projectPath);
1616
Assert.Contains("was successfully installed.", standardOutput);
17-
return Path.Combine(projectPath, "coverletTool", "coverlet ");
17+
return Path.Combine(projectPath, "coverletTool", "coverlet");
1818
}
1919

20-
[ConditionalFact]
21-
[SkipOnOS(OS.Linux)]
22-
[SkipOnOS(OS.MacOS)]
20+
[Fact]
2321
public void DotnetTool()
2422
{
2523
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
2624
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
2725
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
2826
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
2927
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
30-
RunCommand(coverletToolCommandPath, $"\"{publishedTestFile}\" --target \"dotnet\" --targetargs \"test {Path.Combine(clonedTemplateProject.ProjectRootPath, ClonedTemplateProject.ProjectFileName)} --no-build\" --include-test-assembly --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError);
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);
3129
Assert.Contains("Passed!", standardOutput);
3230
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
3331
}
3432

35-
[ConditionalFact]
36-
[SkipOnOS(OS.Linux)]
37-
[SkipOnOS(OS.MacOS)]
33+
[Fact]
3834
public void StandAlone()
3935
{
4036
using ClonedTemplateProject clonedTemplateProject = CloneTemplateProject();
4137
UpdateNugeConfigtWithLocalPackageFolder(clonedTemplateProject.ProjectRootPath!);
4238
string coverletToolCommandPath = InstallTool(clonedTemplateProject.ProjectRootPath!);
4339
DotnetCli($"build {clonedTemplateProject.ProjectRootPath}", out string standardOutput, out string standardError);
4440
string publishedTestFile = clonedTemplateProject.GetFiles("*" + ClonedTemplateProject.AssemblyName + ".dll").Single(f => !f.Contains("obj") && !f.Contains("ref"));
45-
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"\\", out standardOutput, out standardError);
41+
RunCommand(coverletToolCommandPath, $"\"{Path.GetDirectoryName(publishedTestFile)}\" --target \"dotnet\" --targetargs \"{publishedTestFile}\" --output \"{clonedTemplateProject.ProjectRootPath}\"{Path.DirectorySeparatorChar}", out standardOutput, out standardError);
4642
Assert.Contains("Hello World!", standardOutput);
4743
AssertCoverage(clonedTemplateProject, standardOutput: standardOutput);
4844
}

0 commit comments

Comments
 (0)