Skip to content

Commit

Permalink
[wasm][tests][aot] Propogate wasm properties from the original project
Browse files Browse the repository at this point in the history
.. to the proxy project on helix.

This also fixes #50727 , by
correctly passing `$(InvariantGlobalization)` property to the proxy
project. So, re-enable `Invariant.Tests`.
  • Loading branch information
radical committed Apr 7, 2021
1 parent cac4de8 commit 6e63861
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 11 deletions.
39 changes: 34 additions & 5 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@
</PropertyGroup>

<PropertyGroup Condition="'$(TargetOS)' == 'Browser' and '$(BuildWasmAOTTestsOnHelix)' == 'true'">
<RunScriptCommand >dotnet msbuild publish/aot-build.proj /bl:$XHARNESS_OUT/AOTBuild.binlog</RunScriptCommand>
<RunScriptCommand Condition="'$(BuildWasmTestsOn)' == 'helix' and '$(ContinuousIntegrationBuild)' != 'true'">$(RunScriptCommand) /p:RuntimeSrcDir=$(RepoRoot) /p:RuntimeConfig=$(Configuration)</RunScriptCommand>
<RunScriptCommand Condition="'$(BuildWasmTestsOn)' == 'helix' and '$(ContinuousIntegrationBuild)' == 'true'">$(RunScriptCommand) /p:WasmBuildSupportDir=$HELIX_CORRELATION_PAYLOAD/build</RunScriptCommand>
<RunScriptCommand >$(RunScriptCommand) /p:RunAOTCompilation=$(RunAOTCompilation)</RunScriptCommand>
<RunScriptCommand >dotnet msbuild publish/AOTTestProjectForHelix.proj /bl:$XHARNESS_OUT/AOTBuild.binlog</RunScriptCommand>

<RunScriptCommand>$(RunScriptCommand) &amp;&amp; cd wasm_build/AppBundle &amp;&amp;</RunScriptCommand>
<!-- running aot-helix tests locally, so we can test with the same project file as CI -->
<RunScriptCommand Condition="'$(ContinuousIntegrationBuild)' != 'true'">$(RunScriptCommand) /p:RuntimeSrcDir=$(RepoRoot) /p:RuntimeConfig=$(Configuration)</RunScriptCommand>

<!-- running aot-helix tests on helix! -->
<RunScriptCommand Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(RunScriptCommand) /p:WasmBuildSupportDir=$HELIX_CORRELATION_PAYLOAD/build</RunScriptCommand>

<RunScriptCommand >$(RunScriptCommand) /p:RunAOTCompilation=$(RunAOTCompilation)</RunScriptCommand>
<RunScriptCommand >$(RunScriptCommand) &amp;&amp; cd wasm_build/AppBundle</RunScriptCommand>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetOS)' == 'Browser'">
<RunScriptCommand Condition="'$(RunScriptCommand)' != ''">$(RunScriptCommand) &amp;&amp;</RunScriptCommand>

<!-- We need to set this in order to get extensibility on xunit category traits and other arguments we pass down to xunit via MSBuild properties -->
<RunScriptCommand Condition="'$(IsFunctionalTest)' != 'true' and '$(Scenario)' != 'BuildWasmApps'">$(RunScriptCommand) $HARNESS_RUNNER wasm $XHARNESS_COMMAND --app=. --engine=$(JSEngine) $(JSEngineArgs) --js-file=runtime.js --output-directory=$XHARNESS_OUT -- $(RunTestsJSArguments) --run WasmTestRunner.dll $(AssemblyName).dll</RunScriptCommand>
<RunScriptCommand Condition="'$(IsFunctionalTest)' == 'true'">$(RunScriptCommand) $HARNESS_RUNNER wasm $XHARNESS_COMMAND --app=. --engine=$(JSEngine) $(JSEngineArgs) --js-file=runtime.js --output-directory=$XHARNESS_OUT --expected-exit-code=$(ExpectedExitCode) -- $(RunTestsJSArguments) --run $(AssemblyName).dll --testing</RunScriptCommand>
Expand Down Expand Up @@ -280,6 +286,7 @@

<Target Name="BundleTestWasmApp" Condition="'$(TargetOS)' == 'Browser'" DependsOnTargets="$(BundleTestWasmAppDependsOn)" />

<UsingTask Condition="'$(BuildWasmAOTTestsOnHelix)' == 'true'" TaskName="Microsoft.WebAssembly.Build.Tasks.GenerateAOTProps" AssemblyFile="$(WasmBuildTasksAssemblyPath)" />
<Target Name="_BundleAOTTestWasmAppForHelix" DependsOnTargets="PrepareForWasmBuildApp">
<ItemGroup>
<BundleFiles Include="$(WasmMainJSPath)" TargetDir="publish" />
Expand All @@ -289,6 +296,28 @@
<BundleFiles Include="$(MonoProjectRoot)\wasm\data\aot-tests\*" TargetDir="publish" />
</ItemGroup>

<!-- To recreate the original project on helix, we need to set the wasm properties also, same as the
library test project. Eg. $(InvariantGlobalization) -->
<ItemGroup>
<_WasmPropertyNames Include="InvariantGlobalization" />
<_WasmPropertyNames Include="AOTMode" />
<_WasmPropertyNames Include="WasmDebugLevel" />
<_WasmPropertyNames Include="WasmBuildNative" />
<_WasmPropertyNames Include="_WasmDevel" />
<_WasmPropertyNames Include="WasmLinkIcalls" />
<_WasmPropertyNames Include="WasmDedup" />

<_WasmPropertiesToPass
Include="$(%(_WasmPropertyNames.Identity))"
Name="%(_WasmPropertyNames.Identity)"
ConditionToUse="%(_WasmPropertyNames.ConditionToUse)" />
</ItemGroup>

<!-- This file gets imported by the project file on helix -->
<GenerateAOTProps
Properties="@(_WasmPropertiesToPass)"
OutputFile="$(BundleDir)publish\AOTTestProjectForHelix.props" />

<Copy SourceFiles="@(BundleFiles)" DestinationFolder="$(BundleDir)%(TargetDir)" />
<Copy SourceFiles="@(WasmFilesToIncludeInFileSystem)" DestinationFiles="$(BundleDir)\extraFiles\%(WasmFilesToIncludeInFileSystem.TargetPath)" Condition="'%(WasmFilesToIncludeInFileSystem.TargetPath)' != ''" />
</Target>
Expand Down
3 changes: 0 additions & 3 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,6 @@
<!-- Issue: https://github.com/dotnet/runtime/issues/50726 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Caching/tests/System.Runtime.Caching.Tests.csproj" />

<!-- Issue: https://github.com/dotnet/runtime/issues/50727 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Globalization\tests\Invariant\Invariant.Tests.csproj" />

<!-- Issue: https://github.com/dotnet/runtime/issues/50730 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Serialization.Json\tests\System.Runtime.Serialization.Json.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Serialization.Json\tests\ReflectionOnly\System.Runtime.Serialization.Json.ReflectionOnly.Tests.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
<TestRootDir Condition="'$(HELIX_WORKITEM_ROOT)' == ''">$(MSBuildThisFileDirectory)..\wasm_build\</TestRootDir>
<OriginalPublishDir>$(TestRootDir)..\publish\</OriginalPublishDir>
<IntermediateOutputPath>$(TestRootDir)\obj</IntermediateOutputPath>

<WasmStripAOTAssemblies>false</WasmStripAOTAssemblies>
<WasmNativeBuild>false</WasmNativeBuild>
<WasmNativeDebugSymbols>true</WasmNativeDebugSymbols>
<WasmNativeStrip>false</WasmNativeStrip>

<WasmBuildAppDependsOn>PrepareForWasmBuildApp;$(WasmBuildAppDependsOn)</WasmBuildAppDependsOn>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).props" />

<Target Name="BundleTestWasmApp" DependsOnTargets="WasmBuildApp" />

<Target Name="PrepareForWasmBuildApp">
<PropertyGroup>
<WasmAppDir>>$(TestRootDir)AppBundle\</WasmAppDir>
<WasmAppDir>$(TestRootDir)AppBundle\</WasmAppDir>
<WasmMainAssemblyFileName>$(OriginalPublishDir)WasmTestRunner.dll</WasmMainAssemblyFileName>
<WasmMainJSPath>$(OriginalPublishDir)runtime-test.js</WasmMainJSPath>
<WasmGenerateRunV8Script Condition="'$(WasmGenerateRunV8Script)' == ''">true</WasmGenerateRunV8Script>
Expand Down
55 changes: 55 additions & 0 deletions src/tasks/WasmBuildTasks/GenerateAOTProps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.WebAssembly.Build.Tasks
{
public class GenerateAOTProps : Task
{
[NotNull]
[Required]
public ITaskItem[]? Properties { get; set; }

[NotNull]
[Required]
public string? OutputFile { get; set; }

public override bool Execute()
{
var outDir = Path.GetDirectoryName(OutputFile);
if (!string.IsNullOrEmpty(outDir) && !Directory.Exists(outDir))
Directory.CreateDirectory(outDir);

StringBuilder sb = new();

sb.AppendLine("<Project>");
sb.AppendLine(" <PropertyGroup>");

foreach (var prop in Properties)
{
string value = prop.ItemSpec;
string? name = prop.GetMetadata("Name");
string? condition = prop.GetMetadata("ConditionToUse");

if (!string.IsNullOrEmpty(condition))
sb.AppendLine($" <{name} Condition=\"{condition}\">{value}</{name}>");
else
sb.AppendLine($" <{name}>{value}</{name}>");
}

sb.AppendLine(" </PropertyGroup>");
sb.AppendLine("</Project>");

File.WriteAllText(OutputFile, sb.ToString());
return !Log.HasLoggedErrors;
}

}
}

0 comments on commit 6e63861

Please sign in to comment.