diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-03 17:48:57 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-07 19:44:36 -0500 |
commit | 648f370f7966b2738c1446601057d888bbd2c70f (patch) | |
tree | 9022566b1016f94127dfb7e84c9b4dfa057993cd /src/test | |
parent | 6b0f2d978504da82070523eb6adb0b59f9812e93 (diff) | |
download | wix-648f370f7966b2738c1446601057d888bbd2c70f.tar.gz wix-648f370f7966b2738c1446601057d888bbd2c70f.tar.bz2 wix-648f370f7966b2738c1446601057d888bbd2c70f.zip |
Make PathGetSystemPath return an array of paths ordered by preference.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/burn/WixTestTools/BundleVerifier.cs | 12 | ||||
-rw-r--r-- | src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs | 68 |
2 files changed, 78 insertions, 2 deletions
diff --git a/src/test/burn/WixTestTools/BundleVerifier.cs b/src/test/burn/WixTestTools/BundleVerifier.cs index 594b19aa..103171cd 100644 --- a/src/test/burn/WixTestTools/BundleVerifier.cs +++ b/src/test/burn/WixTestTools/BundleVerifier.cs | |||
@@ -15,7 +15,8 @@ namespace WixTestTools | |||
15 | public partial class BundleInstaller | 15 | public partial class BundleInstaller |
16 | { | 16 | { |
17 | public const string DependencyRegistryRoot = "Software\\Classes\\Installer\\Dependencies"; | 17 | public const string DependencyRegistryRoot = "Software\\Classes\\Installer\\Dependencies"; |
18 | public const string FULL_BURN_POLICY_REGISTRY_PATH = "SOFTWARE\\WOW6432Node\\Policies\\WiX\\Burn"; | 18 | public const string FULL_BURN_POLICY_REGISTRY_PATH = "SOFTWARE\\Policies\\WiX\\Burn"; |
19 | public const string FULL_BURN_POLICY_REGISTRY_PATH_WOW6432NODE = "SOFTWARE\\WOW6432Node\\Policies\\WiX\\Burn"; | ||
19 | public const string PACKAGE_CACHE_FOLDER_NAME = "Package Cache"; | 20 | public const string PACKAGE_CACHE_FOLDER_NAME = "Package Cache"; |
20 | 21 | ||
21 | public string BundlePdb { get; } | 22 | public string BundlePdb { get; } |
@@ -35,12 +36,19 @@ namespace WixTestTools | |||
35 | return this.BundleSymbol; | 36 | return this.BundleSymbol; |
36 | } | 37 | } |
37 | 38 | ||
39 | public string GetFullBurnPolicyRegistryPath() | ||
40 | { | ||
41 | var bundleSymbol = this.GetBundleSymbol(); | ||
42 | var x64 = bundleSymbol.Platform != Platform.X86; | ||
43 | return x64 ? FULL_BURN_POLICY_REGISTRY_PATH : FULL_BURN_POLICY_REGISTRY_PATH_WOW6432NODE; | ||
44 | } | ||
45 | |||
38 | public string GetPackageCachePathForCacheId(string cacheId, bool perMachine) | 46 | public string GetPackageCachePathForCacheId(string cacheId, bool perMachine) |
39 | { | 47 | { |
40 | string cachePath; | 48 | string cachePath; |
41 | if (perMachine) | 49 | if (perMachine) |
42 | { | 50 | { |
43 | using var policyKey = Registry.LocalMachine.OpenSubKey(FULL_BURN_POLICY_REGISTRY_PATH); | 51 | using var policyKey = Registry.LocalMachine.OpenSubKey(this.GetFullBurnPolicyRegistryPath()); |
44 | var redirectedCachePath = policyKey?.GetValue("PackageCache") as string; | 52 | var redirectedCachePath = policyKey?.GetValue("PackageCache") as string; |
45 | cachePath = redirectedCachePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), PACKAGE_CACHE_FOLDER_NAME); | 53 | cachePath = redirectedCachePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), PACKAGE_CACHE_FOLDER_NAME); |
46 | } | 54 | } |
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs index 6c8250d9..f5a1cda8 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs | |||
@@ -5,6 +5,7 @@ namespace WixToolsetTest.BurnE2E | |||
5 | using System; | 5 | using System; |
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using System.IO; | 7 | using System.IO; |
8 | using Microsoft.Win32; | ||
8 | using WixBuildTools.TestSupport; | 9 | using WixBuildTools.TestSupport; |
9 | using WixTestTools; | 10 | using WixTestTools; |
10 | using WixToolset.Mba.Core; | 11 | using WixToolset.Mba.Core; |
@@ -201,5 +202,72 @@ namespace WixToolsetTest.BurnE2E | |||
201 | packageB.VerifyInstalled(true); | 202 | packageB.VerifyInstalled(true); |
202 | } | 203 | } |
203 | } | 204 | } |
205 | |||
206 | [RuntimeFact] | ||
207 | public void CanGetEngineWorkingDirectoryFromCommandLine() | ||
208 | { | ||
209 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
210 | var testBAController = this.CreateTestBAController(); | ||
211 | |||
212 | testBAController.SetImmediatelyQuit(); | ||
213 | |||
214 | using (var dfs = new DisposableFileSystem()) | ||
215 | { | ||
216 | var baseTempPath = dfs.GetFolder(true); | ||
217 | var logPath = bundleA.Install(0, $"-burn.engine.working.directory=\"{baseTempPath}\""); | ||
218 | LogVerifier.MessageInLogFileRegex(logPath, $"Burn x86 v4.*, Windows v.* \\(Build .*: Service Pack .*\\), path: {baseTempPath.Replace("\\", "\\\\")}\\\\.*\\\\.cr\\\\BundleA.exe"); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | [RuntimeFact] | ||
223 | public void CanGetEngineWorkingDirectoryFromPolicy() | ||
224 | { | ||
225 | var deletePolicyKey = false; | ||
226 | string originalPolicyValue = null; | ||
227 | |||
228 | var bundleA = this.CreateBundleInstaller("BundleA"); | ||
229 | var testBAController = this.CreateTestBAController(); | ||
230 | var policyPath = bundleA.GetFullBurnPolicyRegistryPath(); | ||
231 | |||
232 | testBAController.SetImmediatelyQuit(); | ||
233 | |||
234 | try | ||
235 | { | ||
236 | using (var dfs = new DisposableFileSystem()) | ||
237 | { | ||
238 | var baseTempPath = dfs.GetFolder(true); | ||
239 | |||
240 | var policyKey = Registry.LocalMachine.OpenSubKey(policyPath, writable: true); | ||
241 | if (policyKey == null) | ||
242 | { | ||
243 | policyKey = Registry.LocalMachine.CreateSubKey(policyPath, writable: true); | ||
244 | deletePolicyKey = true; | ||
245 | } | ||
246 | |||
247 | using (policyKey) | ||
248 | { | ||
249 | originalPolicyValue = policyKey.GetValue("EngineWorkingDirectory") as string; | ||
250 | policyKey.SetValue("EngineWorkingDirectory", baseTempPath); | ||
251 | } | ||
252 | |||
253 | var logPath = bundleA.Install(); | ||
254 | LogVerifier.MessageInLogFileRegex(logPath, $"Burn x86 v4.*, Windows v.* \\(Build .*: Service Pack .*\\), path: {baseTempPath.Replace("\\", "\\\\")}\\\\.*\\\\.cr\\\\BundleA.exe"); | ||
255 | } | ||
256 | } | ||
257 | finally | ||
258 | { | ||
259 | if (deletePolicyKey) | ||
260 | { | ||
261 | Registry.LocalMachine.DeleteSubKeyTree(policyPath); | ||
262 | } | ||
263 | else if (originalPolicyValue != null) | ||
264 | { | ||
265 | using (var policyKey = Registry.LocalMachine.CreateSubKey(policyPath, writable: true)) | ||
266 | { | ||
267 | policyKey.SetValue("EngineWorkingDirectory", originalPolicyValue); | ||
268 | } | ||
269 | } | ||
270 | } | ||
271 | } | ||
204 | } | 272 | } |
205 | } | 273 | } |