CoreHost: Remove a long-name test asset (#373)
authorSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Thu, 28 Nov 2019 14:48:34 +0000 (06:48 -0800)
committerViktor Hofer <viktor.hofer@microsoft.com>
Thu, 28 Nov 2019 14:48:34 +0000 (15:48 +0100)
* 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

src/installer/test/Assets/TestProjects/AppWithSubDirs/Program.cs
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]
src/installer/test/Microsoft.NET.HostModel.Tests/AppHost.Bundle.Tests/BundledAppWithSubDirs.cs
src/installer/test/Microsoft.NET.HostModel.Tests/Helpers/BundleHelper.cs
src/installer/test/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Bundle.Tests/BundleExtractRun.cs

index 2aa4630..0ad18ac 100644 (file)
@@ -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 (file)
index 945c9b4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-.
\ No newline at end of file
index f3d64d3..59360c0 100644 (file)
@@ -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();
             }
         }
     }
index 71d18fe..5d24574 100644 (file)
@@ -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]);
+        }
+
     }
 }
index cb2dfa1..67d4fe6 100644 (file)
@@ -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,