From 0531df3e9f7b3e41434def0c569bd748adc721f6 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 21 Apr 2021 16:51:22 -0500 Subject: Detect payload collisions. #4574 --- .../BundleFixture.cs | 40 ++++++++++++++++++++-- .../MsiTransactionFixture.cs | 8 ++--- .../TestData/BadInput/DuplicatePayloadNames.wxs | 26 ++++++++++++-- .../BundleCustomTable/BundleCustomTable.wxs | 2 +- .../TestData/MsiTransaction/X64AfterX86Bundle.wxs | 8 ++--- .../TestData/MsiTransaction/X86AfterX64Bundle.wxs | 8 ++--- 6 files changed, 75 insertions(+), 17 deletions(-) (limited to 'src/test') diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs index d121da0f..cc91d212 100644 --- a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs @@ -10,6 +10,7 @@ namespace WixToolsetTest.CoreIntegration using System.Xml; using Example.Extension; using WixBuildTools.TestSupport; + using WixToolset.Core.Burn; using WixToolset.Core.TestPackage; using WixToolset.Data; using WixToolset.Data.Burn; @@ -306,7 +307,7 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "https://github.com/wixtoolset/issues/issues/4574")] + [Fact] public void CantBuildWithDuplicatePayloadNames() { var folder = TestData.Get(@"TestData"); @@ -328,7 +329,42 @@ namespace WixToolsetTest.CoreIntegration "-o", exePath, }); - Assert.InRange(result.ExitCode, 2, Int32.MaxValue); + var attachedContainerWarnings = result.Messages.Where(m => m.Id == (int)BurnBackendWarnings.Ids.AttachedContainerPayloadCollision) + .Select(m => m.ToString()) + .ToArray(); + WixAssert.CompareLineByLine(new string[] + { + "The Payload 'Auto2' has a duplicate Name 'burn.exe' in the attached container. When extracting the bundle with dark.exe, the file will get overwritten.", + }, attachedContainerWarnings); + + var baContainerErrors = result.Messages.Where(m => m.Id == (int)BurnBackendErrors.Ids.BAContainerPayloadCollision) + .Select(m => m.ToString()) + .ToArray(); + WixAssert.CompareLineByLine(new string[] + { + "The Payload 'DuplicatePayloadNames.wxs' has a duplicate Name 'fakeba.dll' in the BA container. When extracting the container at runtime, the file will get overwritten.", + "The Payload 'uxTxMXPVMXwQrPTMIGa5WGt93w0Ns' has a duplicate Name 'BootstrapperApplicationData.xml' in the BA container. When extracting the container at runtime, the file will get overwritten.", + "The Payload 'uxYRbgitOs0K878jn5L_z7LdJ21KI' has a duplicate Name 'BundleExtensionData.xml' in the BA container. When extracting the container at runtime, the file will get overwritten.", + }, baContainerErrors); + + var externalErrors = result.Messages.Where(m => m.Id == (int)BurnBackendErrors.Ids.ExternalPayloadCollision) + .Select(m => m.ToString()) + .ToArray(); + WixAssert.CompareLineByLine(new string[] + { + "The external Payload 'HiddenPersistedBundleVariable.wxs' has a duplicate Name 'PayloadCollision'. When building the bundle or laying out the bundle, the file will get overwritten.", + "The external Container 'MsiPackagesContainer' has a duplicate Name 'ContainerCollision'. When building the bundle or laying out the bundle, the file will get overwritten.", + }, externalErrors); + + var packageCacheErrors = result.Messages.Where(m => m.Id == (int)BurnBackendErrors.Ids.PackageCachePayloadCollision) + .Select(m => m.ToString()) + .ToArray(); + WixAssert.CompareLineByLine(new string[] + { + "The Payload 'test.msi' has a duplicate Name 'test.msi' in package 'test.msi'. When caching the package, the file will get overwritten.", + }, packageCacheErrors); + + Assert.Equal(14, result.Messages.Length); } } diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs index 7ec0ea93..a566b490 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs @@ -81,7 +81,7 @@ namespace WixToolsetTest.CoreIntegration Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), "-bindpath", Path.Combine(folder, "SingleFile", "data"), "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(binFolder, "FirstX86.msi"), + "-o", Path.Combine(binFolder, "FirstX86", "FirstX86.msi"), }); result.AssertSuccess(); @@ -94,7 +94,7 @@ namespace WixToolsetTest.CoreIntegration Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), "-bindpath", Path.Combine(folder, "SingleFile", "data"), "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(binFolder, "SecondX86.msi"), + "-o", Path.Combine(binFolder, "SecondX86", "SecondX86.msi"), }); result.AssertSuccess(); @@ -108,7 +108,7 @@ namespace WixToolsetTest.CoreIntegration "-bindpath", Path.Combine(folder, "SingleFile", "data"), "-intermediateFolder", intermediateFolder, "-arch", "x64", - "-o", Path.Combine(binFolder, "FirstX64.msi"), + "-o", Path.Combine(binFolder, "FirstX64", "FirstX64.msi"), }); result.AssertSuccess(); @@ -122,7 +122,7 @@ namespace WixToolsetTest.CoreIntegration "-bindpath", Path.Combine(folder, "SingleFile", "data"), "-intermediateFolder", intermediateFolder, "-arch", "x64", - "-o", Path.Combine(binFolder, "SecondX64.msi"), + "-o", Path.Combine(binFolder, "SecondX64", "SecondX64.msi"), }); result.AssertSuccess(); diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicatePayloadNames.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicatePayloadNames.wxs index 2d4e8a3c..4fe7e097 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicatePayloadNames.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadInput/DuplicatePayloadNames.wxs @@ -2,8 +2,30 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs index db755171..e52302d4 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs @@ -48,6 +48,6 @@ - + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X64AfterX86Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X64AfterX86Bundle.wxs index 8f4fc8bd..e6527a36 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X64AfterX86Bundle.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X64AfterX86Bundle.wxs @@ -2,11 +2,11 @@ - + - - - + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X86AfterX64Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X86AfterX64Bundle.wxs index 221f06c5..f1c939db 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X86AfterX64Bundle.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/MsiTransaction/X86AfterX64Bundle.wxs @@ -2,11 +2,11 @@ - + - - - + + + -- cgit v1.2.3-55-g6feb