Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a Race in Installer Test Infrastructure #38143

Merged
3 commits merged into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public BundleRename(SharedTestState fixture)
}

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/38013")]
[InlineData(true)] // Test renaming the single-exe when contents are extracted
[InlineData(false)] // Test renaming the single-exe when contents are not extracted
private void Bundle_can_be_renamed_while_running(bool testExtraction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class SharedTestState : IDisposable
public SharedTestState()
{
RepoDirectories = new RepoDirectoriesProvider();
TestFixture = new TestProjectFixture("StaticHostApp", RepoDirectories);
TestFixture = new TestProjectFixture("StandaloneApp", RepoDirectories);
TestFixture
.EnsureRestoredForRid(TestFixture.CurrentRid, RepoDirectories.CorehostPackages)
.PublishProject(runtime: TestFixture.CurrentRid,
Expand Down
3 changes: 0 additions & 3 deletions src/installer/tests/TestUtils/TestApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.DotNet.CoreSetup.Test.HostActivation;
using System.IO;

namespace Microsoft.DotNet.CoreSetup.Test
Expand Down Expand Up @@ -37,8 +36,6 @@ public TestApp(TestApp source)
public static TestApp CreateEmpty(string name)
{
string location = GetNewTestArtifactPath(name);
FileUtils.EnsureDirectoryExists(location);

return new TestApp(location);
}

Expand Down
21 changes: 12 additions & 9 deletions src/installer/tests/TestUtils/TestArtifact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.DotNet.CoreSetup.Test.HostActivation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;

namespace Microsoft.DotNet.CoreSetup.Test
{
Expand Down Expand Up @@ -67,25 +69,26 @@ public virtual void Dispose()
_copies.Clear();
}

private static readonly object _pathCountLock = new object();
protected static string GetNewTestArtifactPath(string artifactName)
{
int projectCount = 0;
string projectDirectory = Path.Combine(TestArtifactsPath, projectCount.ToString(), artifactName);
string projectCountDir() => Path.Combine(TestArtifactsPath, projectCount.ToString(), artifactName);

while (Directory.Exists(projectDirectory))
for (; Directory.Exists(projectCountDir()); projectCount++);

lock (_pathCountLock)
{
projectDirectory = Path.Combine(TestArtifactsPath, (++projectCount).ToString(), artifactName);
string projectDirectory;
for (; Directory.Exists(projectDirectory = projectCountDir()); projectCount++);
FileUtils.EnsureDirectoryExists(projectDirectory);
return projectDirectory;
}

return projectDirectory;
}

protected static void CopyRecursive(string sourceDirectory, string destinationDirectory, bool overwrite = false)
{
if (!Directory.Exists(destinationDirectory))
{
Directory.CreateDirectory(destinationDirectory);
}
FileUtils.EnsureDirectoryExists(destinationDirectory);

foreach (var dir in Directory.EnumerateDirectories(sourceDirectory))
{
Expand Down