@joebigelow / wix / commits / 223606fc

Update some skipped tests to be dynamically skipped.

Sean Hall committed Jun 15, 2022 at 17:09 UTC 223606fcd02e6d15e065d1e108e17c8848d35f9f
5 files changed +75 -19
src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs
+10 -2
@@ -4,6 +4,7 @@ namespace WixToolsetTest.ManagedHost
4 {
5 using System;
6 using WixBuildTools.TestSupport;
7 + using WixBuildTools.TestSupport.XunitExtensions;
8 using Xunit;
9
10 public class DncHostFixture
@@ -30,7 +31,7 @@ namespace WixToolsetTest.ManagedHost
31 }
32 }
33
33 - [Fact(Skip = "Requires .NET Core 3.1 x86 runtime which might be missing")]
34 + [SkippableFact]
35 public void CanLoadFDDx86EarliestCoreMBA()
36 {
37 // https://github.com/microsoft/vstest/issues/3586
@@ -43,13 +44,20 @@ namespace WixToolsetTest.ManagedHost
44 var testEngine = new TestEngine();
45
46 var result = testEngine.RunShutdownEngine(bundleFile, baseFolder, x86: true);
47 + var resultOutput = result.Output.ToArray();
48 +
49 + if (resultOutput.Length > 0 && resultOutput[0] == "error from hostfxr: It was not possible to find any compatible framework version")
50 + {
51 + WixAssert.Skip(String.Join(Environment.NewLine, resultOutput));
52 + }
53 +
54 WixAssert.CompareLineByLine(new[]
55 {
56 "Loading .NET Core FDD bootstrapper application.",
57 "Creating BA thread to run asynchronously.",
58 "EarliestCoreBA",
59 "Shutdown,ReloadBootstrapper,0",
52 - }, result.Output.ToArray());
60 + }, resultOutput);
61 }
62 }
63
src/libs/dutil/test/DUtilUnitTest/DUtilTests.cpp
+35 -7
@@ -5,26 +5,49 @@
5 using namespace System;
6 using namespace Xunit;
7 using namespace WixBuildTools::TestSupport;
8 +using namespace WixBuildTools::TestSupport::XunitExtensions;
9
10 namespace DutilTests
11 {
12 + [Collection("Dutil_TraceErrorSource")]
13 public ref class DUtil
14 {
15 public:
14 - [Fact(Skip="Flaky")]
16 + [SkippableFact]
17 void DUtilTraceErrorSourceFiltersOnTraceLevel()
18 {
19 DutilInitialize(&DutilTestTraceError);
20
19 - CallDutilTraceErrorSource();
21 + try
22 + {
23 + CallDutilTraceErrorSource();
24
21 - Dutil_TraceSetLevel(REPORT_DEBUG, FALSE);
25 + Dutil_TraceSetLevel(REPORT_DEBUG, FALSE);
26
23 - Action^ action = gcnew Action(this, &DUtil::CallDutilTraceErrorSource);
24 - // See the comments in WixBuildTools.WixAssert for details.
25 - WixAssert::Throws<Exception^>(action);
27 + Exception^ traceErrorException = nullptr;
28
27 - DutilUninitialize();
29 + try
30 + {
31 + CallDutilTraceErrorSource();
32 + }
33 + catch (Exception^ e)
34 + {
35 + traceErrorException = e;
36 + }
37 +
38 + if (traceErrorException == nullptr)
39 + {
40 + WixAssert::Skip("Dutil_TraceErrorSource did not call the registered callback.");
41 + }
42 + else
43 + {
44 + WixAssert::StringEqual("hr = 0x80004005, message = Error message", traceErrorException->Message, false);
45 + }
46 + }
47 + finally
48 + {
49 + DutilUninitialize();
50 + }
51 }
52
53 private:
@@ -33,4 +56,9 @@ namespace DutilTests
56 Dutil_TraceErrorSource(__FILE__, __LINE__, REPORT_DEBUG, DUTIL_SOURCE_EXTERNAL, E_FAIL, "Error message");
57 }
58 };
59 +
60 + [CollectionDefinition("Dutil_TraceErrorSource", DisableParallelization = true)]
61 + public ref class Dutil_TraceErrorSourceCollectionDefinition
62 + {
63 + };
64 }
src/test/burn/WixTestTools/BundleInstaller.cs
+7 -1
@@ -26,6 +26,10 @@ namespace WixTestTools
26
27 public string TestName { get; }
28
29 + public int? AlternateExitCode { get; set; }
30 +
31 + public int? LastExitCode { get; set; }
32 +
33 /// <summary>
34 /// Runs the bundle asking for help.
35 /// </summary>
@@ -226,7 +230,9 @@ namespace WixTestTools
230
231 // Run the tool and assert the expected code.
232 bundle.ExpectedExitCode = expectedExitCode;
229 - bundle.Run(assertOnError);
233 + bundle.AlternateExitCode = this.AlternateExitCode;
234 + var result = bundle.Run(assertOnError);
235 + this.LastExitCode = result.ExitCode;
236
237 // Return the log file name.
238 return logFile;
src/test/burn/WixTestTools/TestTool.cs
+9 -3
@@ -29,6 +29,11 @@ namespace WixTestTools
29 this.PrintOutputToConsole = true;
30 }
31
32 + /// <summary>
33 + /// The alternate expected exit code of the tool
34 + /// </summary>
35 + public int? AlternateExitCode { get; set; }
36 +
37 /// <summary>
38 /// The arguments to pass to the tool
39 /// </summary>
@@ -139,12 +144,13 @@ namespace WixTestTools
144 List<string> errors = new List<string>();
145
146 // Verify that the expected return code matched the actual return code
142 - if (null != this.ExpectedExitCode && this.ExpectedExitCode != result.ExitCode)
147 + if (null != this.ExpectedExitCode && this.ExpectedExitCode != result.ExitCode &&
148 + (null == this.AlternateExitCode || this.AlternateExitCode != result.ExitCode))
149 {
150 errors.Add(String.Format("Expected exit code {0} did not match actual exit code {1}", this.ExpectedExitCode, result.ExitCode));
151 }
152
147 - var standardErrorString = string.Join(Environment.NewLine, result.StandardError);
153 + var standardErrorString = String.Join(Environment.NewLine, result.StandardError);
154
155 // Verify that the expected error string are in stderr
156 if (null != this.ExpectedErrorStrings)
@@ -158,7 +164,7 @@ namespace WixTestTools
164 }
165 }
166
161 - var standardOutputString = string.Join(Environment.NewLine, result.StandardOutput);
167 + var standardOutputString = String.Join(Environment.NewLine, result.StandardOutput);
168
169 // Verify that the expected output string are in stdout
170 if (null != this.ExpectedOutputStrings)
src/test/burn/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs
+14 -6
@@ -4,6 +4,7 @@ namespace WixToolsetTest.BurnE2E
4 {
5 using System;
6 using System.IO;
7 + using WixBuildTools.TestSupport;
8 using WixTestTools;
9 using Xunit;
10 using Xunit.Abstractions;
@@ -42,14 +43,10 @@ namespace WixToolsetTest.BurnE2E
43 this.CanInstallAndUninstallSimpleBundle("PackageA_x64", "BundleA_x64");
44 }
45
45 -#if DEBUG
46 - [RuntimeFact(Skip = "0xc0000005 during shutdown from tiptsf.dll")]
47 -#else
46 [RuntimeFact]
49 -#endif
47 public void CanInstallAndUninstallSimplePerUserBundle_x64_wixstdba()
48 {
52 - this.CanInstallAndUninstallSimpleBundle("PackageApu_x64", "BundleApu_x64", "PackagePerUser.wxs");
49 + this.CanInstallAndUninstallSimpleBundle("PackageApu_x64", "BundleApu_x64", "PackagePerUser.wxs", unchecked((int)0xc0000005));
50 }
51
52 [RuntimeFact]
@@ -70,11 +67,12 @@ namespace WixToolsetTest.BurnE2E
67 this.CanInstallAndUninstallSimpleBundle("PackageA_x64", "BundleD_x64");
68 }
69
73 - private void CanInstallAndUninstallSimpleBundle(string packageName, string bundleName, string fileName = "Package.wxs")
70 + private void CanInstallAndUninstallSimpleBundle(string packageName, string bundleName, string fileName = "Package.wxs", int? alternateExitCode = null)
71 {
72 var package = this.CreatePackageInstaller(packageName);
73
74 var bundle = this.CreateBundleInstaller(bundleName);
75 + bundle.AlternateExitCode = alternateExitCode;
76
77 var packageSourceCodeInstalled = package.GetInstalledFilePath(fileName);
78
@@ -89,12 +87,22 @@ namespace WixToolsetTest.BurnE2E
87 // Source file should be installed
88 Assert.True(File.Exists(packageSourceCodeInstalled), $"Should have found {packageName} payload installed at: {packageSourceCodeInstalled}");
89
90 + if (alternateExitCode == bundle.LastExitCode)
91 + {
92 + WixAssert.Skip($"Install exited with {bundle.LastExitCode}");
93 + }
94 +
95 bundle.Uninstall(cachedBundlePath);
96
97 // Source file should *not* be installed
98 Assert.False(File.Exists(packageSourceCodeInstalled), $"{packageName} payload should have been removed by uninstall from: {packageSourceCodeInstalled}");
99
100 bundle.VerifyUnregisteredAndRemovedFromPackageCache(cachedBundlePath);
101 +
102 + if (alternateExitCode == bundle.LastExitCode)
103 + {
104 + WixAssert.Skip($"Uninstall exited with {bundle.LastExitCode}");
105 + }
106 }
107 }
108 }