1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
// 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.
namespace WixToolsetTest.BurnE2E
{
using System;
using System.IO;
using WixTestTools;
using Xunit;
using Xunit.Abstractions;
public class PrereqBaTests : BurnE2ETests
{
public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
const int E_PREREQBA_INFINITE_LOOP = -2_114_714_646;
/// <summary>
/// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
/// with an MSI package to represent the prerequisite package.
/// This verifies that:
/// The preqba doesn't infinitely try to install prereqs.
/// The engine automatically uninstalls the bundle since only permanent packages were installed.
/// </summary>
[RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
public void DncAlwaysPreqBaDetectsInfiniteLoop()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleC = this.CreateBundleInstaller("BundleC");
var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleC.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
// Part of the test is Install actually completing.
// Source file should be installed
Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
packageC.VerifyInstalled(false);
// No non-permanent packages should have ended up installed or cached so it should have unregistered.
bundleC.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// <summary>
/// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
/// with an MSI package to represent the prerequisite package.
/// This verifies that:
/// The preqba doesn't infinitely reload itself after failing to load the managed BA.
/// The engine automatically uninstalls the bundle since only permanent packages were installed.
/// </summary>
[RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
public void DncPreqBaDetectsInfiniteLoop()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleA = this.CreateBundleInstaller("BundleA");
var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleA.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
// Part of the test is Install actually completing.
// Source file should be installed
Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
packageC.VerifyInstalled(false);
// No non-permanent packages should have ended up installed or cached so it should have unregistered.
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// <summary>
/// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
/// with an EXE prereq package to swap it out with a good one.
/// This verifies that:
/// The preqba doesn't infinitely try to install prereqs.
/// The managed BA gets loaded after installing prereqs.
/// </summary>
[RuntimeFact]
public void DncAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleC = this.CreateBundleInstaller("BundleC");
var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleC.Install();
// Source file should be installed
Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleC.VerifyRegisteredAndInPackageCache();
bundleC.Uninstall();
bundleC.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// <summary>
/// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist,
/// with an EXE prereq package to swap it out with a good one.
/// This verifies that:
/// The preqba doesn't infinitely reload itself after failing to load the managed BA.
/// The managed BA gets loaded after installing prereqs.
/// </summary>
[RuntimeFact]
public void DncPreqBaLoadsManagedBaAfterInstallingPrereqs()
{
var packageA = this.CreatePackageInstaller("PackageA");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleA = this.CreateBundleInstaller("BundleA");
var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleA.Install();
// Source file should be installed
Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleA.VerifyRegisteredAndInPackageCache();
bundleA.Uninstall();
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
}
[RuntimeFact]
public void DncAlwaysPreqBaForwardsHelpToManagedBa()
{
var bundleE = this.CreateBundleInstaller("BundleE");
var bundleLog = bundleE.Help();
Assert.True(LogVerifier.MessageInLogFile(bundleLog, "This is a BA for automated testing"));
}
/// <summary>
/// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
/// with an MSI package to represent the prerequisite package.
/// This verifies that:
/// The preqba doesn't infinitely try to install prereqs.
/// The engine automatically uninstalls the bundle since only permanent packages were installed.
/// </summary>
[RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
public void MbaAlwaysPreqBaDetectsInfiniteLoop()
{
var packageB = this.CreatePackageInstaller("PackageB");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleD = this.CreateBundleInstaller("BundleD");
var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleD.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
// Part of the test is Install actually completing.
// Source file should be installed
Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
packageC.VerifyInstalled(false);
// No non-permanent packages should have ended up installed or cached so it should have unregistered.
bundleD.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// <summary>
/// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
/// with an MSI package to represent the prerequisite package.
/// This verifies that:
/// The preqba doesn't infinitely reload itself after failing to load the managed BA.
/// The engine automatically uninstalls the bundle since only permanent packages were installed.
/// </summary>
[RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")]
public void MbaPreqBaDetectsInfiniteLoop()
{
var packageB = this.CreatePackageInstaller("PackageB");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleB = this.CreateBundleInstaller("BundleB");
var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleB.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1");
// Part of the test is Install actually completing.
// Source file should be installed
Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
packageC.VerifyInstalled(false);
// No non-permanent packages should have ended up installed or cached so it should have unregistered.
bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// <summary>
/// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
/// with an EXE prereq package to swap it out with a good one.
/// This verifies that:
/// The preqba doesn't infinitely try to install prereqs.
/// The managed BA gets loaded after installing prereqs.
/// </summary>
[RuntimeFact]
public void MbaAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs()
{
var packageB = this.CreatePackageInstaller("PackageB");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleD = this.CreateBundleInstaller("BundleD");
var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleD.Install();
// Source file should be installed
Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleD.VerifyRegisteredAndInPackageCache();
bundleD.Uninstall();
bundleD.VerifyUnregisteredAndRemovedFromPackageCache();
}
/// <summary>
/// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist,
/// with an EXE prereq package to swap it out with a good one.
/// This verifies that:
/// The preqba doesn't infinitely reload itself after failing to load the managed BA.
/// The managed BA gets loaded after installing prereqs.
/// </summary>
[RuntimeFact]
public void MbaPreqBaLoadsManagedBaAfterInstallingPrereqs()
{
var packageB = this.CreatePackageInstaller("PackageB");
var packageC = this.CreatePackageInstaller("PackageC");
var bundleB = this.CreateBundleInstaller("BundleB");
var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs");
// Source file should *not* be installed
Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}");
packageC.VerifyInstalled(false);
bundleB.Install();
// Source file should be installed
Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled));
packageC.VerifyInstalled(true);
bundleB.VerifyRegisteredAndInPackageCache();
bundleB.Uninstall();
// No non-permanent packages should have ended up installed or cached so it should have unregistered.
bundleB.VerifyUnregisteredAndRemovedFromPackageCache();
}
}
}
|