-
Notifications
You must be signed in to change notification settings - Fork 564
[tests] migrate test targets to MSBuild #949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\PrepareWindows.targets" Condition=" '$(OS)' == 'Windows_NT' " /> | ||
| <Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\RunTests.targets" /> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project DefaultTargets="RunAllTests" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup> | ||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
| <_TopDir>$(MSBuildThisFileDirectory)..\..</_TopDir> | ||
| </PropertyGroup> | ||
| <Import Project="$(_TopDir)\Configuration.props" /> | ||
| <UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.SetEnvironmentVariable" /> | ||
| <PropertyGroup> | ||
| <XAIntegratedTests Condition=" '$(HostOS)' == 'Windows' ">False</XAIntegratedTests> | ||
| <_Runtime Condition=" '$(HostOS)' != 'Windows' ">$(ManagedRuntime)</_Runtime> | ||
| <_NUnit>$(_Runtime) packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe</_NUnit> | ||
| <_Test Condition=" '$(TEST)' != '' ">--test="$(TEST)"</_Test> | ||
| <_XABuild>$(_TopDir)\bin\$(Configuration)\bin\xabuild</_XABuild> | ||
| <_XABuildProperties>/p:Configuration=$(Configuration) /p:XAIntegratedTests=$(XAIntegratedTests)</_XABuildProperties> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <_TestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\Xamarin.Android.Build.Tests.dll" /> | ||
| <_JavaInteropTestResults Include="$(JavaInteropSourceDirectory)\TestResult-*.xml" /> | ||
| <_ApkTestProject Include="$(_TopDir)\src\Mono.Android\Test\Mono.Android-Tests.csproj" /> | ||
| <_ApkTestProject Include="$(_TopDir)\tests\CodeGen-Binding\Xamarin.Android.JcwGen-Tests\Xamarin.Android.JcwGen-Tests.csproj" /> | ||
| <_ApkTestProject Include="$(_TopDir)\tests\locales\Xamarin.Android.Locale-Tests\Xamarin.Android.Locale-Tests.csproj" /> | ||
| <_ApkTestProject Include="$(_TopDir)\tests\Xamarin.Android.Bcl-Tests\Xamarin.Android.Bcl-Tests.csproj" /> | ||
| <_ApkTestProject Include="$(_TopDir)\tests\Xamarin.Forms-Performance-Integration\Droid\Xamarin.Forms.Performance.Integration.Droid.csproj" /> | ||
| <_ApkTestProjectAot Include="$(_TopDir)\src\Mono.Android\Test\Mono.Android-Tests.csproj" /> | ||
| </ItemGroup> | ||
| <Target Name="RunNUnitTests"> | ||
| <SetEnvironmentVariable Name="USE_MSBUILD" Value="0" Condition=" '$(USE_MSBUILD)' == '' " /> | ||
| <Exec | ||
| Command="$(_NUnit) $(NUNIT_EXTRA) %(_TestAssembly.Identity) $(_Test) --result="TestResult-%(Filename).xml;format=nunit2" --output="bin\Test$(Configuration)\TestOutput-%(Filename).txt"" | ||
| WorkingDirectory="$(_TopDir)" | ||
| ContinueOnError="True" | ||
| /> | ||
| <ItemGroup> | ||
| <_RenameTestCasesGlob Include="$(_TopDir)\TestResult-*Tests.xml" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <_RenamedTestCases>@(_RenameTestCasesGlob)</_RenamedTestCases> | ||
| </PropertyGroup> | ||
| <MSBuild | ||
| Projects="$(MSBuildThisFileDirectory)TestApks.targets" | ||
| Targets="RenameTestCases" | ||
| Properties="Configuration=$(Configuration);RenameTestCasesGlob=$(_RenamedTestCases)" | ||
| /> | ||
| </Target> | ||
| <Target Name="RunJavaInteropTests"> | ||
| <MSBuild Projects="$(JavaInteropSourceDirectory)\Java.Interop.sln" Condition=" '$(HostOS)' == 'Windows' " /> | ||
| <Exec | ||
| Command ="make -C "$(JavaInteropSourceDirectory)" CONFIGURATION=$(Configuration) all" | ||
| Condition=" '$(HostOS)' != 'Windows' " | ||
| /> | ||
| <SetEnvironmentVariable Name="ANDROID_SDK_PATH" Value="$(AndroidSdkFullPath)" /> | ||
| <MSBuild Projects="$(JavaInteropSourceDirectory)\build-tools\scripts\RunNUnitTests.targets" /> | ||
| <ItemGroup> | ||
| <_RenameTestCasesGlob Include="$(JavaInteropSourceDirectory)\TestResult-*Tests.xml" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <_RenamedTestCases>@(_RenameTestCasesGlob)</_RenamedTestCases> | ||
| </PropertyGroup> | ||
| <MSBuild | ||
| Projects="$(MSBuildThisFileDirectory)TestApks.targets" | ||
| Targets="RenameTestCases" | ||
| Properties="Configuration=$(Configuration);RenameTestCasesGlob=$(_RenamedTestCases)" | ||
| /> | ||
| <Copy SourceFiles="@(_JavaInteropTestResults)" DestinationFolder="$(_TopDir)" /> | ||
| </Target> | ||
| <Target Name="RunApkTests"> | ||
| <Exec Command="$(_XABuild) %(_ApkTestProject.Identity) /t:SignAndroidPackage $(_XABuildProperties)" /> | ||
| <MSBuild Projects="$(_TopDir)\tests\RunApkTests.targets" /> | ||
| <Exec | ||
| Command="$(_XABuild) %(_ApkTestProjectAot.Identity) /t:SignAndroidPackage $(_XABuildProperties) /p:AotAssemblies=True" | ||
| Condition=" '$(Configuration)' == 'Release' " | ||
| /> | ||
| <MSBuild | ||
| Projects="$(_TopDir)\tests\RunApkTests.targets" | ||
| Condition=" '$(Configuration)' == 'Release' " | ||
| /> | ||
| </Target> | ||
| <Target Name="RunAllTests" DependsOnTargets="RunNUnitTests;RunJavaInteropTests;RunApkTests" /> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/SetEnvironmentVariable.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| using Microsoft.Build.Framework; | ||
| using Microsoft.Build.Utilities; | ||
|
|
||
| using System; | ||
|
|
||
| namespace Xamarin.Android.BuildTools.PrepTasks | ||
| { | ||
| public class SetEnvironmentVariable : Task | ||
| { | ||
| [Required] | ||
| public string Name { get; set; } | ||
|
|
||
| [Required] | ||
| public string Value { get; set; } | ||
|
|
||
| public override bool Execute () | ||
| { | ||
| Log.LogMessage (MessageImportance.Low, $"Task {nameof (SetEnvironmentVariable)}"); | ||
| Log.LogMessage (MessageImportance.Low, $" {nameof (Name)}: {Name}"); | ||
| Log.LogMessage (MessageImportance.Low, $" {nameof (Value)}: {Value}"); | ||
|
|
||
| Environment.SetEnvironmentVariable(Name, Value); | ||
|
|
||
| return !Log.HasLoggedErrors; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually work?
Propertiesis a;-delimited list of properties, and$(_RenamedTestCases)may in turn contain;s. If that works....wow.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does seem to work, even under
xbuild. I will need to read the results of the Jenkins build carefully to make sure it looks the same as older builds.