From 1740338df592bedb58cac920dac6b2061c18aa1e Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Thu, 28 Nov 2019 06:48:34 -0800 Subject: [PATCH] CoreHost: Remove a long-name test asset (#373) * CoreHost: Remove a long-name test asset One of the Bundler test use a test-asset with a very long name. This caused problems during `git clone` on windows systems where longname support is not enabled. This change removes the long-named content file from the repo, and generates it from the test instead. * Add long-name fixup for additional tests --- .../Assets/TestProjects/AppWithSubDirs/Program.cs | 1 + .../word | 1 - .../AppHost.Bundle.Tests/BundledAppWithSubDirs.cs | 15 ++++------- .../Helpers/BundleHelper.cs | 29 +++++++++++++++++++++- .../BundleExtractRun.cs | 2 ++ 5 files changed, 36 insertions(+), 12 deletions(-) delete mode 100644 src/installer/test/Assets/TestProjects/AppWithSubDirs/Sentence/This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really long file name for punctuation/word diff --git a/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs b/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs index 2aa4630..0ad18ac 100644 --- a/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs +++ b/src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs @@ -30,6 +30,7 @@ namespace AppWithSubDirs Part("Noun") + Part("Conjunction") + Part("Noun", "Pronoun", "Another") + + // The following part with a really long name is generated while running the test. Part("This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really long file name for punctuation"); // This should print "Wow! We now say hello to the big world and you." diff --git a/src/installer/test/Assets/TestProjects/AppWithSubDirs/Sentence/This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really long file name for punctuation/word b/src/installer/test/Assets/TestProjects/AppWithSubDirs/Sentence/This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really long file name for punctuation/word deleted file mode 100644 index 945c9b4..0000000 --- a/src/installer/test/Assets/TestProjects/AppWithSubDirs/Sentence/This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really long file name for punctuation/word +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs index f3d64d3..59360c0 100644 --- a/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs +++ b/src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs @@ -7,8 +7,6 @@ using Xunit; using Microsoft.DotNet.Cli.Build.Framework; using BundleTests.Helpers; using Microsoft.DotNet.CoreSetup.Test; -using System.Xml.Linq; -using System.IO; namespace AppHost.Bundle.Tests { @@ -81,26 +79,22 @@ namespace AppHost.Bundle.Tests RepoDirectories = new RepoDirectoriesProvider(); TestFrameworkDependentFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories); + BundleHelper.AddLongNameContentToAppWithSubDirs(TestFrameworkDependentFixture); TestFrameworkDependentFixture .EnsureRestoredForRid(TestFrameworkDependentFixture.CurrentRid, RepoDirectories.CorehostPackages) .PublishProject(runtime: TestFrameworkDependentFixture.CurrentRid, outputDirectory: BundleHelper.GetPublishPath(TestFrameworkDependentFixture)); TestSelfContainedFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories); + BundleHelper.AddLongNameContentToAppWithSubDirs(TestSelfContainedFixture); TestSelfContainedFixture .EnsureRestoredForRid(TestSelfContainedFixture.CurrentRid, RepoDirectories.CorehostPackages) .PublishProject(runtime: TestSelfContainedFixture.CurrentRid, outputDirectory: BundleHelper.GetPublishPath(TestSelfContainedFixture)); TestAppWithEmptyFileFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories); - XDocument projectDoc = XDocument.Load(TestAppWithEmptyFileFixture.TestProject.ProjectFile); - projectDoc.Root.Add( - new XElement("ItemGroup", - new XElement("Content", - new XAttribute("Include", "empty.txt"), - new XElement("CopyToOutputDirectory", "PreserveNewest")))); - projectDoc.Save(TestAppWithEmptyFileFixture.TestProject.ProjectFile); - File.WriteAllBytes(Path.Combine(TestAppWithEmptyFileFixture.TestProject.Location, "empty.txt"), new byte[0]); + BundleHelper.AddLongNameContentToAppWithSubDirs(TestAppWithEmptyFileFixture); + BundleHelper.AddEmptyContentToApp(TestAppWithEmptyFileFixture); TestAppWithEmptyFileFixture .EnsureRestoredForRid(TestAppWithEmptyFileFixture.CurrentRid, RepoDirectories.CorehostPackages) .PublishProject(runtime: TestAppWithEmptyFileFixture.CurrentRid, @@ -111,6 +105,7 @@ namespace AppHost.Bundle.Tests { TestFrameworkDependentFixture.Dispose(); TestSelfContainedFixture.Dispose(); + TestAppWithEmptyFileFixture.Dispose(); } } } diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs index 71d18fe..5d24574 100644 --- a/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs +++ b/src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs @@ -2,8 +2,9 @@ // 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.IO; using Microsoft.DotNet.CoreSetup.Test; +using System.IO; +using System.Xml.Linq; namespace BundleTests.Helpers { @@ -60,5 +61,31 @@ namespace BundleTests.Helpers return singleFile; } + public static void AddLongNameContentToAppWithSubDirs(TestProjectFixture fixture) + { + // For tests using the AppWithSubDirs, One of the sub-directories with a really long name + // is generated during test-runs rather than being checked in as a test asset. + // This prevents git-clone of the repo from failing if long-file-name support is not enabled on windows. + var longDirName = "This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really long file name for punctuation"; + var longDirPath = Path.Combine(fixture.TestProject.ProjectDirectory, "Sentence", longDirName); + Directory.CreateDirectory(longDirPath); + using (var writer = File.CreateText(Path.Combine(longDirPath, "word"))) + { + writer.Write("."); + } + } + + public static void AddEmptyContentToApp(TestProjectFixture fixture) + { + XDocument projectDoc = XDocument.Load(fixture.TestProject.ProjectFile); + projectDoc.Root.Add( + new XElement("ItemGroup", + new XElement("Content", + new XAttribute("Include", "empty.txt"), + new XElement("CopyToOutputDirectory", "PreserveNewest")))); + projectDoc.Save(fixture.TestProject.ProjectFile); + File.WriteAllBytes(Path.Combine(fixture.TestProject.Location, "empty.txt"), new byte[0]); + } + } } diff --git a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleExtractRun.cs b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleExtractRun.cs index cb2dfa1..67d4fe6 100644 --- a/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleExtractRun.cs +++ b/src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleExtractRun.cs @@ -101,6 +101,8 @@ namespace Microsoft.NET.HostModel.Tests RepoDirectories = new RepoDirectoriesProvider(); TestFixture = new TestProjectFixture("AppWithSubDirs", RepoDirectories); + BundleHelper.AddLongNameContentToAppWithSubDirs(TestFixture); + TestFixture .EnsureRestoredForRid(TestFixture.CurrentRid, RepoDirectories.CorehostPackages) .PublishProject(runtime: TestFixture.CurrentRid, -- 2.7.4