From 3ec54e0c35c87e2c74b7dc99c274660d58e2806b Mon Sep 17 00:00:00 2001 From: Jan Krivanek Date: Tue, 11 Apr 2023 17:12:39 +0200 Subject: [PATCH] Add diagnostics to symlink embedding unittest --- src/Build.UnitTests/BinaryLogger_Tests.cs | 15 ++++++++++----- .../RequiresSymbolicLinksFactAttribute.cs | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Build.UnitTests/BinaryLogger_Tests.cs b/src/Build.UnitTests/BinaryLogger_Tests.cs index 10e697437e2..e16f3578b22 100644 --- a/src/Build.UnitTests/BinaryLogger_Tests.cs +++ b/src/Build.UnitTests/BinaryLogger_Tests.cs @@ -262,7 +262,8 @@ public void BinaryLoggerShouldEmbedFilesViaTaskOutput() // Can't just compare `Name` because `ZipArchive` does not handle unix directory separators well // thus producing garbled fully qualified paths in the actual .ProjectImports.zip entries - zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith("testtaskoutputfile.txt")); + zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith("testtaskoutputfile.txt"), + () => $"Embedded files: {string.Join(",", zipArchive.Entries)}"); } [RequiresSymbolicLinksFact] @@ -321,10 +322,14 @@ public void BinaryLoggerShouldEmbedSymlinkFilesViaTaskOutput() // Can't just compare `Name` because `ZipArchive` does not handle unix directory separators well // thus producing garbled fully qualified paths in the actual .ProjectImports.zip entries - zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith("testtaskoutputfile.txt")); - zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith(symlinkName)); - zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith(symlinkLvl2Name)); - zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith(emptyFileName)); + zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith("testtaskoutputfile.txt"), + () => $"Embedded files: {string.Join(",", zipArchive.Entries)}"); + zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith(symlinkName), + () => $"Embedded files: {string.Join(",", zipArchive.Entries)}"); + zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith(symlinkLvl2Name), + () => $"Embedded files: {string.Join(",", zipArchive.Entries)}"); + zipArchive.Entries.ShouldContain(zE => zE.Name.EndsWith(emptyFileName), + () => $"Embedded files: {string.Join(",", zipArchive.Entries)}"); } [Fact] diff --git a/src/UnitTests.Shared/RequiresSymbolicLinksFactAttribute.cs b/src/UnitTests.Shared/RequiresSymbolicLinksFactAttribute.cs index 4e53459f155..8f98ab38e0a 100644 --- a/src/UnitTests.Shared/RequiresSymbolicLinksFactAttribute.cs +++ b/src/UnitTests.Shared/RequiresSymbolicLinksFactAttribute.cs @@ -27,7 +27,7 @@ public RequiresSymbolicLinksFactAttribute() // In Windows, a process can create symlinks only if it has sufficient permissions. // We simply try to create one and if it fails we skip the test. string sourceFile = FileUtilities.GetTemporaryFile(); - string destinationFile = FileUtilities.GetTemporaryFile(); + string destinationFile = FileUtilities.GetTemporaryFileName(); try { File.Create(sourceFile).Dispose();