@joebigelow / wix / commits / 209c9211

Automate the test for GetRelatedBundleVariable.

Sean Hall committed Nov 10, 2022 at 22:48 UTC 209c92111928a98972d7f0f9d6d620ab566564d9
15 files changed +97 -59
src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp renamed
+3 -34
@@ -4,20 +4,9 @@
4 #include "BalBaseBAFunctions.h"
5 #include "BalBaseBAFunctionsProc.h"
6
7 -const DWORD VARIABLE_GROW_FACTOR = 80;
7 const LPCWSTR STRING_VARIABLE = L"AString";
8 const LPCWSTR NUMBER_VARIABLE = L"ANumber";
9
11 -static void CALLBACK BafRelatedBundleVariableTestingTraceError(
12 - __in_z LPCSTR szFile,
13 - __in int iLine,
14 - __in REPORT_LEVEL rl,
15 - __in UINT source,
16 - __in HRESULT hrError,
17 - __in_z __format_string LPCSTR szFormat,
18 - __in va_list args
19 - );
20 -
10 class CBafRelatedBundleVariableTesting : public CBalBaseBAFunctions
11 {
12 public: // IBAFunctions
@@ -32,7 +21,7 @@ public: //IBootstrapperApplication
21 __in LPCWSTR wzVersion,
22 __in BOOL fMissingFromCache,
23 __inout BOOL* pfCancel
35 - )
24 + )
25 {
26
27 HRESULT hr = S_OK;
@@ -44,14 +33,14 @@ public: //IBootstrapperApplication
33
34 if (wzValue)
35 {
47 - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "AString = %ws", wzValue);
36 + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: AString = %ws", wzValue);
37 }
38
39 hr = BalGetRelatedBundleVariable(wzBundleId, NUMBER_VARIABLE, &wzValue);
40
41 if (wzValue)
42 {
54 - BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "ANumber = %ws", wzValue);
43 + BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: ANumber = %ws", wzValue);
44 }
45
46 hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel);
@@ -95,8 +84,6 @@ HRESULT WINAPI CreateBAFunctions(
84 CBafRelatedBundleVariableTesting* pBAFunctions = NULL;
85 IBootstrapperEngine* pEngine = NULL;
86
98 - DutilInitialize(&BafRelatedBundleVariableTestingTraceError);
99 -
87 hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine);
88 ExitOnFailure(hr, "Failed to initialize Bal.");
89
@@ -113,21 +100,3 @@ LExit:
100
101 return hr;
102 }
116 -
117 -static void CALLBACK BafRelatedBundleVariableTestingTraceError(
118 - __in_z LPCSTR /*szFile*/,
119 - __in int /*iLine*/,
120 - __in REPORT_LEVEL /*rl*/,
121 - __in UINT source,
122 - __in HRESULT hrError,
123 - __in_z __format_string LPCSTR szFormat,
124 - __in va_list args
125 - )
126 -{
127 - // BalLogError currently uses the Exit... macros,
128 - // so if expanding the scope need to ensure this doesn't get called recursively.
129 - if (DUTIL_SOURCE_THMUTIL == source)
130 - {
131 - BalLogErrorArgs(hrError, szFormat, args);
132 - }
133 -}
src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def renamed
src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj renamed
src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/precomp.cpp renamed
src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/precomp.h renamed
src/test/burn/TestData/BAFunctionsTests/BundleAv1/BundleA.props renamed
+2 -10
@@ -1,22 +1,14 @@
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 -<Project Sdk="WixToolset.Sdk">
2 +<Project>
3 <PropertyGroup>
4 <OutputType>Bundle</OutputType>
5 - <BA>customHyperlinkLicense</BA>
5 + <BA>hyperlinkLicense</BA>
6 <UpgradeCode>{98ACBCF6-B54A-46AF-8990-DFB8795B965B}</UpgradeCode>
7 - <Version Condition=" '$(Version)' == '' ">1.0.0.0</Version>
7 </PropertyGroup>
8 <ItemGroup>
9 <Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" />
10 </ItemGroup>
11 <ItemGroup>
12 <ProjectReference Include="..\BafRelatedBundleVariableTesting\BafRelatedBundleVariableTesting.vcxproj" Properties="Platform=x86" ReferenceOutputAssembly="false" />
14 - <ProjectReference Include="..\PackageA\PackageA.wixproj" />
13 </ItemGroup>
16 - <ItemGroup>
17 - <PackageReference Include="WixToolset.Bal.wixext" />
18 - </ItemGroup>
19 - <Target Name="CopyManualInstructions" AfterTargets="AfterBuild">
20 - <Copy SourceFiles="ManualTests.txt" DestinationFiles="$(OutputPath)ManualTests.txt" />
21 - </Target>
14 </Project>
src/test/burn/TestData/BAFunctionsTests/BundleAv1/BundleAv1.wixproj new
+10
@@ -0,0 +1,10 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="BundleA.props" />
4 + <ItemGroup>
5 + <ProjectReference Include="..\PackageAv1\PackageAv1.wixproj" />
6 + </ItemGroup>
7 + <ItemGroup>
8 + <PackageReference Include="WixToolset.Bal.wixext" />
9 + </ItemGroup>
10 +</Project>
\ No newline at end of file
src/test/burn/TestData/BAFunctionsTests/BundleAv1/BundleAv1.wxs renamed
+3 -5
@@ -1,15 +1,13 @@
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. -->
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
3
4 <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
5 <Fragment>
6 - <BootstrapperApplication Id="customHyperlinkLicense">
7 - <!-- WixStandardBootstrapperApplication.RtfLicense -->
8 - <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" />
6 + <BootstrapperApplication>
7 <Payload SourceFile="$(var.BafRelatedBundleVariableTesting.TargetPath)" bal:BAFunctions="yes" />
8 </BootstrapperApplication>
9 <PackageGroup Id="BundlePackages">
12 - <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" />
10 + <MsiPackage Id="PackageA" SourceFile="$(var.PackageAv1.TargetPath)" />
11 </PackageGroup>
12 <Variable Name="ANumber" bal:Overridable="yes" Value="42" Persisted="yes" />
13 <Variable Name="AString" bal:Overridable="yes" Value="This is a test" Persisted="yes" />
src/test/burn/TestData/BAFunctionsTests/BundleAv2/BundleAv2.wixproj new
+13
@@ -0,0 +1,13 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="..\BundleAv1\BundleA.props" />
4 + <PropertyGroup>
5 + <Version>2.0.0.0</Version>
6 + </PropertyGroup>
7 + <ItemGroup>
8 + <ProjectReference Include="..\PackageAv2\PackageAv2.wixproj" />
9 + </ItemGroup>
10 + <ItemGroup>
11 + <PackageReference Include="WixToolset.Bal.wixext" />
12 + </ItemGroup>
13 +</Project>
\ No newline at end of file
src/test/burn/TestData/BAFunctionsTests/BundleAv2/BundleAv2.wxs new
+15
@@ -0,0 +1,15 @@
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 +
3 +
4 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
5 + <Fragment>
6 + <BootstrapperApplication>
7 + <Payload SourceFile="$(var.BafRelatedBundleVariableTesting.TargetPath)" bal:BAFunctions="yes" />
8 + </BootstrapperApplication>
9 + <PackageGroup Id="BundlePackages">
10 + <MsiPackage Id="PackageA" SourceFile="$(var.PackageAv2.TargetPath)" />
11 + </PackageGroup>
12 + <Variable Name="ANumber" bal:Overridable="yes" Value="4242" Persisted="yes" />
13 + <Variable Name="AString" bal:Overridable="yes" Value="This is a test v2" Persisted="yes" />
14 + </Fragment>
15 +</Wix>
src/test/burn/TestData/BAFunctionsTests/PackageAv1/PackageA.props new
+9
@@ -0,0 +1,9 @@
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 +<Project>
3 + <PropertyGroup>
4 + <UpgradeCode>{F5E0E236-395D-4E7F-BE0A-00B20F7EAF4B}</UpgradeCode>
5 + </PropertyGroup>
6 + <ItemGroup>
7 + <Compile Include="..\..\Templates\Package.wxs" Link="Package.wxs" />
8 + </ItemGroup>
9 +</Project>
\ No newline at end of file
src/test/burn/TestData/BAFunctionsTests/PackageAv1/PackageAv1.wixproj new
+4
@@ -0,0 +1,4 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="PackageA.props" />
4 +</Project>
\ No newline at end of file
src/test/burn/TestData/BAFunctionsTests/PackageAv2/PackageAv2.wixproj new
+7
@@ -0,0 +1,7 @@
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 +<Project Sdk="WixToolset.Sdk">
3 + <Import Project="..\PackageAv1\PackageA.props" />
4 + <PropertyGroup>
5 + <Version>2.0.0.0</Version>
6 + </PropertyGroup>
7 +</Project>
\ No newline at end of file
src/test/burn/TestData/Manual/BundleD/ManualTests.txt deleted
-10
@@ -1,10 +0,0 @@
1 -BafRelatedBundleVariableTesting
2 -# Building, Run initial build w/ no parameters, run a second (re)build w/ a /p:Version=1.1.0.0 (ensure it actually builds, as CLI params aren't accounted in the build optimization)
3 -1. Run BundleD.exe (v1.0).
4 -2. Click Install.
5 -3. Verify that the Bundle installs successfully.
6 -4. Run BundleD.exe (v1.1).
7 -5. Check the log file in %TEMP% There should be lines reporting:
8 -[0708:04B4]i000: AString = This is a test
9 -[0708:04B4]i000: ANumber = 42
10 -
src/test/burn/WixToolsetTest.BurnE2E/BAFunctionsTests.cs new
+31
@@ -0,0 +1,31 @@
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 +
3 +namespace WixToolsetTest.BurnE2E
4 +{
5 + using WixTestTools;
6 + using Xunit;
7 + using Xunit.Abstractions;
8 +
9 + public class BAFunctionsTests : BurnE2ETests
10 + {
11 + public BAFunctionsTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
12 +
13 + [RuntimeFact]
14 + public void LogsPersistedRelatedBundleVariables()
15 + {
16 + this.CreatePackageInstaller("PackageAv1");
17 + this.CreatePackageInstaller("PackageAv2");
18 + var bundleAv1 = this.CreateBundleInstaller("BundleAv1");
19 + var bundleAv2 = this.CreateBundleInstaller("BundleAv2");
20 +
21 + bundleAv1.Install();
22 + bundleAv1.VerifyRegisteredAndInPackageCache();
23 +
24 + var bundleAv2InstallLogFilePath = bundleAv2.Install();
25 + bundleAv2.VerifyRegisteredAndInPackageCache();
26 +
27 + Assert.True(LogVerifier.MessageInLogFileRegex(bundleAv2InstallLogFilePath, @"Retrieved related bundle variable with BAFunctions: ANumber = 42"));
28 + Assert.True(LogVerifier.MessageInLogFileRegex(bundleAv2InstallLogFilePath, @"Retrieved related bundle variable with BAFunctions: AString = This is a test"));
29 + }
30 + }
31 +}