diff options
author | Rob Mensching <rob@firegiant.com> | 2022-02-04 07:29:16 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-02-04 08:11:58 -0800 |
commit | d38946ac8357d9d4f25a157571f8f8d5500f663f (patch) | |
tree | cc86b487395e69599126c0b6c94a619655e61a70 | |
parent | 3a9a2a4a1a009ac6ee7a4e15c5fe85d04a115650 (diff) | |
download | wix-d38946ac8357d9d4f25a157571f8f8d5500f663f.tar.gz wix-d38946ac8357d9d4f25a157571f8f8d5500f663f.tar.bz2 wix-d38946ac8357d9d4f25a157571f8f8d5500f663f.zip |
Ensure Class element without Context does not crash compiler
3 files changed, 126 insertions, 71 deletions
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs new file mode 100644 index 00000000..4aeabc82 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs | |||
@@ -0,0 +1,114 @@ | |||
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.IO; | ||
6 | using WixBuildTools.TestSupport; | ||
7 | using WixToolset.Core.TestPackage; | ||
8 | using Xunit; | ||
9 | |||
10 | public class ClassFixture | ||
11 | { | ||
12 | [Fact] | ||
13 | public void ClassWithoutContextDoesNotCrash() | ||
14 | { | ||
15 | var folder = TestData.Get(@"TestData"); | ||
16 | |||
17 | using (var fs = new DisposableFileSystem()) | ||
18 | { | ||
19 | var baseFolder = fs.GetFolder(); | ||
20 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
21 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
22 | |||
23 | var result = WixRunner.Execute(new[] | ||
24 | { | ||
25 | "build", | ||
26 | Path.Combine(folder, "Class", "ClassWithoutContext.wxs"), | ||
27 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
28 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
29 | "-bindpath", Path.Combine(folder, ".Data"), | ||
30 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
31 | "-intermediateFolder", intermediateFolder, | ||
32 | "-o", msiPath | ||
33 | }); | ||
34 | |||
35 | result.AssertSuccess(); | ||
36 | |||
37 | var results = Query.QueryDatabase(msiPath, new[] { "Class", "Registry" }); | ||
38 | Assert.Empty(results); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | [Fact] | ||
43 | public void PopulatesClassTablesWhenIconIndexIsZero() | ||
44 | { | ||
45 | var folder = TestData.Get(@"TestData"); | ||
46 | |||
47 | using (var fs = new DisposableFileSystem()) | ||
48 | { | ||
49 | var baseFolder = fs.GetFolder(); | ||
50 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
51 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
52 | |||
53 | var result = WixRunner.Execute(new[] | ||
54 | { | ||
55 | "build", | ||
56 | Path.Combine(folder, "Class", "IconIndex0.wxs"), | ||
57 | Path.Combine(folder, "Icon", "SampleIcon.wxs"), | ||
58 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
59 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
60 | "-bindpath", Path.Combine(folder, ".Data"), | ||
61 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
62 | "-intermediateFolder", intermediateFolder, | ||
63 | "-o", msiPath | ||
64 | }); | ||
65 | |||
66 | result.AssertSuccess(); | ||
67 | |||
68 | Assert.True(File.Exists(msiPath)); | ||
69 | var results = Query.QueryDatabase(msiPath, new[] { "Class" }); | ||
70 | WixAssert.CompareLineByLine(new[] | ||
71 | { | ||
72 | "Class:{3FAED4CC-C473-4B8A-BE8B-303871377A4A}\tLocalServer32\tClassComp\t\tFakeClass3FAE\t\t\tSampleIcon\t0\t\t\tProductFeature\t", | ||
73 | }, results); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | [Fact] | ||
78 | public void PopulatesClassTablesWhenProgIdIsNestedUnderAdvertisedClass() | ||
79 | { | ||
80 | var folder = TestData.Get(@"TestData"); | ||
81 | |||
82 | using (var fs = new DisposableFileSystem()) | ||
83 | { | ||
84 | var baseFolder = fs.GetFolder(); | ||
85 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
86 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
87 | |||
88 | var result = WixRunner.Execute(new[] | ||
89 | { | ||
90 | "build", | ||
91 | Path.Combine(folder, "ProgId", "NestedUnderClass.wxs"), | ||
92 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
93 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
94 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
95 | "-intermediateFolder", intermediateFolder, | ||
96 | "-o", msiPath | ||
97 | }); | ||
98 | |||
99 | result.AssertSuccess(); | ||
100 | |||
101 | Assert.True(File.Exists(msiPath)); | ||
102 | var results = Query.QueryDatabase(msiPath, new[] { "Class", "ProgId", "Registry" }); | ||
103 | WixAssert.CompareLineByLine(new[] | ||
104 | { | ||
105 | "Class:{F12A6F69-117F-471F-AE73-F8E74218F498}\tLocalServer32\tProgIdComp\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tFakeClassF12A\t\t\t\t\t\t\tProductFeature\t", | ||
106 | "ProgId:73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\t\t{F12A6F69-117F-471F-AE73-F8E74218F498}\tFakeClassF12A\t\t", | ||
107 | "Registry:regUIIK326nDZpkWHuexeF58EikQvA\t0\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tNoOpen\tNoOpen73E7\tProgIdComp", | ||
108 | "Registry:regvrhMurMp98anbQJkpgA8yJCefdM\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\Version\t\t0.0.0.1\tProgIdComp", | ||
109 | "Registry:regY1F4E2lvu_Up6gV6c3jeN5ukn8s\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\LocalServer32\tThreadingModel\tApartment\tProgIdComp", | ||
110 | }, results); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index 259c480c..7489bb47 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs | |||
@@ -220,77 +220,6 @@ namespace WixToolsetTest.CoreIntegration | |||
220 | } | 220 | } |
221 | 221 | ||
222 | [Fact] | 222 | [Fact] |
223 | public void PopulatesClassTablesWhenIconIndexIsZero() | ||
224 | { | ||
225 | var folder = TestData.Get(@"TestData"); | ||
226 | |||
227 | using (var fs = new DisposableFileSystem()) | ||
228 | { | ||
229 | var baseFolder = fs.GetFolder(); | ||
230 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
231 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
232 | |||
233 | var result = WixRunner.Execute(new[] | ||
234 | { | ||
235 | "build", | ||
236 | Path.Combine(folder, "Class", "IconIndex0.wxs"), | ||
237 | Path.Combine(folder, "Icon", "SampleIcon.wxs"), | ||
238 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
239 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
240 | "-bindpath", Path.Combine(folder, ".Data"), | ||
241 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
242 | "-intermediateFolder", intermediateFolder, | ||
243 | "-o", msiPath | ||
244 | }); | ||
245 | |||
246 | result.AssertSuccess(); | ||
247 | |||
248 | Assert.True(File.Exists(msiPath)); | ||
249 | var results = Query.QueryDatabase(msiPath, new[] { "Class" }); | ||
250 | WixAssert.CompareLineByLine(new[] | ||
251 | { | ||
252 | "Class:{3FAED4CC-C473-4B8A-BE8B-303871377A4A}\tLocalServer32\tClassComp\t\tFakeClass3FAE\t\t\tSampleIcon\t0\t\t\tProductFeature\t", | ||
253 | }, results); | ||
254 | } | ||
255 | } | ||
256 | |||
257 | [Fact] | ||
258 | public void PopulatesClassTablesWhenProgIdIsNestedUnderAdvertisedClass() | ||
259 | { | ||
260 | var folder = TestData.Get(@"TestData"); | ||
261 | |||
262 | using (var fs = new DisposableFileSystem()) | ||
263 | { | ||
264 | var baseFolder = fs.GetFolder(); | ||
265 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
266 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
267 | |||
268 | var result = WixRunner.Execute(new[] | ||
269 | { | ||
270 | "build", | ||
271 | Path.Combine(folder, "ProgId", "NestedUnderClass.wxs"), | ||
272 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
273 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
274 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
275 | "-intermediateFolder", intermediateFolder, | ||
276 | "-o", msiPath | ||
277 | }); | ||
278 | |||
279 | result.AssertSuccess(); | ||
280 | |||
281 | Assert.True(File.Exists(msiPath)); | ||
282 | var results = Query.QueryDatabase(msiPath, new[] { "Class", "ProgId", "Registry" }); | ||
283 | WixAssert.CompareLineByLine(new[] | ||
284 | { | ||
285 | "Class:{F12A6F69-117F-471F-AE73-F8E74218F498}\tLocalServer32\tProgIdComp\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tFakeClassF12A\t\t\t\t\t\t\tProductFeature\t", | ||
286 | "ProgId:73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\t\t{F12A6F69-117F-471F-AE73-F8E74218F498}\tFakeClassF12A\t\t", | ||
287 | "Registry:regUIIK326nDZpkWHuexeF58EikQvA\t0\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tNoOpen\tNoOpen73E7\tProgIdComp", | ||
288 | "Registry:regvrhMurMp98anbQJkpgA8yJCefdM\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\Version\t\t0.0.0.1\tProgIdComp", | ||
289 | "Registry:regY1F4E2lvu_Up6gV6c3jeN5ukn8s\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\LocalServer32\tThreadingModel\tApartment\tProgIdComp", | ||
290 | }, results); | ||
291 | } | ||
292 | } | ||
293 | [Fact] | ||
294 | public void PopulatesCreateFolderTableForNullKeypathComponents() | 223 | public void PopulatesCreateFolderTableForNullKeypathComponents() |
295 | { | 224 | { |
296 | var folder = TestData.Get(@"TestData\Components"); | 225 | var folder = TestData.Get(@"TestData\Components"); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Class/ClassWithoutContext.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Class/ClassWithoutContext.wxs new file mode 100644 index 00000000..a9e152a3 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Class/ClassWithoutContext.wxs | |||
@@ -0,0 +1,12 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
3 | <Fragment> | ||
4 | <ComponentGroup Id="ProductComponents"> | ||
5 | <Component Id="ClassComp" Directory="INSTALLFOLDER" Guid="9BFDA7DC-CA16-40B3-A6B5-961E60B30892"> | ||
6 | <File Source="test.txt" Name="ClassComp.txt"> | ||
7 | <Class Id="3FAED4CC-C473-4B8A-BE8B-303871377A4A" /> | ||
8 | </File> | ||
9 | </Component> | ||
10 | </ComponentGroup> | ||
11 | </Fragment> | ||
12 | </Wix> | ||