Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,24 @@ TEST_APK_PROJECTS = \
tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj \
tests/locales/Xamarin.Android.Locale-Tests/Xamarin.Android.Locale-Tests.csproj

# Syntax: $(call BUILD_TEST_APK,path/to/project.csproj)
TEST_APK_PROJECTS_RELEASE = \
src/Mono.Android/Test/Mono.Android-Tests.csproj

# Syntax: $(call BUILD_TEST_APK,path/to/project.csproj,additional_msbuild_flags)
define BUILD_TEST_APK
# Must use xabuild to ensure correct assemblies are resolved
MSBUILD="$(MSBUILD)" tools/scripts/xabuild $(MSBUILD_FLAGS) /t:SignAndroidPackage $(1)
MSBUILD="$(MSBUILD)" tools/scripts/xabuild $(MSBUILD_FLAGS) /t:SignAndroidPackage $(2) $(1)
endef # BUILD_TEST_APK

# Syntax: $(call RUN_APK_TESTS,projects,additional_msbuild_flags)
define RUN_APK_TESTS
$(foreach p, $(1), $(call BUILD_TEST_APK, $(p),$(2)))
$(MSBUILD) $(MSBUILD_FLAGS) $(2) tests/RunApkTests.targets
endef

run-apk-tests:
$(foreach p, $(TEST_APK_PROJECTS), $(call BUILD_TEST_APK, $(p)))
$(MSBUILD) $(MSBUILD_FLAGS) tests/RunApkTests.targets
$(call RUN_APK_TESTS, $(TEST_APK_PROJECTS), )
ifneq ($(wildcard bin/Release),)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, unless the intent is to prevent these tests from running on the PR builder.

The bin/Debug/... artifacts should be able to build an app with /p:Configuration=Release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bin/Debug/... artifacts are able to build normal apps with /p:Configuration=Release, such as samples/HelloWorld.

However, our unit tests are not "normal" apps; they import e.g. Configuration.props, and depend strongly on $(Configuration), so all manner of things break if they don't exist.

$(call RUN_APK_TESTS, $(TEST_APK_PROJECTS_RELEASE), /p:Configuration=Release)
$(call RUN_APK_TESTS, $(TEST_APK_PROJECTS_RELEASE), /p:Configuration=Release /p:AotAssemblies=true)
endif
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override bool Execute ()
Log.LogMessage (MessageImportance.Normal, $"Last timing message: {(last - start).TotalMilliseconds}ms");

if (ResultsFilename != null) {
using (var resultsFile = new StreamWriter (Path.Combine (Path.GetDirectoryName (ResultsFilename), $"Test-{ApplicationPackageName}-times.csv"))) {
using (var resultsFile = new StreamWriter (Path.Combine (Path.GetDirectoryName (ResultsFilename), $"{Path.GetFileNameWithoutExtension (ResultsFilename)}-times.csv"))) {
WriteValues (resultsFile, results.Keys);
WriteValues (resultsFile, results.Values);
resultsFile.Close ();
Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android/Test/Mono.Android-Tests.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<UnitTestApk Include="$(OutputPath)Mono.Android_Tests-Signed.apk">
<Package>Mono.Android_Tests</Package>
<InstrumentationType>xamarin.android.runtimetests.TestInstrumentation</InstrumentationType>
<ResultsPath>$(MSBuildThisFileDirectory)..\..\..\TestResult-Mono.Android_Tests.xml</ResultsPath>
<ResultsPath>$(MSBuildThisFileDirectory)..\..\..\TestResult-Mono.Android_Tests-$(Configuration)$(_AotName).xml</ResultsPath>
</UnitTestApk>
</ItemGroup>
</Project>
9 changes: 6 additions & 3 deletions tests/RunApkTests.targets
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Project DefaultTargets="RunApkTests" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Condition)' == '' ">Debug</Configuration>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol oops. :-)

<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<OutputPath>$(MSBuildThisFileDirectory)..\bin\Test$(Configuration)\</OutputPath>
</PropertyGroup>
<Import Project="..\Configuration.props" />
<PropertyGroup>
<_AotName Condition=" '$(AotAssemblies)' == 'true' ">-Aot</_AotName>
</PropertyGroup>
<!--
Note that the `.csproj` for each `@(UnitTestApk)` entry *must* be added to
`$(TEST_APK_PROJECTS)` in the toplevel Makefile so that the `.apk` is built.
-->
<Import Project="..\src\Mono.Android\Test\Mono.Android-Tests.projitems" />
<Import Project="..\tests\CodeGen-Binding\Xamarin.Android.JcwGen-Tests\Xamarin.Android.JcwGen-Tests.projitems" />
<Import Project="..\tests\locales\Xamarin.Android.Locale-Tests\Xamarin.Android.Locale-Tests.projitems" />
<Import Project="..\tests\CodeGen-Binding\Xamarin.Android.JcwGen-Tests\Xamarin.Android.JcwGen-Tests.projitems" Condition=" '$(Configuration)' == 'Debug' " />
<Import Project="..\tests\locales\Xamarin.Android.Locale-Tests\Xamarin.Android.Locale-Tests.projitems" Condition=" '$(Configuration)' == 'Debug' " />
<Import Project="..\build-tools\scripts\UnitTestApks.targets" />
<PropertyGroup>
<RunApkTestsDependsOn>
Expand Down