From 73dc2706d9f151554356aaf3e69bfad5b46a21e9 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 1 Jan 2021 19:11:00 -0600 Subject: Add tests for wrong managed BA configuration. Test out the .NET Core test BA as well. --- src/TestData/MsiTransaction/BundleBv1/BundleB.wxi | 1 - .../MsiTransaction/BundleBv1/BundleBv1.wxs | 1 + .../MsiTransaction/BundleBv2/BundleBv2.wxs | 1 + src/TestData/PrereqBa/BundleA/BundleA.wixproj | 16 +++++ src/TestData/PrereqBa/BundleA/BundleA.wxi | 17 +++++ src/TestData/PrereqBa/BundleA/BundleA.wxs | 21 ++++++ .../PrereqBa/BundleA/bad.runtimeconfig.json | 10 +++ src/TestData/PrereqBa/BundleB/BundleB.wixproj | 16 +++++ src/TestData/PrereqBa/BundleB/BundleB.wxi | 17 +++++ src/TestData/PrereqBa/BundleB/BundleB.wxs | 20 ++++++ src/TestData/PrereqBa/BundleB/bad.config | 17 +++++ src/TestData/PrereqBa/PackageA/PackageA.wixproj | 9 +++ src/TestData/PrereqBa/PackageB/PackageB.wixproj | 9 +++ src/TestData/PrereqBa/PackageF/PackageF.wixproj | 12 ++++ src/TestData/TestBA/TestBAWixlib/TestBA.wxs | 22 +++++-- .../TestBA/TestBAWixlib/testbawixlib.wixproj | 3 +- src/Utilities/TestBA/TestBA.csproj | 11 ++-- src/WixToolsetTest.BurnE2E/PrereqBaTests.cs | 76 ++++++++++++++++++++++ 18 files changed, 267 insertions(+), 12 deletions(-) create mode 100644 src/TestData/PrereqBa/BundleA/BundleA.wixproj create mode 100644 src/TestData/PrereqBa/BundleA/BundleA.wxi create mode 100644 src/TestData/PrereqBa/BundleA/BundleA.wxs create mode 100644 src/TestData/PrereqBa/BundleA/bad.runtimeconfig.json create mode 100644 src/TestData/PrereqBa/BundleB/BundleB.wixproj create mode 100644 src/TestData/PrereqBa/BundleB/BundleB.wxi create mode 100644 src/TestData/PrereqBa/BundleB/BundleB.wxs create mode 100644 src/TestData/PrereqBa/BundleB/bad.config create mode 100644 src/TestData/PrereqBa/PackageA/PackageA.wixproj create mode 100644 src/TestData/PrereqBa/PackageB/PackageB.wixproj create mode 100644 src/TestData/PrereqBa/PackageF/PackageF.wixproj create mode 100644 src/WixToolsetTest.BurnE2E/PrereqBaTests.cs diff --git a/src/TestData/MsiTransaction/BundleBv1/BundleB.wxi b/src/TestData/MsiTransaction/BundleBv1/BundleB.wxi index cb7a602d..943b8b48 100644 --- a/src/TestData/MsiTransaction/BundleBv1/BundleB.wxi +++ b/src/TestData/MsiTransaction/BundleBv1/BundleB.wxi @@ -11,7 +11,6 @@ - diff --git a/src/TestData/MsiTransaction/BundleBv1/BundleBv1.wxs b/src/TestData/MsiTransaction/BundleBv1/BundleBv1.wxs index 420d5157..1a24f53e 100644 --- a/src/TestData/MsiTransaction/BundleBv1/BundleBv1.wxs +++ b/src/TestData/MsiTransaction/BundleBv1/BundleBv1.wxs @@ -5,6 +5,7 @@ + diff --git a/src/TestData/MsiTransaction/BundleBv2/BundleBv2.wxs b/src/TestData/MsiTransaction/BundleBv2/BundleBv2.wxs index 39197d7d..33665860 100644 --- a/src/TestData/MsiTransaction/BundleBv2/BundleBv2.wxs +++ b/src/TestData/MsiTransaction/BundleBv2/BundleBv2.wxs @@ -5,6 +5,7 @@ + diff --git a/src/TestData/PrereqBa/BundleA/BundleA.wixproj b/src/TestData/PrereqBa/BundleA/BundleA.wixproj new file mode 100644 index 00000000..ab4c0499 --- /dev/null +++ b/src/TestData/PrereqBa/BundleA/BundleA.wixproj @@ -0,0 +1,16 @@ + + + + Bundle + + + + + + + + + + + + \ No newline at end of file diff --git a/src/TestData/PrereqBa/BundleA/BundleA.wxi b/src/TestData/PrereqBa/BundleA/BundleA.wxi new file mode 100644 index 00000000..23623ffb --- /dev/null +++ b/src/TestData/PrereqBa/BundleA/BundleA.wxi @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/TestData/PrereqBa/BundleA/BundleA.wxs b/src/TestData/PrereqBa/BundleA/BundleA.wxs new file mode 100644 index 00000000..53139834 --- /dev/null +++ b/src/TestData/PrereqBa/BundleA/BundleA.wxs @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/TestData/PrereqBa/BundleA/bad.runtimeconfig.json b/src/TestData/PrereqBa/BundleA/bad.runtimeconfig.json new file mode 100644 index 00000000..07a1a830 --- /dev/null +++ b/src/TestData/PrereqBa/BundleA/bad.runtimeconfig.json @@ -0,0 +1,10 @@ +{ + "runtimeOptions": { + "tfm": "net5.5", + "rollForward": "Disable", + "framework": { + "name": "Microsoft.WindowsDesktop.App", + "version": "5.5.0" + } + } +} \ No newline at end of file diff --git a/src/TestData/PrereqBa/BundleB/BundleB.wixproj b/src/TestData/PrereqBa/BundleB/BundleB.wixproj new file mode 100644 index 00000000..7d4d1ebd --- /dev/null +++ b/src/TestData/PrereqBa/BundleB/BundleB.wixproj @@ -0,0 +1,16 @@ + + + + Bundle + + + + + + + + + + + + \ No newline at end of file diff --git a/src/TestData/PrereqBa/BundleB/BundleB.wxi b/src/TestData/PrereqBa/BundleB/BundleB.wxi new file mode 100644 index 00000000..6bfeb213 --- /dev/null +++ b/src/TestData/PrereqBa/BundleB/BundleB.wxi @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/TestData/PrereqBa/BundleB/BundleB.wxs b/src/TestData/PrereqBa/BundleB/BundleB.wxs new file mode 100644 index 00000000..57d8a552 --- /dev/null +++ b/src/TestData/PrereqBa/BundleB/BundleB.wxs @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/TestData/PrereqBa/BundleB/bad.config b/src/TestData/PrereqBa/BundleB/bad.config new file mode 100644 index 00000000..1512e59a --- /dev/null +++ b/src/TestData/PrereqBa/BundleB/bad.config @@ -0,0 +1,17 @@ + + + + + + + +
+ + + + + + + + + diff --git a/src/TestData/PrereqBa/PackageA/PackageA.wixproj b/src/TestData/PrereqBa/PackageA/PackageA.wixproj new file mode 100644 index 00000000..d46982fa --- /dev/null +++ b/src/TestData/PrereqBa/PackageA/PackageA.wixproj @@ -0,0 +1,9 @@ + + + + {A13BFF68-61DF-4015-9AD1-03854B5E0212} + + + + + \ No newline at end of file diff --git a/src/TestData/PrereqBa/PackageB/PackageB.wixproj b/src/TestData/PrereqBa/PackageB/PackageB.wixproj new file mode 100644 index 00000000..d5edf338 --- /dev/null +++ b/src/TestData/PrereqBa/PackageB/PackageB.wixproj @@ -0,0 +1,9 @@ + + + + {3DD4621A-F7AB-4548-89A8-6DCB0A9BC954} + + + + + \ No newline at end of file diff --git a/src/TestData/PrereqBa/PackageF/PackageF.wixproj b/src/TestData/PrereqBa/PackageF/PackageF.wixproj new file mode 100644 index 00000000..3d52e939 --- /dev/null +++ b/src/TestData/PrereqBa/PackageF/PackageF.wixproj @@ -0,0 +1,12 @@ + + + + {7DEEE928-CD7F-49AD-8000-2ED6339D8A78} + + + + + + + + \ No newline at end of file diff --git a/src/TestData/TestBA/TestBAWixlib/TestBA.wxs b/src/TestData/TestBA/TestBAWixlib/TestBA.wxs index 56ddd1aa..348a0cbb 100644 --- a/src/TestData/TestBA/TestBAWixlib/TestBA.wxs +++ b/src/TestData/TestBA/TestBAWixlib/TestBA.wxs @@ -2,10 +2,24 @@ - - - - + + + + + + + + + + + + + + + + + + diff --git a/src/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj b/src/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj index ee63707e..7dd1798c 100644 --- a/src/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj +++ b/src/TestData/TestBA/TestBAWixlib/testbawixlib.wixproj @@ -6,7 +6,8 @@ en-us - + + diff --git a/src/Utilities/TestBA/TestBA.csproj b/src/Utilities/TestBA/TestBA.csproj index f23235b9..796a0dfd 100644 --- a/src/Utilities/TestBA/TestBA.csproj +++ b/src/Utilities/TestBA/TestBA.csproj @@ -3,22 +3,21 @@ - net35 + net35;net5.0-windows TestBA WixToolset.Test.BA embedded win-x86 + true + true - + + - - - - \ No newline at end of file diff --git a/src/WixToolsetTest.BurnE2E/PrereqBaTests.cs b/src/WixToolsetTest.BurnE2E/PrereqBaTests.cs new file mode 100644 index 00000000..c10736b1 --- /dev/null +++ b/src/WixToolsetTest.BurnE2E/PrereqBaTests.cs @@ -0,0 +1,76 @@ +// 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. + +namespace WixToolsetTest.BurnE2E +{ + using System; + using System.IO; + using Xunit; + using Xunit.Abstractions; + + public class PrereqBaTests : BurnE2ETests + { + public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper, "PrereqBa") { } + + /// + /// 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. + /// + [Fact] + public void DncPreqBaDetectsInfiniteLoop() + { + var packageA = this.CreatePackageInstaller("PackageA"); + this.CreatePackageInstaller("PackageF"); + + 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}"); + + bundleA.Install(); + + // Part of the test is Install actually completing. + + // Source file should be installed + Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); + + // No non-permanent packages should have ended up installed or cached so it should have unregistered. + bundleA.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. + /// + [Fact] + public void MbaPreqBaDetectsInfiniteLoop() + { + var packageB = this.CreatePackageInstaller("PackageB"); + this.CreatePackageInstaller("PackageF"); + + 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}"); + + bundleB.Install(); + + // Part of the test is Install actually completing. + + // Source file should be installed + Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); + + // No non-permanent packages should have ended up installed or cached so it should have unregistered. + bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); + } + } +} -- cgit v1.2.3-55-g6feb