aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs')
-rw-r--r--src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs
deleted file mode 100644
index 8be62e92..00000000
--- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/TestEngine.cs
+++ /dev/null
@@ -1,76 +0,0 @@
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
3namespace WixToolsetTest.ManagedHost
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Diagnostics;
8 using System.IO;
9 using WixInternal.TestSupport;
10 using WixInternal.Core.TestPackage;
11
12 public class TestEngine
13 {
14 private static readonly string TestEngineFile = TestData.Get(@"..\x64\examples\Example.TestEngine\Example.TestEngine.exe");
15 private static readonly string TestEngineFileX86 = TestData.Get(@"..\x86\examples\Example.TestEngine\Example.TestEngine.exe");
16
17 public TestEngineResult RunReloadEngine(string bundleFilePath, string tempFolderPath, bool x86 = false)
18 {
19 return this.RunTestEngine("reload", bundleFilePath, tempFolderPath, x86);
20 }
21
22 public TestEngineResult RunShutdownEngine(string bundleFilePath, string tempFolderPath, bool x86 = false)
23 {
24 return this.RunTestEngine("shutdown", bundleFilePath, tempFolderPath, x86);
25 }
26
27 private TestEngineResult RunTestEngine(string engineMode, string bundleFilePath, string tempFolderPath, bool x86 = false)
28 {
29 var baFolderPath = Path.Combine(tempFolderPath, "ba");
30 var extractFolderPath = Path.Combine(tempFolderPath, "extract");
31 var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFilePath, baFolderPath, extractFolderPath);
32 extractResult.AssertSuccess();
33
34 var args = new string[] {
35 engineMode,
36 '"' + bundleFilePath + '"',
37 '"' + extractResult.GetBAFilePath(baFolderPath) + '"',
38 };
39 return RunProcessCaptureOutput(x86 ? TestEngineFileX86 : TestEngineFile, args);
40 }
41
42 private static TestEngineResult RunProcessCaptureOutput(string executablePath, string[] arguments = null, string workingFolder = null)
43 {
44 var startInfo = new ProcessStartInfo(executablePath)
45 {
46 Arguments = String.Join(' ', arguments),
47 CreateNoWindow = true,
48 RedirectStandardError = true,
49 RedirectStandardOutput = true,
50 UseShellExecute = false,
51 WorkingDirectory = workingFolder,
52 };
53
54 var exitCode = 0;
55 var output = new List<string>();
56
57 using (var process = Process.Start(startInfo))
58 {
59 process.OutputDataReceived += (s, e) => { if (e.Data != null) { output.Add(e.Data); } };
60 process.ErrorDataReceived += (s, e) => { if (e.Data != null) { output.Add(e.Data); } };
61
62 process.BeginErrorReadLine();
63 process.BeginOutputReadLine();
64
65 process.WaitForExit();
66 exitCode = process.ExitCode;
67 }
68
69 return new TestEngineResult
70 {
71 ExitCode = exitCode,
72 Output = output,
73 };
74 }
75 }
76}