@joebigelow / wix / commits / 002dc607

Add simple patching test to verify file updates are included

Rob Mensching committed Sep 2, 2022 at 15:31 UTC 002dc6077477c6a7762f1fca225c2577913a2c82
5 files changed +80
src/wix/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
+35
@@ -55,6 +55,41 @@ namespace WixToolsetTest.CoreIntegration
55 }
56 }
57
58 + [Fact]
59 + public void CanBuildSimplePatchWithFileChanges()
60 + {
61 + var folder = TestData.Get(@"TestData", "PatchWithFileChanges");
62 +
63 + using (var fs = new DisposableFileSystem())
64 + {
65 + var baseFolder = fs.GetFolder();
66 + var tempFolderBaseline = Path.Combine(baseFolder, "baseline");
67 + var tempFolderUpdate = Path.Combine(baseFolder, "update");
68 + var tempFolderPatch = Path.Combine(baseFolder, "patch");
69 +
70 + var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolderBaseline, "1.0.0", "1.0.0", "1.0.0", new[] { Path.Combine(folder, ".baseline-data") });
71 + var update1Pdb = BuildMsi("Update.msi", folder, tempFolderUpdate, "1.0.1", "1.0.1", "1.0.1", new[] { Path.Combine(folder, ".update-data") });
72 + var patchPdb = BuildMsp("Patch1.msp", folder, tempFolderPatch, "1.0.1", bindpaths: new[] { Path.GetDirectoryName(baselinePdb), Path.GetDirectoryName(update1Pdb) });
73 + var patchPath = Path.ChangeExtension(patchPdb, ".msp");
74 +
75 + var doc = GetExtractPatchXml(patchPath);
76 + WixAssert.StringEqual("{7D326855-E790-4A94-8611-5351F8321FCA}", doc.Root.Element(PatchNamespace + "TargetProductCode").Value);
77 +
78 + var names = Query.GetSubStorageNames(patchPath);
79 + WixAssert.CompareLineByLine(new[] { "#RTM.1", "RTM.1" }, names);
80 +
81 + var cab = Path.Combine(baseFolder, "foo.cab");
82 + Query.ExtractStream(patchPath, "foo.cab", cab);
83 + Assert.True(File.Exists(cab));
84 +
85 + var files = Query.GetCabinetFiles(cab);
86 + var file = files.Single();
87 + WixAssert.StringEqual("a.txt", file.Name);
88 + var contents = file.OpenText().ReadToEnd();
89 + WixAssert.StringEqual("This is A v1.0.1\r\n", contents);
90 + }
91 + }
92 +
93 [Fact]
94 public void CanBuildSimplePatchWithNoFileChanges()
95 {
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithFileChanges/.baseline-data/A.txt new
+1
@@ -0,0 +1 @@
1 +This is A v1.0.0
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithFileChanges/.update-data/A.txt new
+1
@@ -0,0 +1 @@
1 +This is A v1.0.1
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithFileChanges/Package.wxs new
+27
@@ -0,0 +1,27 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Package Name="~Test Package" Version="$(V)" Manufacturer="Example Corporation" Language="1033" UpgradeCode="7d326855-e790-4a94-8611-5351f8321fca" Compressed="yes" Scope="perMachine" ProductCode="7d326855-e790-4a94-8611-5351f8321fca">
3 +
4 + <MajorUpgrade DowngradeErrorMessage="Newer version already installed." />
5 + <MediaTemplate EmbedCab="yes" />
6 +
7 + <StandardDirectory Id="ProgramFilesFolder">
8 + <Directory Id="INSTALLFOLDER" Name="~Test App" />
9 + </StandardDirectory>
10 +
11 + <Feature Id="Main">
12 + <ComponentGroupRef Id="Components" />
13 + </Feature>
14 + </Package>
15 +
16 + <Fragment>
17 + <ComponentGroup Id="Components" Directory="INSTALLFOLDER">
18 + <Component>
19 + <File Id="a.txt" Name="a.txt" Source="A.txt" />
20 + </Component>
21 +
22 + <Component>
23 + <RegistryValue Root="HKLM" Key="SOFTWARE\!(bind.property.ProductName)\Patch" Name="Version" Value="$(V)" />
24 + </Component>
25 + </ComponentGroup>
26 + </Fragment>
27 +</Wix>
src/wix/test/WixToolsetTest.CoreIntegration/TestData/PatchWithFileChanges/Patch.wxs new
+16
@@ -0,0 +1,16 @@
1 +<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
2 + <Patch
3 + AllowRemoval="yes"
4 + DisplayName="~Test Patch v$(V)"
5 + Description="~Test Small Update Patch v$(V)"
6 + MoreInfoURL="http://www.example.com/"
7 + Manufacturer="Example Corporation"
8 + Classification="Update">
9 +
10 + <Media Id="1" Cabinet="foo.cab">
11 + <PatchBaseline Id="RTM" BaselineFile="Baseline.wixpdb" UpdateFile="Update.wixpdb" />
12 + </Media>
13 +
14 + <PatchFamily Id='SequenceFamily' Version='$(V)' />
15 + </Patch>
16 +</Wix>