Skip to content
Permalink
Browse files

[Build] Unit tests: use proper xunit.console.exe depending on x86 or x64

  • Loading branch information
xen2 committed Apr 15, 2019
1 parent 643d095 commit 7fa89cadcf9f1088dc1d996ffea648f54e19a142
Showing with 31 additions and 8 deletions.
  1. +13 −7 build/Xenko.build
  2. +9 −1 sources/targets/Xenko.Core.GlobalSettings.targets
  3. +9 −0 sources/targets/Xenko.UnitTests.targets
@@ -14,7 +14,7 @@ Example of use:
<BuildProperties Condition="'$(XenkoSign)' != ''">$(BuildProperties);XenkoSign=$(XenkoSign)</BuildProperties>
<BuildProperties Condition="'$(XenkoOfficialBuild)' != ''">$(BuildProperties);XenkoOfficialBuild=$(XenkoOfficialBuild)</BuildProperties>
<NuGetPath>$(MSBuildThisFileDirectory).nuget\NuGet.exe</NuGetPath>
<XunitRunnerConsoleVersion>2.3.1</XunitRunnerConsoleVersion>
<XunitRunnerConsoleVersion>2.4.1</XunitRunnerConsoleVersion>
<XenkoStoreUrl Condition="'$(XenkoStoreUrl)' == ''">https://api.nuget.org/v3/index.json</XenkoStoreUrl>
<AdvancedInstallerPath Condition="'$(AdvancedInstallerPath)' == '' And Exists('$(MSBuildProgramFiles32)\Caphyon\Advanced Installer 15.5.1\bin\x86\advinst.exe')">$(MSBuildProgramFiles32)\Caphyon\Advanced Installer 15.5.1\bin\x86\advinst.exe</AdvancedInstallerPath>
</PropertyGroup>
@@ -238,10 +238,11 @@ Example of use:
<Target Name="DownloadXunitRunnerConsole">
<MakeDir Directories="$(MSBuildThisFileDirectory)packages"/>
<PropertyGroup>
<XunitRunnerConsolePath>$(MSBuildThisFileDirectory)packages\xunit.runner.console.$(XunitRunnerConsoleVersion)\tools\net452\xunit.console.exe</XunitRunnerConsolePath>
<XunitRunnerConsolePathDefault>$(MSBuildThisFileDirectory)packages\xunit.runner.console.$(XunitRunnerConsoleVersion)\tools\net461\xunit.console.exe</XunitRunnerConsolePathDefault>
<XunitRunnerConsolePathX86>$(MSBuildThisFileDirectory)packages\xunit.runner.console.$(XunitRunnerConsoleVersion)\tools\net461\xunit.console.x86.exe</XunitRunnerConsolePathX86>
</PropertyGroup>
<Exec Command='"$(NuGetPath)" install xunit.runner.console -Version $(XunitRunnerConsoleVersion)' Condition="!Exists('$(XunitRunnerConsolePath)')" WorkingDirectory="$(MSBuildThisFileDirectory)packages" />
<Error Text="Could not find xunit.runner at expected location [$(XunitRunnerConsolePath)]" Condition="!Exists('$(XunitRunnerConsolePath)')"/>
<Exec Command='"$(NuGetPath)" install xunit.runner.console -Version $(XunitRunnerConsoleVersion)' Condition="!Exists('$(XunitRunnerConsolePathDefault)')" WorkingDirectory="$(MSBuildThisFileDirectory)packages" />
<Error Text="Could not find xunit.runner at expected location [$(XunitRunnerConsolePathDefault)]" Condition="!Exists('$(XunitRunnerConsolePathDefault)')"/>
</Target>

<Target Name="RunTestsWindows" DependsOnTargets="DownloadXunitRunnerConsole">
@@ -369,12 +370,17 @@ Example of use:
<!-- Build unit tests -->
<Message Importance="High" Text="Building unit test from solution %(Solution): @(UnitTest->'%(TargetName)')"/>
<MSBuild Targets="@(UnitTest->'%(TargetName)');$(XenkoTestExtraTargets)" Projects="%(Solution)" Properties="$(BuildProperties);DeployExtension=true">
<Output TaskParameter="TargetOutputs" ItemName="AssembliesToTest" />
<Output TaskParameter="TargetOutputs" ItemName="AssembliesToTest" />
</MSBuild>

<!-- Run unit tests -->
<MakeDir Directories="$(MSBuildThisFileDirectory)TestResults"/>
<Exec Command="&quot;$(XunitRunnerConsolePath)&quot; @(AssembliesToTest->'%(Identity)', ' ')"/>
<ItemGroup>
<AssembliesToTestDefault Include="@(AssembliesToTest)" Condition="'%(AssembliesToTest.PlatformTarget)' != 'x86'"/>
<AssembliesToTestX86 Include="@(AssembliesToTest)" Condition="'%(AssembliesToTest.PlatformTarget)' == 'x86'"/>
</ItemGroup>
<Exec Condition="'@(AssembliesToTestDefault)' != ''" Command="&quot;$(XunitRunnerConsolePathDefault)&quot; @(AssembliesToTestDefault->'%(Identity)', ' ')"/>
<Exec Condition="'@(AssembliesToTestX86)' != ''" Command="&quot;$(XunitRunnerConsolePathX86)&quot; @(AssembliesToTestX86->'%(Identity)', ' ')"/>
</Target>

<ItemGroup>
@@ -164,5 +164,13 @@
Note: this target is redefined in References.targets for user projects -->
<Target Name="CopyXenkoNativeLibraries" Condition=" '$(XenkoPlatform)' == 'iOS' and '$(OutputType)' == 'Exe'">
</Target>


<!-- Used by Xenko.build to detect if unit tests prefer to run in 32 or 64 bits (note: it's a copy of Xenko.UnitTests.targets one because some unit tests import Xenko.Core.PreSettings.targets rather than Xenko.UnitTests.targets) -->
<Target Name="_XenkoAfterGetTargetPathWithTargetPlatformMoniker" AfterTargets="GetTargetPathWithTargetPlatformMoniker">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Update="$(TargetPath)">
<PlatformTarget>$(PlatformTarget)</PlatformTarget>
</TargetPathWithTargetPlatformMoniker>
</ItemGroup>
</Target>
</Project>
@@ -54,4 +54,13 @@
<XenkoCompileAssetOptions>$(XenkoCompileAssetOptions) --property:XenkoGraphicsApi=$(XenkoGraphicsApi)</XenkoCompileAssetOptions>
</PropertyGroup>
</Target>

<!-- Used by Xenko.build to detect if unit tests prefer to run in 32 or 64 bits -->
<Target Name="_XenkoAfterGetTargetPathWithTargetPlatformMoniker" AfterTargets="GetTargetPathWithTargetPlatformMoniker">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Update="$(TargetPath)">
<PlatformTarget>$(PlatformTarget)</PlatformTarget>
</TargetPathWithTargetPlatformMoniker>
</ItemGroup>
</Target>
</Project>

0 comments on commit 7fa89ca

Please sign in to comment.
You can’t perform that action at this time.