diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-02-28 21:05:49 -0600 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-03-02 15:50:47 -0600 |
commit | 8b3488c8c77959f425d0e5f70d27c5b2b1c86125 (patch) | |
tree | 827dfa7caba09d7fa032c317505a590bb834c4e6 /src/test | |
parent | a6013a643208a8d1fc2d1136ef8d3a6c3e909522 (diff) | |
download | wix-8b3488c8c77959f425d0e5f70d27c5b2b1c86125.tar.gz wix-8b3488c8c77959f425d0e5f70d27c5b2b1c86125.tar.bz2 wix-8b3488c8c77959f425d0e5f70d27c5b2b1c86125.zip |
Use new PackagePayload symbols for the package's payload.
#4183
Diffstat (limited to 'src/test')
9 files changed, 291 insertions, 5 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/PackagePayloadFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PackagePayloadFixture.cs new file mode 100644 index 00000000..77a21f61 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/PackagePayloadFixture.cs | |||
@@ -0,0 +1,207 @@ | |||
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 | |||
3 | namespace WixToolsetTest.CoreIntegration | ||
4 | { | ||
5 | using System.Collections.Generic; | ||
6 | using System.IO; | ||
7 | using System.Linq; | ||
8 | using WixBuildTools.TestSupport; | ||
9 | using WixToolset.Core.TestPackage; | ||
10 | using Xunit; | ||
11 | |||
12 | public class PackagePayloadFixture | ||
13 | { | ||
14 | [Fact] | ||
15 | public void CanSpecifyPackagePayloadInPayloadGroup() | ||
16 | { | ||
17 | var folder = TestData.Get(@"TestData"); | ||
18 | |||
19 | using (var fs = new DisposableFileSystem()) | ||
20 | { | ||
21 | var baseFolder = fs.GetFolder(); | ||
22 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
23 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); | ||
24 | var baFolderPath = Path.Combine(baseFolder, "ba"); | ||
25 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | ||
26 | |||
27 | var result = WixRunner.Execute(new[] | ||
28 | { | ||
29 | "build", | ||
30 | Path.Combine(folder, "PackagePayload", "PackagePayloadInPayloadGroup.wxs"), | ||
31 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), | ||
32 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | ||
33 | "-bindpath", Path.Combine(folder, ".Data"), | ||
34 | "-intermediateFolder", intermediateFolder, | ||
35 | "-o", bundlePath, | ||
36 | }); | ||
37 | |||
38 | result.AssertSuccess(); | ||
39 | |||
40 | Assert.True(File.Exists(bundlePath)); | ||
41 | |||
42 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); | ||
43 | extractResult.AssertSuccess(); | ||
44 | |||
45 | var exePackageElements = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Chain/burn:ExePackage"); | ||
46 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> | ||
47 | { | ||
48 | { "ExePackage", new List<string> { "CacheId", "InstallSize", "Size" } }, | ||
49 | }; | ||
50 | Assert.Equal(1, exePackageElements.Count); | ||
51 | Assert.Equal("<ExePackage Id='PackagePayloadInPayloadGroup' Cache='yes' CacheId='*' InstallSize='*' Size='*' PerMachine='yes' Permanent='yes' Vital='yes' RollbackBoundaryForward='WixDefaultBoundary' RollbackBoundaryBackward='WixDefaultBoundary' LogPathVariable='WixBundleLog_PackagePayloadInPayloadGroup' RollbackLogPathVariable='WixBundleRollbackLog_PackagePayloadInPayloadGroup' DetectCondition='none' InstallArguments='' UninstallArguments='' RepairArguments='' Repairable='no'><PayloadRef Id='burn.exe' /></ExePackage>", exePackageElements[0].GetTestXml(ignoreAttributesByElementName)); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | [Fact] | ||
56 | public void ErrorWhenMissingSourceFileAndHash() | ||
57 | { | ||
58 | var folder = TestData.Get(@"TestData", "PackagePayload"); | ||
59 | |||
60 | using (var fs = new DisposableFileSystem()) | ||
61 | { | ||
62 | var baseFolder = fs.GetFolder(); | ||
63 | |||
64 | var result = WixRunner.Execute(false, new[] | ||
65 | { | ||
66 | "build", | ||
67 | Path.Combine(folder, "MissingSourceFileAndHash.wxs"), | ||
68 | "-o", Path.Combine(baseFolder, "test.wixlib") | ||
69 | }); | ||
70 | |||
71 | Assert.Equal(44, result.ExitCode); | ||
72 | WixAssert.CompareLineByLine(new[] | ||
73 | { | ||
74 | "The MsuPackagePayload element's SourceFile or Hash attribute was not found; one of these is required.", | ||
75 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | [Fact] | ||
80 | public void ErrorWhenMissingSourceFileAndName() | ||
81 | { | ||
82 | var folder = TestData.Get(@"TestData", "PackagePayload"); | ||
83 | |||
84 | using (var fs = new DisposableFileSystem()) | ||
85 | { | ||
86 | var baseFolder = fs.GetFolder(); | ||
87 | |||
88 | var result = WixRunner.Execute(false, new[] | ||
89 | { | ||
90 | "build", | ||
91 | Path.Combine(folder, "MissingSourceFileAndName.wxs"), | ||
92 | "-o", Path.Combine(baseFolder, "test.wixlib") | ||
93 | }); | ||
94 | |||
95 | Assert.Equal(44, result.ExitCode); | ||
96 | WixAssert.CompareLineByLine(new[] | ||
97 | { | ||
98 | "The MsiPackagePayload element's Name or SourceFile attribute was not found; one of these is required.", | ||
99 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | [Fact] | ||
104 | public void ErrorWhenSpecifiedHash() | ||
105 | { | ||
106 | var folder = TestData.Get(@"TestData", "PackagePayload"); | ||
107 | |||
108 | using (var fs = new DisposableFileSystem()) | ||
109 | { | ||
110 | var baseFolder = fs.GetFolder(); | ||
111 | |||
112 | var result = WixRunner.Execute(new[] | ||
113 | { | ||
114 | "build", | ||
115 | Path.Combine(folder, "SpecifiedHash.wxs"), | ||
116 | "-o", Path.Combine(baseFolder, "test.wixlib") | ||
117 | }); | ||
118 | |||
119 | Assert.Equal(4, result.ExitCode); | ||
120 | WixAssert.CompareLineByLine(new[] | ||
121 | { | ||
122 | "The MspPackagePayload element contains an unexpected attribute 'Hash'.", | ||
123 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | [Fact] | ||
128 | public void ErrorWhenSpecifiedHashAndMissingDownloadUrl() | ||
129 | { | ||
130 | var folder = TestData.Get(@"TestData", "PackagePayload"); | ||
131 | |||
132 | using (var fs = new DisposableFileSystem()) | ||
133 | { | ||
134 | var baseFolder = fs.GetFolder(); | ||
135 | |||
136 | var result = WixRunner.Execute(new[] | ||
137 | { | ||
138 | "build", | ||
139 | Path.Combine(folder, "SpecifiedHashAndMissingDownloadUrl.wxs"), | ||
140 | "-o", Path.Combine(baseFolder, "test.wixlib") | ||
141 | }); | ||
142 | |||
143 | Assert.Equal(10, result.ExitCode); | ||
144 | WixAssert.CompareLineByLine(new[] | ||
145 | { | ||
146 | "The MsuPackagePayload/@DownloadUrl attribute was not found; it is required when attribute Hash is specified.", | ||
147 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | [Fact] | ||
152 | public void ErrorWhenSpecifiedSourceFileAndHash() | ||
153 | { | ||
154 | var folder = TestData.Get(@"TestData", "PackagePayload"); | ||
155 | |||
156 | using (var fs = new DisposableFileSystem()) | ||
157 | { | ||
158 | var baseFolder = fs.GetFolder(); | ||
159 | |||
160 | var result = WixRunner.Execute(new[] | ||
161 | { | ||
162 | "build", | ||
163 | Path.Combine(folder, "SpecifiedSourceFileAndHash.wxs"), | ||
164 | "-o", Path.Combine(baseFolder, "test.wixlib") | ||
165 | }); | ||
166 | |||
167 | Assert.Equal(35, result.ExitCode); | ||
168 | WixAssert.CompareLineByLine(new[] | ||
169 | { | ||
170 | "The ExePackagePayload/@Hash attribute cannot be specified when attribute SourceFile is present.", | ||
171 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | [Fact] | ||
176 | public void ErrorWhenWrongPackagePayloadInPayloadGroup() | ||
177 | { | ||
178 | var folder = TestData.Get(@"TestData"); | ||
179 | |||
180 | using (var fs = new DisposableFileSystem()) | ||
181 | { | ||
182 | var baseFolder = fs.GetFolder(); | ||
183 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
184 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); | ||
185 | |||
186 | var result = WixRunner.Execute(new[] | ||
187 | { | ||
188 | "build", | ||
189 | Path.Combine(folder, "PackagePayload", "WrongPackagePayloadInPayloadGroup.wxs"), | ||
190 | Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), | ||
191 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | ||
192 | "-bindpath", Path.Combine(folder, ".Data"), | ||
193 | "-intermediateFolder", intermediateFolder, | ||
194 | "-o", bundlePath, | ||
195 | }); | ||
196 | |||
197 | Assert.Equal(407, result.ExitCode); | ||
198 | WixAssert.CompareLineByLine(new[] | ||
199 | { | ||
200 | "The ExePackagePayload element can only be used for ExePackages.", | ||
201 | "The location of the package related to previous error.", | ||
202 | "There is no payload defined for package 'WrongPackagePayloadInPayloadGroup'. This is specified on the MsiPackage element or a child MsiPackagePayload element.", | ||
203 | }, result.Messages.Select(m => m.ToString()).ToArray()); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | } | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/MissingSourceFileAndHash.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/MissingSourceFileAndHash.wxs new file mode 100644 index 00000000..5e1b99ff --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/MissingSourceFileAndHash.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <MsuPackage Id="MissingSourceFileAndHash" Permanent="yes" DetectCondition="none"> | ||
6 | <MsuPackagePayload DownloadUrl="example.com" /> | ||
7 | </MsuPackage> | ||
8 | </PackageGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/MissingSourceFileAndName.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/MissingSourceFileAndName.wxs new file mode 100644 index 00000000..f220d81a --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/MissingSourceFileAndName.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <MsiPackage Id="MissingSourceFileAndName"> | ||
6 | <MsiPackagePayload DownloadUrl="example.com" /> | ||
7 | </MsiPackage> | ||
8 | </PackageGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/PackagePayloadInPayloadGroup.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/PackagePayloadInPayloadGroup.wxs new file mode 100644 index 00000000..149870a4 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/PackagePayloadInPayloadGroup.wxs | |||
@@ -0,0 +1,15 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <ExePackage Id="PackagePayloadInPayloadGroup" Permanent="yes" DetectCondition="none"> | ||
6 | <PayloadGroupRef Id="PackagePayloadGroup" /> | ||
7 | </ExePackage> | ||
8 | </PackageGroup> | ||
9 | </Fragment> | ||
10 | <Fragment> | ||
11 | <PayloadGroup Id="PackagePayloadGroup"> | ||
12 | <ExePackagePayload SourceFile="burn.exe" /> | ||
13 | </PayloadGroup> | ||
14 | </Fragment> | ||
15 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedHash.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedHash.wxs new file mode 100644 index 00000000..3c361c49 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedHash.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <MspPackage Id="SpecifiedHash"> | ||
6 | <MspPackagePayload SourceFile="example.msp" DownloadUrl="example.com" Hash="abcd" /> | ||
7 | </MspPackage> | ||
8 | </PackageGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedHashAndMissingDownloadUrl.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedHashAndMissingDownloadUrl.wxs new file mode 100644 index 00000000..8e62f660 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedHashAndMissingDownloadUrl.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <MsuPackage Id="SpecifiedHashAndMissingDownloadUrl" Permanent="yes" DetectCondition="none"> | ||
6 | <MsuPackagePayload Name="example.msu" Hash="abcd" Size="1" Version="1.0.0.0" ProductName="KB1234567" Description="fake msu" /> | ||
7 | </MsuPackage> | ||
8 | </PackageGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedSourceFileAndHash.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedSourceFileAndHash.wxs new file mode 100644 index 00000000..f79da874 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/SpecifiedSourceFileAndHash.wxs | |||
@@ -0,0 +1,10 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <ExePackage Id="SpecifiedSourceFileAndHash" Permanent="yes" DetectCondition="none"> | ||
6 | <ExePackagePayload SourceFile="example.exe" Hash="abcd" /> | ||
7 | </ExePackage> | ||
8 | </PackageGroup> | ||
9 | </Fragment> | ||
10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/WrongPackagePayloadInPayloadGroup.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/WrongPackagePayloadInPayloadGroup.wxs new file mode 100644 index 00000000..dda306cf --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/PackagePayload/WrongPackagePayloadInPayloadGroup.wxs | |||
@@ -0,0 +1,15 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <PackageGroup Id="BundlePackages"> | ||
5 | <MsiPackage Id="WrongPackagePayloadInPayloadGroup"> | ||
6 | <PayloadGroupRef Id="WrongPackagePayloadGroup" /> | ||
7 | </MsiPackage> | ||
8 | </PackageGroup> | ||
9 | </Fragment> | ||
10 | <Fragment> | ||
11 | <PayloadGroup Id="WrongPackagePayloadGroup"> | ||
12 | <ExePackagePayload SourceFile="burn.exe" /> | ||
13 | </PayloadGroup> | ||
14 | </Fragment> | ||
15 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleExeBundle/SingleExeRemotePayload.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleExeBundle/SingleExeRemotePayload.wxs index 79ba52d2..56f08ba9 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/SingleExeBundle/SingleExeRemotePayload.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/SingleExeBundle/SingleExeRemotePayload.wxs | |||
@@ -13,11 +13,10 @@ | |||
13 | Vital="yes" | 13 | Vital="yes" |
14 | Permanent="yes" | 14 | Permanent="yes" |
15 | Protocol="netfx4" | 15 | Protocol="netfx4" |
16 | DownloadUrl="C" | 16 | LogPathVariable="NetFx462FullLog"> |
17 | LogPathVariable="NetFx462FullLog" | 17 | <ExePackagePayload |
18 | Compressed="no" | 18 | DownloadUrl="C" |
19 | Name="NDP462-KB3151802-Web.exe"> | 19 | Name="NDP462-KB3151802-Web.exe" |
20 | <RemotePayload | ||
21 | Description="Microsoft .NET Framework 4.6.2 Setup" | 20 | Description="Microsoft .NET Framework 4.6.2 Setup" |
22 | Hash="C42E6ED280290648BBD59F664008852F4CFE4548" | 21 | Hash="C42E6ED280290648BBD59F664008852F4CFE4548" |
23 | ProductName="Microsoft .NET Framework 4.6.2" | 22 | ProductName="Microsoft .NET Framework 4.6.2" |