From 223606fcd02e6d15e065d1e108e17c8848d35f9f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 15 Jun 2022 17:09:55 -0500 Subject: Update some skipped tests to be dynamically skipped. --- .../WixToolsetTest.ManagedHost/DncHostFixture.cs | 12 +++++-- src/libs/dutil/test/DUtilUnitTest/DUtilTests.cpp | 42 ++++++++++++++++++---- src/test/burn/WixTestTools/BundleInstaller.cs | 8 ++++- src/test/burn/WixTestTools/TestTool.cs | 12 +++++-- .../BasicFunctionalityTests.cs | 20 +++++++---- 5 files changed, 75 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs b/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs index 25856f4d..3aa2bec7 100644 --- a/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs +++ b/src/ext/Bal/test/WixToolsetTest.ManagedHost/DncHostFixture.cs @@ -4,6 +4,7 @@ namespace WixToolsetTest.ManagedHost { using System; using WixBuildTools.TestSupport; + using WixBuildTools.TestSupport.XunitExtensions; using Xunit; public class DncHostFixture @@ -30,7 +31,7 @@ namespace WixToolsetTest.ManagedHost } } - [Fact(Skip = "Requires .NET Core 3.1 x86 runtime which might be missing")] + [SkippableFact] public void CanLoadFDDx86EarliestCoreMBA() { // https://github.com/microsoft/vstest/issues/3586 @@ -43,13 +44,20 @@ namespace WixToolsetTest.ManagedHost var testEngine = new TestEngine(); var result = testEngine.RunShutdownEngine(bundleFile, baseFolder, x86: true); + var resultOutput = result.Output.ToArray(); + + if (resultOutput.Length > 0 && resultOutput[0] == "error from hostfxr: It was not possible to find any compatible framework version") + { + WixAssert.Skip(String.Join(Environment.NewLine, resultOutput)); + } + WixAssert.CompareLineByLine(new[] { "Loading .NET Core FDD bootstrapper application.", "Creating BA thread to run asynchronously.", "EarliestCoreBA", "Shutdown,ReloadBootstrapper,0", - }, result.Output.ToArray()); + }, resultOutput); } } diff --git a/src/libs/dutil/test/DUtilUnitTest/DUtilTests.cpp b/src/libs/dutil/test/DUtilUnitTest/DUtilTests.cpp index 70e5a256..5e2d69e1 100644 --- a/src/libs/dutil/test/DUtilUnitTest/DUtilTests.cpp +++ b/src/libs/dutil/test/DUtilUnitTest/DUtilTests.cpp @@ -5,26 +5,49 @@ using namespace System; using namespace Xunit; using namespace WixBuildTools::TestSupport; +using namespace WixBuildTools::TestSupport::XunitExtensions; namespace DutilTests { + [Collection("Dutil_TraceErrorSource")] public ref class DUtil { public: - [Fact(Skip="Flaky")] + [SkippableFact] void DUtilTraceErrorSourceFiltersOnTraceLevel() { DutilInitialize(&DutilTestTraceError); - CallDutilTraceErrorSource(); + try + { + CallDutilTraceErrorSource(); - Dutil_TraceSetLevel(REPORT_DEBUG, FALSE); + Dutil_TraceSetLevel(REPORT_DEBUG, FALSE); - Action^ action = gcnew Action(this, &DUtil::CallDutilTraceErrorSource); - // See the comments in WixBuildTools.WixAssert for details. - WixAssert::Throws(action); + Exception^ traceErrorException = nullptr; - DutilUninitialize(); + try + { + CallDutilTraceErrorSource(); + } + catch (Exception^ e) + { + traceErrorException = e; + } + + if (traceErrorException == nullptr) + { + WixAssert::Skip("Dutil_TraceErrorSource did not call the registered callback."); + } + else + { + WixAssert::StringEqual("hr = 0x80004005, message = Error message", traceErrorException->Message, false); + } + } + finally + { + DutilUninitialize(); + } } private: @@ -33,4 +56,9 @@ namespace DutilTests Dutil_TraceErrorSource(__FILE__, __LINE__, REPORT_DEBUG, DUTIL_SOURCE_EXTERNAL, E_FAIL, "Error message"); } }; + + [CollectionDefinition("Dutil_TraceErrorSource", DisableParallelization = true)] + public ref class Dutil_TraceErrorSourceCollectionDefinition + { + }; } diff --git a/src/test/burn/WixTestTools/BundleInstaller.cs b/src/test/burn/WixTestTools/BundleInstaller.cs index 0ab02d1b..5551d3c0 100644 --- a/src/test/burn/WixTestTools/BundleInstaller.cs +++ b/src/test/burn/WixTestTools/BundleInstaller.cs @@ -26,6 +26,10 @@ namespace WixTestTools public string TestName { get; } + public int? AlternateExitCode { get; set; } + + public int? LastExitCode { get; set; } + /// /// Runs the bundle asking for help. /// @@ -226,7 +230,9 @@ namespace WixTestTools // Run the tool and assert the expected code. bundle.ExpectedExitCode = expectedExitCode; - bundle.Run(assertOnError); + bundle.AlternateExitCode = this.AlternateExitCode; + var result = bundle.Run(assertOnError); + this.LastExitCode = result.ExitCode; // Return the log file name. return logFile; diff --git a/src/test/burn/WixTestTools/TestTool.cs b/src/test/burn/WixTestTools/TestTool.cs index 9c3a3ea6..eb77c75b 100644 --- a/src/test/burn/WixTestTools/TestTool.cs +++ b/src/test/burn/WixTestTools/TestTool.cs @@ -29,6 +29,11 @@ namespace WixTestTools this.PrintOutputToConsole = true; } + /// + /// The alternate expected exit code of the tool + /// + public int? AlternateExitCode { get; set; } + /// /// The arguments to pass to the tool /// @@ -139,12 +144,13 @@ namespace WixTestTools List errors = new List(); // Verify that the expected return code matched the actual return code - if (null != this.ExpectedExitCode && this.ExpectedExitCode != result.ExitCode) + if (null != this.ExpectedExitCode && this.ExpectedExitCode != result.ExitCode && + (null == this.AlternateExitCode || this.AlternateExitCode != result.ExitCode)) { errors.Add(String.Format("Expected exit code {0} did not match actual exit code {1}", this.ExpectedExitCode, result.ExitCode)); } - var standardErrorString = string.Join(Environment.NewLine, result.StandardError); + var standardErrorString = String.Join(Environment.NewLine, result.StandardError); // Verify that the expected error string are in stderr if (null != this.ExpectedErrorStrings) @@ -158,7 +164,7 @@ namespace WixTestTools } } - var standardOutputString = string.Join(Environment.NewLine, result.StandardOutput); + var standardOutputString = String.Join(Environment.NewLine, result.StandardOutput); // Verify that the expected output string are in stdout if (null != this.ExpectedOutputStrings) diff --git a/src/test/burn/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs index de817e90..4d915c02 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs @@ -4,6 +4,7 @@ namespace WixToolsetTest.BurnE2E { using System; using System.IO; + using WixBuildTools.TestSupport; using WixTestTools; using Xunit; using Xunit.Abstractions; @@ -42,14 +43,10 @@ namespace WixToolsetTest.BurnE2E this.CanInstallAndUninstallSimpleBundle("PackageA_x64", "BundleA_x64"); } -#if DEBUG - [RuntimeFact(Skip = "0xc0000005 during shutdown from tiptsf.dll")] -#else [RuntimeFact] -#endif public void CanInstallAndUninstallSimplePerUserBundle_x64_wixstdba() { - this.CanInstallAndUninstallSimpleBundle("PackageApu_x64", "BundleApu_x64", "PackagePerUser.wxs"); + this.CanInstallAndUninstallSimpleBundle("PackageApu_x64", "BundleApu_x64", "PackagePerUser.wxs", unchecked((int)0xc0000005)); } [RuntimeFact] @@ -70,11 +67,12 @@ namespace WixToolsetTest.BurnE2E this.CanInstallAndUninstallSimpleBundle("PackageA_x64", "BundleD_x64"); } - private void CanInstallAndUninstallSimpleBundle(string packageName, string bundleName, string fileName = "Package.wxs") + private void CanInstallAndUninstallSimpleBundle(string packageName, string bundleName, string fileName = "Package.wxs", int? alternateExitCode = null) { var package = this.CreatePackageInstaller(packageName); var bundle = this.CreateBundleInstaller(bundleName); + bundle.AlternateExitCode = alternateExitCode; var packageSourceCodeInstalled = package.GetInstalledFilePath(fileName); @@ -89,12 +87,22 @@ namespace WixToolsetTest.BurnE2E // Source file should be installed Assert.True(File.Exists(packageSourceCodeInstalled), $"Should have found {packageName} payload installed at: {packageSourceCodeInstalled}"); + if (alternateExitCode == bundle.LastExitCode) + { + WixAssert.Skip($"Install exited with {bundle.LastExitCode}"); + } + bundle.Uninstall(cachedBundlePath); // Source file should *not* be installed Assert.False(File.Exists(packageSourceCodeInstalled), $"{packageName} payload should have been removed by uninstall from: {packageSourceCodeInstalled}"); bundle.VerifyUnregisteredAndRemovedFromPackageCache(cachedBundlePath); + + if (alternateExitCode == bundle.LastExitCode) + { + WixAssert.Skip($"Uninstall exited with {bundle.LastExitCode}"); + } } } } -- cgit v1.2.3-55-g6feb