@joebigelow / wix / commits / 4d94ed9f

Use dotnet test on C++/CLI test projects to get trx logs.

Sean Hall committed Jun 16, 2022 at 14:41 UTC 4d94ed9fd1d9cb69337134561c520a24a91b91b2
16 files changed +222 -20
src/api/api.cmd
+4 -2
@@ -7,6 +7,8 @@
7 @if /i "%1"=="release" set _C=Release
8 @if not "%1"=="" shift & goto parse_args
9
10 +@set _B=%~dp0..\..\build\api\%_C%
11 +
12 @echo Building api %_C%
13
14 :: restore
@@ -17,8 +19,8 @@ msbuild api_t.proj -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\api_bu
19
20 :: test
21 dotnet test burn\test\WixToolsetTest.Mba.Core -c %_C% --nologo --no-build -l "trx;LogFileName=%_L%\TestResults\WixToolsetTest.Mba.Core.trx" || exit /b
20 -msbuild burn\test\BalUtilUnitTest -t:Test -p:Configuration=%_C% -nologo -p:CppCliTestResultsFile="%_L%\TestResults\BalUtilUnitTest.xunit2.xml" || exit /b
21 -msbuild burn\test\BextUtilUnitTest -t:Test -p:Configuration=%_C% -nologo -p:CppCliTestResultsFile="%_L%\TestResults\BextUtilUnitTest.xunit2.xml" || exit /b
22 +dotnet test %_B%\x86\BalUtilUnitTest.dll --nologo -l "trx;LogFileName=%_L%\TestResults\BalUtilUnitTest.trx" || exit /b
23 +dotnet test %_B%\x86\BextUtilUnitTest.dll --nologo -l "trx;LogFileName=%_L%\TestResults\BextUtilUnitTest.trx" || exit /b
24 dotnet test wix\api_wix.sln -c %_C% --nologo --no-build -l "trx;LogFileName=%_L%\TestResults\api_wix.trx" || exit /b
25
26 @popd
src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp new
+49
@@ -0,0 +1,49 @@
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 +#include "precomp.h"
4 +
5 +using namespace System;
6 +using namespace Xunit;
7 +using namespace WixBuildTools::TestSupport;
8 +using namespace WixBuildTools::TestSupport::XunitExtensions;
9 +
10 +namespace BalUtilTests
11 +{
12 + public ref class BAFunctions
13 + {
14 + public:
15 + [Fact]
16 + void CanCreateTestBAFunctions()
17 + {
18 + HRESULT hr = S_OK;
19 + BOOTSTRAPPER_CREATE_ARGS bootstrapperArgs = { };
20 + BOOTSTRAPPER_COMMAND bootstrapperCommand = { };
21 + BA_FUNCTIONS_CREATE_ARGS args = { };
22 + BA_FUNCTIONS_CREATE_RESULTS results = { };
23 + IBootstrapperEngine* pEngine = NULL;
24 + IBAFunctions* pBAFunctions = NULL;
25 +
26 + bootstrapperArgs.cbSize = sizeof(bootstrapperArgs);
27 + bootstrapperArgs.pCommand = &bootstrapperCommand;
28 +
29 + args.cbSize = sizeof(args);
30 + args.pBootstrapperCreateArgs = &bootstrapperArgs;
31 +
32 + results.cbSize = sizeof(results);
33 +
34 + try
35 + {
36 + hr = BalInitializeFromCreateArgs(&bootstrapperArgs, &pEngine);
37 + NativeAssert::Succeeded(hr, "Failed to create engine.");
38 +
39 + hr = CreateBAFunctions(NULL, pEngine, &args, &results, &pBAFunctions);
40 + NativeAssert::Succeeded(hr, "Failed to create BAFunctions.");
41 + }
42 + finally
43 + {
44 + ReleaseObject(pEngine);
45 + ReleaseObject(pBAFunctions);
46 + }
47 + }
48 + };
49 +}
src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj
+4
@@ -37,6 +37,8 @@
37 </PropertyGroup>
38
39 <ItemGroup>
40 + <ClCompile Include="BAFunctionsTests.cpp" />
41 + <ClCompile Include="BootstrapperApplicationTests.cpp" />
42 <ClCompile Include="precomp.cpp">
43 <PrecompiledHeader>Create</PrecompiledHeader>
44 <!-- Warnings from referencing netstandard dlls -->
@@ -48,6 +50,8 @@
50
51 <ItemGroup>
52 <ClInclude Include="precomp.h" />
53 + <ClInclude Include="TestBAFunctions.h" />
54 + <ClInclude Include="TestBootstrapperApplication.h" />
55 </ItemGroup>
56
57 <ItemGroup>
src/api/burn/test/BalUtilUnitTest/BalUtilUnitTest.vcxproj.filters
+12
@@ -15,6 +15,12 @@
15 </Filter>
16 </ItemGroup>
17 <ItemGroup>
18 + <ClCompile Include="BAFunctionsTests.cpp">
19 + <Filter>Source Files</Filter>
20 + </ClCompile>
21 + <ClCompile Include="BootstrapperApplicationTests.cpp">
22 + <Filter>Source Files</Filter>
23 + </ClCompile>
24 <ClCompile Include="precomp.cpp">
25 <Filter>Source Files</Filter>
26 </ClCompile>
@@ -29,5 +35,11 @@
35 <ClInclude Include="precomp.h">
36 <Filter>Header Files</Filter>
37 </ClInclude>
38 + <ClInclude Include="TestBAFunctions.h">
39 + <Filter>Header Files</Filter>
40 + </ClInclude>
41 + <ClInclude Include="TestBootstrapperApplication.h">
42 + <Filter>Header Files</Filter>
43 + </ClInclude>
44 </ItemGroup>
45 </Project>
\ No newline at end of file
src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp new
+45
@@ -0,0 +1,45 @@
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 +#include "precomp.h"
4 +
5 +using namespace System;
6 +using namespace Xunit;
7 +using namespace WixBuildTools::TestSupport;
8 +using namespace WixBuildTools::TestSupport::XunitExtensions;
9 +
10 +namespace BalUtilTests
11 +{
12 + public ref class BootstrapperApplication
13 + {
14 + public:
15 + [Fact]
16 + void CanCreateTestBootstrapperApplication()
17 + {
18 + HRESULT hr = S_OK;
19 + BOOTSTRAPPER_CREATE_ARGS args = { };
20 + BOOTSTRAPPER_COMMAND command = { };
21 + BOOTSTRAPPER_CREATE_RESULTS results = { };
22 + IBootstrapperEngine* pEngine = NULL;
23 + IBootstrapperApplication* pApplication = NULL;
24 +
25 + args.cbSize = sizeof(args);
26 + args.pCommand = &command;
27 +
28 + results.cbSize = sizeof(results);
29 +
30 + try
31 + {
32 + hr = BalInitializeFromCreateArgs(&args, &pEngine);
33 + NativeAssert::Succeeded(hr, "Failed to create engine.");
34 +
35 + hr = CreateBootstrapperApplication(pEngine, &args, &results, &pApplication);
36 + NativeAssert::Succeeded(hr, "Failed to create BootstrapperApplication.");
37 + }
38 + finally
39 + {
40 + ReleaseObject(pEngine);
41 + ReleaseObject(pApplication);
42 + }
43 + }
44 + };
45 +}
src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h new
+10
@@ -0,0 +1,10 @@
1 +#pragma once
2 +// 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.
3 +
4 +HRESULT CreateBAFunctions(
5 + __in HMODULE hModule,
6 + __in IBootstrapperEngine* pEngine,
7 + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
8 + __in BA_FUNCTIONS_CREATE_RESULTS* pResults,
9 + __out IBAFunctions** ppApplication
10 + );
src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h new
+9
@@ -0,0 +1,9 @@
1 +#pragma once
2 +// 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.
3 +
4 +HRESULT CreateBootstrapperApplication(
5 + __in IBootstrapperEngine* pEngine,
6 + __in const BOOTSTRAPPER_CREATE_ARGS* pArgs,
7 + __inout BOOTSTRAPPER_CREATE_RESULTS* pResults,
8 + __out IBootstrapperApplication** ppApplication
9 + );
src/api/burn/test/BalUtilUnitTest/precomp.h
+9 -5
@@ -18,11 +18,15 @@
18 #include <BootstrapperEngine.h>
19 #include <BootstrapperApplication.h>
20
21 -#include "IBootstrapperEngine.h"
22 -#include "IBootstrapperApplication.h"
23 -#include "balutil.h"
24 -#include "balretry.h"
25 -#include "BAFunctions.h"
21 +#include <BAFunctions.h>
22 +#include <IBootstrapperEngine.h>
23 +#include <IBootstrapperApplication.h>
24 +#include <IBAFunctions.h>
25 +#include <balutil.h>
26 +#include <balretry.h>
27 +
28 +#include "TestBAFunctions.h"
29 +#include "TestBootstrapperApplication.h"
30
31 #pragma managed
32 #include <vcclr.h>
src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj
+2
@@ -36,6 +36,7 @@
36 </PropertyGroup>
37
38 <ItemGroup>
39 + <ClCompile Include="BundleExtensionTests.cpp" />
40 <ClCompile Include="precomp.cpp">
41 <PrecompiledHeader>Create</PrecompiledHeader>
42 <!-- Warnings from referencing netstandard dlls -->
@@ -46,6 +47,7 @@
47
48 <ItemGroup>
49 <ClInclude Include="precomp.h" />
50 + <ClInclude Include="TestBundleExtension.h" />
51 </ItemGroup>
52
53 <ItemGroup>
src/api/burn/test/BextUtilUnitTest/BextUtilUnitTest.vcxproj.filters
+6
@@ -15,6 +15,9 @@
15 </Filter>
16 </ItemGroup>
17 <ItemGroup>
18 + <ClCompile Include="BundleExtensionTests.cpp">
19 + <Filter>Source Files</Filter>
20 + </ClCompile>
21 <ClCompile Include="precomp.cpp">
22 <Filter>Source Files</Filter>
23 </ClCompile>
@@ -26,5 +29,8 @@
29 <ClInclude Include="precomp.h">
30 <Filter>Header Files</Filter>
31 </ClInclude>
32 + <ClInclude Include="TestBundleExtension.h">
33 + <Filter>Header Files</Filter>
34 + </ClInclude>
35 </ItemGroup>
36 </Project>
\ No newline at end of file
src/api/burn/test/BextUtilUnitTest/BundleExtensionTests.cpp new
+44
@@ -0,0 +1,44 @@
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 +#include "precomp.h"
4 +
5 +using namespace System;
6 +using namespace Xunit;
7 +using namespace WixBuildTools::TestSupport;
8 +using namespace WixBuildTools::TestSupport::XunitExtensions;
9 +
10 +namespace BextUtilTests
11 +{
12 + public ref class BundleExtension
13 + {
14 + public:
15 + [Fact]
16 + void CanCreateTestBundleExtension()
17 + {
18 + HRESULT hr = S_OK;
19 + BUNDLE_EXTENSION_CREATE_ARGS args = { };
20 + BUNDLE_EXTENSION_CREATE_RESULTS results = { };
21 + IBundleExtensionEngine* pEngine = NULL;
22 + IBundleExtension* pBundleExtension = NULL;
23 +
24 + args.cbSize = sizeof(args);
25 + args.wzBundleExtensionDataPath = L"test.xml";
26 +
27 + results.cbSize = sizeof(results);
28 +
29 + try
30 + {
31 + hr = BextInitializeFromCreateArgs(&args, &pEngine);
32 + NativeAssert::Succeeded(hr, "Failed to create engine.");
33 +
34 + hr = TestBundleExtensionCreate(pEngine, &args, &results, &pBundleExtension);
35 + NativeAssert::Succeeded(hr, "Failed to create BootstrapperApplication.");
36 + }
37 + finally
38 + {
39 + ReleaseObject(pEngine);
40 + ReleaseObject(pBundleExtension);
41 + }
42 + }
43 + };
44 +}
src/api/burn/test/BextUtilUnitTest/TestBundleExtension.h new
+9
@@ -0,0 +1,9 @@
1 +#pragma once
2 +// 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.
3 +
4 +HRESULT TestBundleExtensionCreate(
5 + __in IBundleExtensionEngine* pEngine,
6 + __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
7 + __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults,
8 + __out IBundleExtension** ppBundleExtension
9 + );
src/api/burn/test/BextUtilUnitTest/precomp.h
+5 -3
@@ -11,9 +11,11 @@
11 #include <BundleExtensionEngine.h>
12 #include <BundleExtension.h>
13
14 -#include "IBundleExtensionEngine.h"
15 -#include "IBundleExtension.h"
16 -#include "bextutil.h"
14 +#include <IBundleExtensionEngine.h>
15 +#include <IBundleExtension.h>
16 +#include <bextutil.h>
17 +
18 +#include "TestBundleExtension.h"
19
20 #pragma managed
21 #include <vcclr.h>
src/burn/burn.cmd
+4 -2
@@ -7,6 +7,8 @@
7 @if /i "%1"=="release" set _C=Release
8 @if not "%1"=="" shift & goto parse_args
9
10 +@set _B=%~dp0..\..\build\burn\%_C%
11 +
12 @echo Building burn %_C%
13
14 :: burn
@@ -15,8 +17,8 @@ nuget restore || exit /b
17
18 msbuild burn_t.proj -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\burn_build.binlog || exit /b
19
18 -msbuild test\BurnUnitTest -t:Test -p:Configuration=%_C% -p:Platform=Win32 -nologo -p:CppCliTestResultsFile="%_L%\TestResults\BurnUnitTest32.xunit2.xml" || exit /b
19 -msbuild test\BurnUnitTest -t:Test -p:Configuration=%_C% -p:Platform=x64 -nologo -p:CppCliTestResultsFile="%_L%\TestResults\BurnUnitTest64.xunit2.xml" || exit /b
20 +dotnet test %_B%\x86\BurnUnitTest.dll --nologo -l "trx;LogFileName=%_L%\TestResults\BurnUnitTest32.trx" || exit /b
21 +dotnet test %_B%\x64\BurnUnitTest.dll --nologo -l "trx;LogFileName=%_L%\TestResults\BurnUnitTest64.trx" || exit /b
22
23 @popd
24 @endlocal
src/libs/libs.cmd
+4 -2
@@ -7,12 +7,14 @@
7 @if /i "%1"=="release" set _C=Release
8 @if not "%1"=="" shift & goto parse_args
9
10 +@set _B=%~dp0..\..\build\libs\%_C%
11 +
12 @echo Building libs %_C%
13
14 msbuild -Restore libs_t.proj -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\libs_build.binlog || exit /b
15
14 -msbuild dutil\test\DutilUnitTest -t:Test -p:Configuration=%_C% -p:Platform=Win32 -nologo -p:CppCliTestResultsFile="%_L%\TestResults\DutilUnitTest32.xunit2.xml" || exit /b
15 -msbuild dutil\test\DutilUnitTest -t:Test -p:Configuration=%_C% -p:Platform=x64 -nologo -p:CppCliTestResultsFile="%_L%\TestResults\DutilUnitTest64.xunit2.xml" || exit /b
16 +dotnet test %_B%\x86\DUtilUnitTest.dll --nologo -l "trx;LogFileName=%_L%\TestResults\DutilUnitTest32.trx" || exit /b
17 +dotnet test %_B%\x64\DUtilUnitTest.dll --nologo -l "trx;LogFileName=%_L%\TestResults\DutilUnitTest64.trx" || exit /b
18
19 @popd
20 @endlocal
src/testresultfilelist.txt
+6 -6
@@ -1,10 +1,10 @@
1 build/logs/TestResults/api_wix.trx
2 -build/logs/TestResults/BalUtilUnitTest.xunit2.xml
3 -build/logs/TestResults/BextUtilUnitTest.xunit2.xml
4 -build/logs/TestResults/BurnUnitTest32.xunit2.xml
5 -build/logs/TestResults/BurnUnitTest64.xunit2.xml
6 -build/logs/TestResults/DutilUnitTest32.xunit2.xml
7 -build/logs/TestResults/DutilUnitTest64.xunit2.xml
2 +build/logs/TestResults/BalUtilUnitTest.trx
3 +build/logs/TestResults/BextUtilUnitTest.trx
4 +build/logs/TestResults/BurnUnitTest32.trx
5 +build/logs/TestResults/BurnUnitTest64.trx
6 +build/logs/TestResults/DutilUnitTest32.trx
7 +build/logs/TestResults/DutilUnitTest64.trx
8 build/logs/TestResults/WixToolsetTest.Bal.trx
9 build/logs/TestResults/WixToolsetTest.BuildTasks.trx
10 build/logs/TestResults/WixToolsetTest.BurnE2E.trx