From 3e0e54aff605da9c5ec6c02f7e83d5e816c857a2 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 26 Aug 2022 17:47:46 -0700 Subject: Update old test code to latest SWID tag spec Fixes 6675 --- .../PatchTests/BundlePatchA/BundlePatchA.wixproj | 3 ++ .../burn/TestData/PatchTests/PatchA/PatchA.wixproj | 3 +- src/test/burn/TestData/Templates/Bundle.wxs | 2 +- src/test/burn/TestData/Templates/Package.wxs | 8 ++- src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs | 13 +++-- .../WixToolsetTest.CoreIntegration/PatchFixture.cs | 59 ++++++++++++++++++++-- .../TestData/PatchWithSoftwareTag/.data/A.txt | 1 + .../TestData/PatchWithSoftwareTag/Package.wxs | 28 ++++++++++ .../TestData/PatchWithSoftwareTag/Patch.wxs | 16 ++++++ 9 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs (limited to 'src') diff --git a/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj b/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj index 9b91b3f4..5eeaff59 100644 --- a/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj +++ b/src/test/burn/TestData/PatchTests/BundlePatchA/BundlePatchA.wixproj @@ -5,6 +5,9 @@ true {AA083618-6280-44B8-9899-57BCC57906A5} + + 1.0.1.0 + diff --git a/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj b/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj index da9acb5e..6163691a 100644 --- a/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj +++ b/src/test/burn/TestData/PatchTests/PatchA/PatchA.wixproj @@ -1,8 +1,7 @@ - PatchCreation - .msp + Patch 1079 diff --git a/src/test/burn/TestData/Templates/Bundle.wxs b/src/test/burn/TestData/Templates/Bundle.wxs index c55f67a7..43974524 100644 --- a/src/test/burn/TestData/Templates/Bundle.wxs +++ b/src/test/burn/TestData/Templates/Bundle.wxs @@ -14,7 +14,7 @@ - + diff --git a/src/test/burn/TestData/Templates/Package.wxs b/src/test/burn/TestData/Templates/Package.wxs index c7597131..a1189fd9 100644 --- a/src/test/burn/TestData/Templates/Package.wxs +++ b/src/test/burn/TestData/Templates/Package.wxs @@ -20,7 +20,7 @@ - + @@ -35,6 +35,12 @@ + + + + + + diff --git a/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs index b63be5f5..b0cdea16 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/PatchTests.cs @@ -56,7 +56,7 @@ namespace WixToolsetTest.BurnE2E packageAv1.VerifyTestRegistryRootDeleted(); } - [RuntimeFact(Skip = "https://github.com/wixtoolset/issues/issues/6675")] + [RuntimeFact] public void CanPatchSwidTag() { var originalVersion = "1.0.0.0"; @@ -116,8 +116,7 @@ namespace WixToolsetTest.BurnE2E private static void VerifySwidTagVersion(string tagName, string expectedVersion) { - var regidFolder = Environment.ExpandEnvironmentVariables(@"%ProgramData%\regid.1995-08.com.example"); - var tagPath = Path.Combine(regidFolder, "regid.1995-08.com.example " + tagName + ".swidtag"); + var tagPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "TestingSwidTags", "swidtag", tagName + ".swidtag"); string version = null; if (File.Exists(tagPath)) @@ -126,11 +125,15 @@ namespace WixToolsetTest.BurnE2E doc.Load(tagPath); var ns = new XmlNamespaceManager(doc.NameTable); - ns.AddNamespace("s", "http://standards.iso.org/iso/19770/-2/2009/schema.xsd"); + ns.AddNamespace("s", "http://standards.iso.org/iso/19770/-2/2015/schema.xsd"); - var versionNode = doc.SelectSingleNode("/s:software_identification_tag/s:product_version/s:name", ns); + var versionNode = doc.SelectSingleNode("/s:SoftwareIdentity/@version", ns); version = versionNode?.InnerText ?? String.Empty; } + else + { + Assert.True(expectedVersion == null, $"Did not find SWID tag with expected version {expectedVersion} at: {tagPath}"); + } Assert.Equal(expectedVersion, version); } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs index a26472fa..5bf770ac 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs @@ -9,6 +9,7 @@ namespace WixToolsetTest.CoreIntegration using System.Linq; using System.Runtime.InteropServices; using System.Text; + using System.Text.RegularExpressions; using System.Xml; using System.Xml.Linq; using Example.Extension; @@ -86,6 +87,50 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void CanBuildSimplePatchWithSoftwareTag() + { + var folder = TestData.Get(@"TestData", "PatchWithSoftwareTag"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var tempFolderBaseline = Path.Combine(baseFolder, "baseline"); + var tempFolderUpdate = Path.Combine(baseFolder, "update"); + var tempFolderPatch = Path.Combine(baseFolder, "patch"); + + var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolderBaseline, "1.0.0", "1.0.0", "1.0.0"); + var update1Pdb = BuildMsi("Update.msi", folder, tempFolderUpdate, "1.0.1", "1.0.1", "1.0.1"); + var patchPdb = BuildMsp("Patch1.msp", folder, tempFolderPatch, "1.0.1", bindpaths: new[] { Path.GetDirectoryName(baselinePdb), Path.GetDirectoryName(update1Pdb) }); + var patchPath = Path.ChangeExtension(patchPdb, ".msp"); + + var doc = GetExtractPatchXml(patchPath); + WixAssert.StringEqual("{7D326855-E790-4A94-8611-5351F8321FCA}", doc.Root.Element(PatchNamespace + "TargetProductCode").Value); + + var names = Query.GetSubStorageNames(patchPath); + WixAssert.CompareLineByLine(new[] { "#RTM.1", "RTM.1" }, names); + + var cab = Path.Combine(baseFolder, "foo.cab"); + Query.ExtractStream(patchPath, "foo.cab", cab); + Assert.True(File.Exists(cab)); + + var files = Query.GetCabinetFiles(cab); + var file = files.Single(); + WixAssert.StringEqual("tag1jwIT_7lT286E4Dyji95s65UuO4", file.Name); + + var contents = file.OpenText().ReadToEnd(); + contents = Regex.Replace(contents, @"msi\:package/[A-Z0-9\-]+", "msi:package/G-U-I-D"); + WixAssert.StringEqual(String.Join(Environment.NewLine, new[] + { + "", + "", + " ", + " ", + "", + }), contents.Replace('"', '\'')); + } + } + [Fact] public void CanBuildSimplePatchWithBaselineIdTooLong() { @@ -192,12 +237,12 @@ namespace WixToolsetTest.CoreIntegration } } - private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB) + private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB, IEnumerable bindpaths = null) { var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName)); - var result = WixRunner.Execute(new[] + var args = new List { "build", Path.Combine(sourceFolder, @"Package.wxs"), @@ -208,7 +253,15 @@ namespace WixToolsetTest.CoreIntegration "-intermediateFolder", Path.Combine(baseFolder, "obj"), "-o", outputPath, "-ext", extensionPath, - }); + }; + + foreach (var additionaBindPath in bindpaths ?? Enumerable.Empty()) + { + args.Add("-bindpath"); + args.Add(additionaBindPath); + } + + var result = WixRunner.Execute(args.ToArray()); result.AssertSuccess(); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt new file mode 100644 index 00000000..6fd385bd --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/.data/A.txt @@ -0,0 +1 @@ +This is A v1.0.0 diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs new file mode 100644 index 00000000..1b97e6b7 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Package.wxs @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs new file mode 100644 index 00000000..889b1220 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithSoftwareTag/Patch.wxs @@ -0,0 +1,16 @@ + + + + + + + + + + -- cgit v1.2.3-55-g6feb