aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2020-01-24 15:27:20 -0800
committerRob Mensching <rob@firegiant.com>2020-02-05 16:15:47 -0800
commit6ff680e386b1543ad1a58d1b1d465ce8aa20bc7d (patch)
treec717333cd10d5592e59dfb898b391275bba1f389 /src/test
parent6e2e67ab55c75f4655397588c0dcc64f50d22f92 (diff)
downloadwix-6ff680e386b1543ad1a58d1b1d465ce8aa20bc7d.tar.gz
wix-6ff680e386b1543ad1a58d1b1d465ce8aa20bc7d.tar.bz2
wix-6ff680e386b1543ad1a58d1b1d465ce8aa20bc7d.zip
Start on new patch infrastructure
Diffstat (limited to 'src/test')
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs112
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs28
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.0.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.1.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.0.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.1.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs31
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Patch.wxs23
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.0.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.1.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.0.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.1.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Package.wxs31
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Patch.wxs16
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj14
15 files changed, 234 insertions, 29 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
new file mode 100644
index 00000000..584f86fe
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/PatchFixture.cs
@@ -0,0 +1,112 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolsetTest.CoreIntegration
4{
5 using System.ComponentModel;
6 using System.IO;
7 using System.Linq;
8 using System.Runtime.InteropServices;
9 using System.Text;
10 using System.Xml.Linq;
11 using WixBuildTools.TestSupport;
12 using WixToolset.Core.TestPackage;
13 using Xunit;
14
15 public class PatchFixture
16 {
17 private static readonly XNamespace PatchNamespace = "http://www.microsoft.com/msi/patch_applicability.xsd";
18
19 [Fact(Skip = "Skip until patches have files in them")]
20 public void CanBuildSimplePatch()
21 {
22 var folder = TestData.Get(@"TestData\PatchSingle");
23
24 using (var fs = new DisposableFileSystem())
25 {
26 var tempFolder = fs.GetFolder();
27
28 var baselinePdb = BuildMsi("Baseline.msi", folder, tempFolder, "1.0.0", "1.0.0", "1.0.0");
29 var update1Pdb = BuildMsi("Update.msi", folder, tempFolder, "1.0.1", "1.0.1", "1.0.1");
30 var patchPdb = BuildMsp("Patch1.msp", folder, tempFolder, "1.0.1");
31 var baselinePath = Path.ChangeExtension(baselinePdb, ".msp");
32 var patchPath = Path.ChangeExtension(patchPdb, ".msp");
33
34 Assert.True(File.Exists(baselinePdb));
35 Assert.True(File.Exists(update1Pdb));
36
37 var doc = GetExtractPatchXml(patchPath);
38 Assert.Equal("{7D326855-E790-4A94-8611-5351F8321FCA}", doc.Root.Element(PatchNamespace + "TargetProductCode").Value);
39
40 var names = Query.GetSubStorageNames(patchPath);
41 Assert.Equal(new[] { "#RTM.1", "RTM.1" }, names);
42
43 var cab = Path.Combine(tempFolder, "foo.cab");
44 Query.ExtractStream(patchPath, "foo.cab", cab);
45 Assert.True(File.Exists(cab));
46
47 var files = Query.GetCabinetFiles(cab);
48 Assert.Equal(new[] { "a", "b" }, files.Select(f => f.ArchiveName).ToArray()); // This test may not be quite correct, yet.
49 }
50 }
51
52 private static string BuildMsi(string outputName, string sourceFolder, string baseFolder, string defineV, string defineA, string defineB)
53 {
54 var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
55
56 var result = WixRunner.Execute(new[]
57 {
58 "build",
59 Path.Combine(sourceFolder, @"Package.wxs"),
60 "-d", "V=" + defineV,
61 "-d", "A=" + defineA,
62 "-d", "B=" + defineB,
63 "-bindpath", Path.Combine(sourceFolder, ".data"),
64 "-intermediateFolder", Path.Combine(baseFolder, "obj"),
65 "-o", outputPath
66 });
67
68 result.AssertSuccess();
69
70 return Path.ChangeExtension(outputPath, ".wixpdb");
71 }
72
73 private static string BuildMsp(string outputName, string sourceFolder, string baseFolder, string defineV)
74 {
75 var outputPath = Path.Combine(baseFolder, Path.Combine("bin", outputName));
76
77 var result = WixRunner.Execute(new[]
78 {
79 "build",
80 Path.Combine(sourceFolder, @"Patch.wxs"),
81 "-d", "V=" + defineV,
82 "-bindpath", Path.Combine(baseFolder, "bin"),
83 "-intermediateFolder", Path.Combine(baseFolder, "obj"),
84 "-o", outputPath
85 });
86
87 result.AssertSuccess();
88
89 return Path.ChangeExtension(outputPath, ".wixpdb");
90 }
91
92 private static XDocument GetExtractPatchXml(string path)
93 {
94 var buffer = new StringBuilder(65535);
95 var size = buffer.Capacity;
96
97 var er = MsiExtractPatchXMLData(path, 0, buffer, ref size);
98 if (er != 0)
99 {
100 throw new Win32Exception(er);
101 }
102
103 return XDocument.Parse(buffer.ToString());
104 }
105
106 [DllImport("msi.dll", EntryPoint = "MsiExtractPatchXMLDataW", CharSet = CharSet.Unicode, ExactSpelling = true)]
107 private static extern int MsiExtractPatchXMLData(string szPatchPath, int dwReserved, StringBuilder szXMLData, ref int pcchXMLData);
108
109 [DllImport("msi.dll", EntryPoint = "MsiApplyPatchW", CharSet = CharSet.Unicode, ExactSpelling = true)]
110 private static extern int MsiApplyPatch(string szPatchPackage, string szInstallPackage, int eInstallType, string szCommandLine);
111 }
112}
diff --git a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs
index 4e48cbe1..b1a4c607 100644
--- a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs
@@ -68,34 +68,6 @@ namespace WixToolsetTest.CoreIntegration
68 } 68 }
69 69
70 [Fact] 70 [Fact]
71 public void WixVersionVariablesWork()
72 {
73 var folder = TestData.Get(@"TestData\Variables");
74
75 using (var fs = new DisposableFileSystem())
76 {
77 var baseFolder = fs.GetFolder();
78 var intermediateFolder = Path.Combine(baseFolder, "obj");
79
80 var result = WixRunner.Execute(new[]
81 {
82 "build",
83 Path.Combine(folder, "Package.wxs"),
84 Path.Combine(folder, "PackageComponents.wxs"),
85 "-loc", Path.Combine(folder, "Package.en-us.wxl"),
86 "-bindpath", Path.Combine(folder, "data"),
87 "-intermediateFolder", intermediateFolder,
88 "-o", Path.Combine(baseFolder, @"bin\test.msi")
89 });
90
91 result.AssertSuccess();
92
93 var warning = result.Messages.Where(message => message.Id == (int)WarningMessages.Ids.PreprocessorWarning);
94 Assert.Single(warning);
95 }
96 }
97
98 [Fact]
99 public void ForEachLoopsWork() 71 public void ForEachLoopsWork()
100 { 72 {
101 var folder = TestData.Get(@"TestData\ForEach"); 73 var folder = TestData.Get(@"TestData\ForEach");
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.0.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.0.txt
new file mode 100644
index 00000000..6fd385bd
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.0.txt
@@ -0,0 +1 @@
This is A v1.0.0
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.1.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.1.txt
new file mode 100644
index 00000000..b1f0bc01
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Av1.0.1.txt
@@ -0,0 +1 @@
This ia A v1.0.1
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.0.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.0.txt
new file mode 100644
index 00000000..ece55fec
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.0.txt
@@ -0,0 +1 @@
This is B v1.0.0
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.1.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.1.txt
new file mode 100644
index 00000000..cf3372fd
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/.data/Bv1.0.1.txt
@@ -0,0 +1 @@
This ia B v1.0.1
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs
new file mode 100644
index 00000000..2657797f
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Package.wxs
@@ -0,0 +1,31 @@
1<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
2 <Product Id='e703bf17-4765-444c-91fd-88550fa681d4' Name='~Test Package'
3 Version='$(var.V)' Manufacturer='Example Corporation' Language='1033'
4 UpgradeCode='e703bf17-4765-444c-91fd-88550fa681d4'>
5 <Package InstallScope='perMachine' />
6
7 <MajorUpgrade DowngradeErrorMessage='Newer version already installed.' />
8 <MediaTemplate />
9
10 <Directory Id='TARGETDIR' Name='SourceDir'>
11 <Directory Id='ProgramFilesFolder'>
12 <Directory Id='INSTALLFOLDER' Name='~Test App' />
13 </Directory>
14 </Directory>
15
16 <Feature Id='Main'>
17 <ComponentGroupRef Id='Components' />
18 </Feature>
19 </Product>
20
21 <Fragment>
22 <ComponentGroup Id="Components" Directory='INSTALLFOLDER'>
23 <Component Id='A'>
24 <File Name='a.txt' Source='Av$(var.A).txt' />
25 </Component>
26 <Component Id='B'>
27 <File Name='b.txt' Source='Bv$(var.B).txt' />
28 </Component>
29 </ComponentGroup>
30 </Fragment>
31</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Patch.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Patch.wxs
new file mode 100644
index 00000000..7c3cff7e
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchFamilyFilter/Patch.wxs
@@ -0,0 +1,23 @@
1<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
2 <Patch
3 AllowRemoval="yes"
4 Manufacturer="FireGiant"
5 MoreInfoURL="http://www.example.com/"
6 DisplayName="~Test Patch v$(var.V)"
7 Description="~Test Small Update Patch v($var.V)"
8 Classification="Update"
9 >
10
11 <Media Id="1" Cabinet="foo.cab">
12 <PatchBaseline Id="RTM"/>
13 </Media>
14
15 <PatchFamilyRef Id='SamplePatchFamily'/>
16 </Patch>
17
18 <Fragment>
19 <PatchFamily Id='SamplePatchFamily' Version='$(var.V)' Supersede='yes'>
20 <ComponentRef Id="A"/>
21 </PatchFamily>
22 </Fragment>
23</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.0.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.0.txt
new file mode 100644
index 00000000..6fd385bd
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.0.txt
@@ -0,0 +1 @@
This is A v1.0.0
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.1.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.1.txt
new file mode 100644
index 00000000..b1f0bc01
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Av1.0.1.txt
@@ -0,0 +1 @@
This ia A v1.0.1
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.0.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.0.txt
new file mode 100644
index 00000000..ece55fec
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.0.txt
@@ -0,0 +1 @@
This is B v1.0.0
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.1.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.1.txt
new file mode 100644
index 00000000..cf3372fd
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/.data/Bv1.0.1.txt
@@ -0,0 +1 @@
This ia B v1.0.1
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Package.wxs
new file mode 100644
index 00000000..ee133ba3
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Package.wxs
@@ -0,0 +1,31 @@
1<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
2 <Product Id='7d326855-e790-4a94-8611-5351f8321fca' Name='~Test Package'
3 Version='$(var.V)' Manufacturer='Example Corporation' Language='1033'
4 UpgradeCode='7d326855-e790-4a94-8611-5351f8321fca'>
5 <Package InstallScope='perMachine' Compressed='yes' />
6
7 <MajorUpgrade DowngradeErrorMessage='Newer version already installed.' />
8 <MediaTemplate EmbedCab='yes' />
9
10 <Directory Id='TARGETDIR' Name='SourceDir'>
11 <Directory Id='ProgramFilesFolder'>
12 <Directory Id='INSTALLFOLDER' Name='~Test App' />
13 </Directory>
14 </Directory>
15
16 <Feature Id='Main'>
17 <ComponentGroupRef Id='Components' />
18 </Feature>
19 </Product>
20
21 <Fragment>
22 <ComponentGroup Id="Components" Directory='INSTALLFOLDER'>
23 <Component>
24 <File Id='a.txt' Name='a.txt' Source='Av$(var.A).txt' />
25 </Component>
26 <Component>
27 <File Id='b.txt' Name='b.txt' Source='Bv$(var.B).txt' />
28 </Component>
29 </ComponentGroup>
30 </Fragment>
31</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Patch.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Patch.wxs
new file mode 100644
index 00000000..52e87f64
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PatchSingle/Patch.wxs
@@ -0,0 +1,16 @@
1<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
2 <Patch
3 AllowRemoval="yes"
4 DisplayName="~Test Patch v$(var.V)"
5 Description="~Test Small Update Patch v$(var.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='$(var.V)' />
15 </Patch>
16</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
index 0330adf6..b17a27ff 100644
--- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
@@ -1,4 +1,4 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> 2<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3 3
4<Project Sdk="Microsoft.NET.Sdk"> 4<Project Sdk="Microsoft.NET.Sdk">
@@ -41,6 +41,18 @@
41 <Content Include="TestData\Font\TrueType.wxs" CopyToOutputDirectory="PreserveNewest" /> 41 <Content Include="TestData\Font\TrueType.wxs" CopyToOutputDirectory="PreserveNewest" />
42 <Content Include="TestData\Icon\SampleIcon.wxs" CopyToOutputDirectory="PreserveNewest" /> 42 <Content Include="TestData\Icon\SampleIcon.wxs" CopyToOutputDirectory="PreserveNewest" />
43 <Content Include="TestData\LockPermissions\EmptyPermissions.wxs" CopyToOutputDirectory="PreserveNewest" /> 43 <Content Include="TestData\LockPermissions\EmptyPermissions.wxs" CopyToOutputDirectory="PreserveNewest" />
44 <Content Include="TestData\PatchFamilyFilter\.data\Av1.0.0.txt" CopyToOutputDirectory="PreserveNewest" />
45 <Content Include="TestData\PatchFamilyFilter\.data\Av1.0.1.txt" CopyToOutputDirectory="PreserveNewest" />
46 <Content Include="TestData\PatchFamilyFilter\.data\Bv1.0.0.txt" CopyToOutputDirectory="PreserveNewest" />
47 <Content Include="TestData\PatchFamilyFilter\.data\Bv1.0.1.txt" CopyToOutputDirectory="PreserveNewest" />
48 <Content Include="TestData\PatchFamilyFilter\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
49 <Content Include="TestData\PatchFamilyFilter\Patch.wxs" CopyToOutputDirectory="PreserveNewest" />
50 <Content Include="TestData\PatchSingle\.data\Av1.0.0.txt" CopyToOutputDirectory="PreserveNewest" />
51 <Content Include="TestData\PatchSingle\.data\Av1.0.1.txt" CopyToOutputDirectory="PreserveNewest" />
52 <Content Include="TestData\PatchSingle\.data\Bv1.0.0.txt" CopyToOutputDirectory="PreserveNewest" />
53 <Content Include="TestData\PatchSingle\.data\Bv1.0.1.txt" CopyToOutputDirectory="PreserveNewest" />
54 <Content Include="TestData\PatchSingle\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
55 <Content Include="TestData\PatchSingle\Patch.wxs" CopyToOutputDirectory="PreserveNewest" />
44 <Content Include="TestData\SameFileFolders\data\a\test.txt" CopyToOutputDirectory="PreserveNewest" /> 56 <Content Include="TestData\SameFileFolders\data\a\test.txt" CopyToOutputDirectory="PreserveNewest" />
45 <Content Include="TestData\SameFileFolders\data\c\test.txt" CopyToOutputDirectory="PreserveNewest" /> 57 <Content Include="TestData\SameFileFolders\data\c\test.txt" CopyToOutputDirectory="PreserveNewest" />
46 <Content Include="TestData\SameFileFolders\data\b\test.txt" CopyToOutputDirectory="PreserveNewest" /> 58 <Content Include="TestData\SameFileFolders\data\b\test.txt" CopyToOutputDirectory="PreserveNewest" />