Skip to content

Commit dfa3f2c

Browse files
committed
introduce CleanupBuildOutput method
1 parent 3046182 commit dfa3f2c

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

test/coverlet.integration.tests/DeterministicBuild.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Xml.Linq;
99
using Coverlet.Core;
1010
using Coverlet.Tests.Utils;
11-
using Coverlet.Tests.Xunit.Extensions;
1211
using Newtonsoft.Json;
1312
using Xunit;
1413
using Xunit.Abstractions;
@@ -127,14 +126,10 @@ public void Msbuild()
127126
Assert.True(File.Exists(testResultFile));
128127
AssertCoverage(standardOutput);
129128

130-
// Process exits hang on clean seem that process doesn't close, maybe some msbuild node reuse? btw manually tested
131-
DotnetCli("clean", out standardOutput, out standardError, _testProjectPath);
132-
// Assert.False(File.Exists(sourceRootMappingFilePath));
133-
// RunCommand("git", "clean -fdx", out _, out _, _testProjectPath);
129+
CleanupBuildOutput();
134130
}
135131

136-
[ConditionalFact]
137-
[SkipOnOS(OS.Linux, "Hung up on Linux")]
132+
[Fact]
138133
public void Msbuild_SourceLink()
139134
{
140135
string testResultPath = Path.Join(_testResultsPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName);
@@ -176,17 +171,14 @@ public void Msbuild_SourceLink()
176171
Assert.Contains("raw.githubusercontent.com", File.ReadAllText(testResultFile));
177172
AssertCoverage(standardOutput, checkDeterministicReport: false);
178173

179-
// Process exits hang on clean seem that process doesn't close, maybe some msbuild node reuse? btw manually tested
180-
DotnetCli("clean", out standardOutput, out standardError, _testProjectPath);
181-
// Assert.False(File.Exists(sourceRootMappingFilePath));
182-
// RunCommand("git", "clean -fdx", out _, out _, _testProjectPath);
174+
CleanupBuildOutput();
183175
}
184176

185177
[Fact]
186178
public void Collectors()
187179
{
188180
string testResultPath = Path.Join(_testResultsPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName);
189-
string testLogFilesPath = Path.Join(_testBinaryPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName);
181+
string testLogFilesPath = Path.Join(_testResultsPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName, "log");
190182
string logFilename = string.Concat(((ITest)_testMember!.GetValue(_output)!).DisplayName, ".binlog");
191183

192184
CreateDeterministicTestPropsFile();
@@ -234,17 +226,14 @@ public void Collectors()
234226
Assert.Contains("[coverlet]Initialize CoverletInProcDataCollector", File.ReadAllText(Directory.GetFiles(testLogFilesPath, "log.host.*.txt").Single()));
235227
Assert.Contains("[coverlet]Mapping resolved", dataCollectorLogContent);
236228

237-
// Process exits hang on clean seem that process doesn't close, maybe some msbuild node reuse? btw manually tested
238-
DotnetCli("clean", out standardOutput, out standardError, _testProjectPath);
239-
// Assert.False(File.Exists(sourceRootMappingFilePath));
240-
// RunCommand("git", "clean -fdx", out _, out _, _testProjectPath);
229+
CleanupBuildOutput();
241230
}
242231

243232
[Fact]
244233
public void Collectors_SourceLink()
245234
{
246235
string testResultPath = Path.Join(_testResultsPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName);
247-
string testLogFilesPath = Path.Join(_testBinaryPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName);
236+
string testLogFilesPath = Path.Join(_testResultsPath, ((ITest)_testMember!.GetValue(_output)!).DisplayName, "log");
248237
string logFilename = string.Concat(((ITest)_testMember!.GetValue(_output)!).DisplayName, ".binlog");
249238

250239
CreateDeterministicTestPropsFile();
@@ -305,10 +294,7 @@ public void Collectors_SourceLink()
305294
Assert.Contains("[coverlet]Initialize CoverletInProcDataCollector", File.ReadAllText(Directory.GetFiles(testLogFilesPath, "log.host.*.txt").Single()));
306295
Assert.Contains("[coverlet]Mapping resolved", dataCollectorLogContent);
307296

308-
// Process exits hang on clean seem that process doesn't close, maybe some msbuild node reuse? btw manually tested
309-
DotnetCli("clean", out standardOutput, out standardError, _testProjectPath);
310-
// Assert.False(File.Exists(sourceRootMappingFilePath));
311-
// RunCommand("git", "clean -fdx", out _, out _, _testProjectPath);
297+
CleanupBuildOutput();
312298
}
313299

314300
private static void DeleteTestIntermediateFiles(string testResultsPath)
@@ -342,6 +328,19 @@ private static void DeleteLogFiles(string directory)
342328
}
343329

344330
}
331+
private void CleanupBuildOutput()
332+
{
333+
if (Directory.Exists(_testBinaryPath))
334+
{
335+
Directory.Delete(_testBinaryPath, recursive: true);
336+
}
337+
338+
string intermediateBuildOutput = _testBinaryPath.Replace("bin", "obj");
339+
if (Directory.Exists(intermediateBuildOutput))
340+
{
341+
Directory.Delete(intermediateBuildOutput, recursive: true);
342+
}
343+
}
345344
private static void DeleteCoverageFiles(string directory)
346345
{
347346
if (Directory.Exists(directory))

0 commit comments

Comments
 (0)