From 648f370f7966b2738c1446601057d888bbd2c70f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 3 Jun 2022 17:48:57 -0500 Subject: Make PathGetSystemPath return an array of paths ordered by preference. --- src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'src/test/burn/WixToolsetTest.BurnE2E/CacheTests.cs') 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 using System; using System.Collections.Generic; using System.IO; + using Microsoft.Win32; using WixBuildTools.TestSupport; using WixTestTools; using WixToolset.Mba.Core; @@ -201,5 +202,72 @@ namespace WixToolsetTest.BurnE2E packageB.VerifyInstalled(true); } } + + [RuntimeFact] + public void CanGetEngineWorkingDirectoryFromCommandLine() + { + var bundleA = this.CreateBundleInstaller("BundleA"); + var testBAController = this.CreateTestBAController(); + + testBAController.SetImmediatelyQuit(); + + using (var dfs = new DisposableFileSystem()) + { + var baseTempPath = dfs.GetFolder(true); + var logPath = bundleA.Install(0, $"-burn.engine.working.directory=\"{baseTempPath}\""); + LogVerifier.MessageInLogFileRegex(logPath, $"Burn x86 v4.*, Windows v.* \\(Build .*: Service Pack .*\\), path: {baseTempPath.Replace("\\", "\\\\")}\\\\.*\\\\.cr\\\\BundleA.exe"); + } + } + + [RuntimeFact] + public void CanGetEngineWorkingDirectoryFromPolicy() + { + var deletePolicyKey = false; + string originalPolicyValue = null; + + var bundleA = this.CreateBundleInstaller("BundleA"); + var testBAController = this.CreateTestBAController(); + var policyPath = bundleA.GetFullBurnPolicyRegistryPath(); + + testBAController.SetImmediatelyQuit(); + + try + { + using (var dfs = new DisposableFileSystem()) + { + var baseTempPath = dfs.GetFolder(true); + + var policyKey = Registry.LocalMachine.OpenSubKey(policyPath, writable: true); + if (policyKey == null) + { + policyKey = Registry.LocalMachine.CreateSubKey(policyPath, writable: true); + deletePolicyKey = true; + } + + using (policyKey) + { + originalPolicyValue = policyKey.GetValue("EngineWorkingDirectory") as string; + policyKey.SetValue("EngineWorkingDirectory", baseTempPath); + } + + var logPath = bundleA.Install(); + LogVerifier.MessageInLogFileRegex(logPath, $"Burn x86 v4.*, Windows v.* \\(Build .*: Service Pack .*\\), path: {baseTempPath.Replace("\\", "\\\\")}\\\\.*\\\\.cr\\\\BundleA.exe"); + } + } + finally + { + if (deletePolicyKey) + { + Registry.LocalMachine.DeleteSubKeyTree(policyPath); + } + else if (originalPolicyValue != null) + { + using (var policyKey = Registry.LocalMachine.CreateSubKey(policyPath, writable: true)) + { + policyKey.SetValue("EngineWorkingDirectory", originalPolicyValue); + } + } + } + } } } -- cgit v1.2.3-55-g6feb