From b2432086ef975650227a2015a26e1792d757244d Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Thu, 18 Jun 2020 00:11:49 -0700 Subject: [PATCH 1/3] Re-enable Apphost.Bundle.Tests.BundleRename test --- .../AppHost.Bundle.Tests/BundleRename.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs index 3a0ed2c7f33e6e..8decb641466908 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundleRename.cs @@ -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) From 98277682cd71d2067b67e39a383940ce3836c522 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Thu, 18 Jun 2020 00:13:57 -0700 Subject: [PATCH 2/3] Remove StaticHostApp StaticHostTest used the StaticHostApp (which is effectively a copy of StandaloneApp) as a work-around for synchronization problems. Remove this work-around. --- .../Assets/TestProjects/StaticHostApp/Program.cs | 16 ---------------- .../StaticHostApp/StaticHostApp.csproj | 13 ------------- .../AppHost.Bundle.Tests/StaticHost.cs | 2 +- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs delete mode 100644 src/installer/tests/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj diff --git a/src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs b/src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs deleted file mode 100644 index c631d81d540483..00000000000000 --- a/src/installer/tests/Assets/TestProjects/StaticHostApp/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -namespace StaticHostApp -{ - public static class Program - { - public static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/src/installer/tests/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj b/src/installer/tests/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj deleted file mode 100644 index eff31e8532b40b..00000000000000 --- a/src/installer/tests/Assets/TestProjects/StaticHostApp/StaticHostApp.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - $(NETCoreAppFramework) - Exe - $(TestTargetRid) - $(MNAVersion) - - - - - - diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs index 78b5c9449fe1b3..504ebe33e42e75 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/StaticHost.cs @@ -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, From 639a214245789fa1ff1967f0c9f74e24c9073f53 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Thu, 18 Jun 2020 00:06:34 -0700 Subject: [PATCH 3/3] Synchronize GetNewTestArtifactPath() Add locking around GetNewTestArtifactPath() so that multiple threads attempting to create new copies of a TextFixture don't collide and work on the same path. --- src/installer/tests/TestUtils/TestApp.cs | 3 --- src/installer/tests/TestUtils/TestArtifact.cs | 21 +++++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/installer/tests/TestUtils/TestApp.cs b/src/installer/tests/TestUtils/TestApp.cs index a1ff67d95c82ed..4936dfe3cdb331 100644 --- a/src/installer/tests/TestUtils/TestApp.cs +++ b/src/installer/tests/TestUtils/TestApp.cs @@ -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 @@ -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); } diff --git a/src/installer/tests/TestUtils/TestArtifact.cs b/src/installer/tests/TestUtils/TestArtifact.cs index d989a37e8f9f98..d514d211610192 100644 --- a/src/installer/tests/TestUtils/TestArtifact.cs +++ b/src/installer/tests/TestUtils/TestArtifact.cs @@ -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 { @@ -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)) {