From 040e50ec2859c1de70cd8e9f957474321774f293 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 11 Feb 2025 13:53:50 -0800 Subject: Rewrite Prereq tests after hardening and bypassing .NET GUI errors --- .../burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs | 212 ++++----------------- 1 file changed, 39 insertions(+), 173 deletions(-) (limited to 'src/test/burn/WixToolsetTest.BurnE2E') diff --git a/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs index 4fccb0e9..bc21458d 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs @@ -12,22 +12,21 @@ namespace WixToolsetTest.BurnE2E { public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } - const int E_PREREQBA_INFINITE_LOOP = -2_114_714_646; - /// - /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, - /// with an MSI package to represent the prerequisite package. + /// This bundle purposely misnames its .runtimeconfig.json file to force the PreqBA to kick in + /// and use its EXE prereq package to swap in a good one. /// This verifies that: - /// The preqba doesn't infinitely try to install prereqs. - /// The engine automatically uninstalls the bundle since only permanent packages were installed. + /// The mangaged BA fails to load due to the missing file. + /// The preqba kicks in to copy in the file. + /// The managed BA gets loaded. /// - [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")] - public void DncAlwaysPreqBaDetectsInfiniteLoop() + [RuntimeFact] + public void DncLoadsOnlyAfterInstallingPrereqs() { var packageA = this.CreatePackageInstaller("PackageA"); var packageC = this.CreatePackageInstaller("PackageC"); - var bundleC = this.CreateBundleInstaller("BundleC"); + var bundleA = this.CreateBundleInstaller("BundleA"); var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); @@ -35,60 +34,28 @@ namespace WixToolsetTest.BurnE2E Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); packageC.VerifyInstalled(false); - bundleC.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); - - // Part of the test is Install actually completing. + bundleA.Install(); // Source file should be installed Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); - packageC.VerifyInstalled(false); - - // No non-permanent packages should have ended up installed or cached so it should have unregistered. - bundleC.VerifyUnregisteredAndRemovedFromPackageCache(); - } - - /// - /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, - /// with an MSI package to represent the prerequisite package. - /// This verifies that: - /// The preqba doesn't infinitely reload itself after failing to load the managed BA. - /// The engine automatically uninstalls the bundle since only permanent packages were installed. - /// - [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")] - public void DncPreqBaDetectsInfiniteLoop() - { - var packageA = this.CreatePackageInstaller("PackageA"); - var packageC = this.CreatePackageInstaller("PackageC"); - - var bundleA = this.CreateBundleInstaller("BundleA"); - - var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); - - // Source file should *not* be installed - Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); - packageC.VerifyInstalled(false); - - bundleA.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); + packageC.VerifyInstalled(true); - // Part of the test is Install actually completing. + bundleA.VerifyRegisteredAndInPackageCache(); - // Source file should be installed - Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); - packageC.VerifyInstalled(false); + bundleA.Uninstall(); - // No non-permanent packages should have ended up installed or cached so it should have unregistered. bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); } /// - /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, - /// with an EXE prereq package to swap it out with a good one. + /// This bundle purposely misnames its .runtimeconfig.json file to force the PreqBA to kick in + /// and use its EXE prereq package to swap in a good one. /// This verifies that: - /// The preqba doesn't infinitely try to install prereqs. - /// The managed BA gets loaded after installing prereqs. + /// The preqba runs first to fix the file. + /// The managed BA gets loaded on first try. /// [RuntimeFact] - public void DncAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs() + public void DncPreqsFirstThenBaLoadsManagedBa() { var packageA = this.CreatePackageInstaller("PackageA"); var packageC = this.CreatePackageInstaller("PackageC"); @@ -114,64 +81,20 @@ namespace WixToolsetTest.BurnE2E bundleC.VerifyUnregisteredAndRemovedFromPackageCache(); } - /// - /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, - /// with an EXE prereq package to swap it out with a good one. + /// This bundle purposely misnames its WixToolset.Mba.Host.config file to force the PreqBA to kick in + /// and use its EXE prereq package to swap in a good one. /// This verifies that: - /// The preqba doesn't infinitely reload itself after failing to load the managed BA. - /// The managed BA gets loaded after installing prereqs. + /// The mangaged BA fails to load due to the missing file. + /// The preqba kicks in to copy in the file. + /// The managed BA gets loaded. /// - [RuntimeFact] - public void DncPreqBaLoadsManagedBaAfterInstallingPrereqs() - { - var packageA = this.CreatePackageInstaller("PackageA"); - var packageC = this.CreatePackageInstaller("PackageC"); - - var bundleA = this.CreateBundleInstaller("BundleA"); - - var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); - - // Source file should *not* be installed - Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); - packageC.VerifyInstalled(false); - - bundleA.Install(); - - // Source file should be installed - Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); - packageC.VerifyInstalled(true); - - bundleA.VerifyRegisteredAndInPackageCache(); - - bundleA.Uninstall(); - - bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); - } - - [RuntimeFact] - public void DncAlwaysPreqBaForwardsHelpToManagedBa() - { - var bundleE = this.CreateBundleInstaller("BundleE"); - - var bundleLog = bundleE.Help(); - - Assert.True(LogVerifier.MessageInLogFile(bundleLog, "This is a BA for automated testing")); - } - - /// - /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, - /// with an MSI package to represent the prerequisite package. - /// This verifies that: - /// The preqba doesn't infinitely try to install prereqs. - /// The engine automatically uninstalls the bundle since only permanent packages were installed. - /// - [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")] - public void MbaAlwaysPreqBaDetectsInfiniteLoop() + [RuntimeFact(Skip = "It is no longer possible to replace the bad.config with a good config, these tests do not work for .NET Framework the way they can for .NET above.")] + public void MbaLoadsOnlyAfterInstallingPrereqs() { var packageB = this.CreatePackageInstaller("PackageB"); var packageC = this.CreatePackageInstaller("PackageC"); - var bundleD = this.CreateBundleInstaller("BundleD"); + var bundleB = this.CreateBundleInstaller("BundleB"); var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs"); @@ -179,60 +102,28 @@ namespace WixToolsetTest.BurnE2E Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); packageC.VerifyInstalled(false); - bundleD.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); - - // Part of the test is Install actually completing. + bundleB.Install(); // Source file should be installed Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); - packageC.VerifyInstalled(false); - - // No non-permanent packages should have ended up installed or cached so it should have unregistered. - bundleD.VerifyUnregisteredAndRemovedFromPackageCache(); - } - - /// - /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, - /// with an MSI package to represent the prerequisite package. - /// This verifies that: - /// The preqba doesn't infinitely reload itself after failing to load the managed BA. - /// The engine automatically uninstalls the bundle since only permanent packages were installed. - /// - [RuntimeFact(Skip = ".NET displays a message box when runtime is not present on the machine which hangs on CI systems. Skip this test until we can get a different behavior from .NET")] - public void MbaPreqBaDetectsInfiniteLoop() - { - var packageB = this.CreatePackageInstaller("PackageB"); - var packageC = this.CreatePackageInstaller("PackageC"); - - var bundleB = this.CreateBundleInstaller("BundleB"); - - var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs"); - - // Source file should *not* be installed - Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); - packageC.VerifyInstalled(false); - - bundleB.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); + packageC.VerifyInstalled(true); - // Part of the test is Install actually completing. + bundleB.VerifyRegisteredAndInPackageCache(); - // Source file should be installed - Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); - packageC.VerifyInstalled(false); + bundleB.Uninstall(); // No non-permanent packages should have ended up installed or cached so it should have unregistered. bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); } - /// - /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, - /// with an EXE prereq package to swap it out with a good one. + /// This bundle purposely misnames its WixToolset.Mba.Host.config file to force the PreqBA to kick in + /// and use its EXE prereq package to swap in a good one. /// This verifies that: - /// The preqba doesn't infinitely try to install prereqs. - /// The managed BA gets loaded after installing prereqs. + /// The preqba runs first to fix the file. + /// The managed BA gets loaded on first try. /// - [RuntimeFact] - public void MbaAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs() + [RuntimeFact(Skip = "It is no longer possible to replace the bad.config with a good config, these tests do not work for .NET Framework the way they can for .NET above.")] + public void MbaPreqsFirstThenBaLoadsManagedBa() { var packageB = this.CreatePackageInstaller("PackageB"); var packageC = this.CreatePackageInstaller("PackageC"); @@ -258,39 +149,14 @@ namespace WixToolsetTest.BurnE2E bundleD.VerifyUnregisteredAndRemovedFromPackageCache(); } - /// - /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, - /// with an EXE prereq package to swap it out with a good one. - /// This verifies that: - /// The preqba doesn't infinitely reload itself after failing to load the managed BA. - /// The managed BA gets loaded after installing prereqs. - /// [RuntimeFact] - public void MbaPreqBaLoadsManagedBaAfterInstallingPrereqs() + public void DncAlwaysPreqBaForwardsHelpToManagedBa() { - var packageB = this.CreatePackageInstaller("PackageB"); - var packageC = this.CreatePackageInstaller("PackageC"); - - var bundleB = this.CreateBundleInstaller("BundleB"); - - var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs"); - - // Source file should *not* be installed - Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); - packageC.VerifyInstalled(false); - - bundleB.Install(); - - // Source file should be installed - Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); - packageC.VerifyInstalled(true); - - bundleB.VerifyRegisteredAndInPackageCache(); + var bundleE = this.CreateBundleInstaller("BundleE"); - bundleB.Uninstall(); + var bundleLog = bundleE.Help(); - // No non-permanent packages should have ended up installed or cached so it should have unregistered. - bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); + Assert.True(LogVerifier.MessageInLogFile(bundleLog, "This is a BA for automated testing")); } } } -- cgit v1.2.3-55-g6feb