Skip to content
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

Adding browser-wasm trimming test leg #48429

Merged
13 commits merged into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from 12 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
2 changes: 1 addition & 1 deletion eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
targetRid: browser-wasm
platform: Browser_wasm
container:
image: ubuntu-18.04-webassembly-20210111135621-8ac9b02
image: ubuntu-18.04-webassembly-20210223133559-4800846
registry: mcr
jobParameters:
runtimeFlavor: ${{ parameters.runtimeFlavor }}
Expand Down
16 changes: 16 additions & 0 deletions eng/pipelines/runtime-linker-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,19 @@ jobs:
nameSuffix: Runtime_Release
buildArgs: -s clr+libs -c $(_BuildConfig)
extraStepsTemplate: /eng/pipelines/libraries/execute-trimming-tests-steps.yml

#
# Build Release config vertical for Browser-wasm
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: release
platforms:
- Browser_wasm
jobParameters:
testGroup: innerloop
timeoutInMinutes: 120
nameSuffix: Runtime_Release
buildArgs: -s mono+libs -c $(_BuildConfig)
extraStepsTemplate: /eng/pipelines/libraries/execute-trimming-tests-steps.yml
3 changes: 3 additions & 0 deletions eng/testing/linker/SupportFiles/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<Project>
<PropertyGroup>
<SkipConfigureTrimming>true</SkipConfigureTrimming>
<UseDefaultBlazorWASMFeatureSwitches>false</UseDefaultBlazorWASMFeatureSwitches>
<PublishTrimmed>true</PublishTrimmed>
<SkipImportRepoLinkerTargets>true</SkipImportRepoLinkerTargets>
<TrimMode>link</TrimMode>
<TrimmerRemoveSymbols>false</TrimmerRemoveSymbols>
<SelfContained>true</SelfContained>
Expand Down
17 changes: 16 additions & 1 deletion eng/testing/linker/SupportFiles/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<Project>
<Import Project="$(RepositoryEngineeringDir)testing\tests.mobile.targets" Condition="'$(RuntimeIdentifier)' == 'browser-wasm'" />

<PropertyGroup>
<BundleDir>$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)', '$(OutputPath)', 'AppBundle'))</BundleDir>
<WasmMainAssemblyFileName>project.dll</WasmMainAssemblyFileName>
</PropertyGroup>

<Target Name="RemoveRuntimePackFromDownloadItem"
AfterTargets="ProcessFrameworkReferences">
<ItemGroup>
Expand All @@ -12,7 +19,7 @@
<Target Name="UpdateRuntimePack"
AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<ResolvedRuntimePack Update="@(ResolvedRuntimePack)" PackageDirectory="$(RuntimePackDir)" />
<ResolvedRuntimePack Update="@(ResolvedRuntimePack)" PackageDirectory="$(MicrosoftNetCoreAppRuntimePackRidDir)../../" />
<ResolvedTargetingPack Update="@(ResolvedTargetingPack)" Path="$(TargetingPackDir)" />
</ItemGroup>
</Target>
Expand All @@ -29,4 +36,12 @@
</ItemGroup>
</Target>

<Target Name="CreateTestWasmAppBundle"
AfterTargets="Publish"
DependsOnTargets="BundleTestWasmApp"
Condition="'$(TargetArchitecture)' == 'wasm' And '$(TargetOs)' == 'browser'" />

<!-- Overriding these targets as these projects won't need to binplace -->
<Target Name="PublishTestAsSelfContained" />

</Project>
8 changes: 7 additions & 1 deletion eng/testing/linker/project.csproj.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<MonoAOTCompilerDir>{MonoAOTCompilerDir}</MonoAOTCompilerDir>
<MonoProjectRoot>{MonoProjectRoot}</MonoProjectRoot>
<EventSourceSupport>true</EventSourceSupport>
<MonoAOTCompilerTasksAssemblyPath>{MonoAOTCompilerTasksAssemblyPath}</MonoAOTCompilerTasksAssemblyPath>
<WasmAppBuilderTasksAssemblyPath>{WasmAppBuilderTasksAssemblyPath}</WasmAppBuilderTasksAssemblyPath>
<MicrosoftNetCoreAppRuntimePackRidDir>{MicrosoftNetCoreAppRuntimePackRidDir}</MicrosoftNetCoreAppRuntimePackRidDir>
<RepositoryEngineeringDir>{RepositoryEngineeringDir}</RepositoryEngineeringDir>
<TargetFramework>{NetCoreAppCurrent}</TargetFramework>
<RuntimeIdentifier>{RuntimeIdentifier}</RuntimeIdentifier>
<RuntimePackDir>{RuntimePackDir}</RuntimePackDir>
<TargetingPackDir>{TargetingPackDir}</TargetingPackDir>
<NETCoreAppMaximumVersion>{NetCoreAppMaximumVersion}</NETCoreAppMaximumVersion>
<MicrosoftNETCoreAppVersion>{MicrosoftNETCoreAppVersion}</MicrosoftNETCoreAppVersion>
Expand Down
28 changes: 20 additions & 8 deletions eng/testing/linker/trimmingTests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
<!-- We need to separate Item metadata declaration in two in order to be able to use ProjectDir and TestRuntimeIdentifier bellow -->
<TestConsoleAppSourceFiles>
<ProjectFile>%(ProjectDir)project.csproj</ProjectFile>
<TestCommand>$([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'publish', 'project'))</TestCommand>
<TestExecutionDirectory>$([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'publish'))</TestExecutionDirectory>
<RuntimePackDirectory>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'microsoft.netcore.app.runtime.%(TestRuntimeIdentifier)', '$(Configuration)'))</RuntimePackDirectory>
<TestCommand Condition="'$(TargetArchitecture)' != 'wasm' Or '$(TargetOs)' != 'browser'">$([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'publish', 'project'))</TestCommand>
<TestCommand Condition="'$(TargetArchitecture)' == 'wasm' And '$(TargetOs)' == 'browser'">$([MSBuild]::NormalizePath('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'AppBundle', 'run-v8.sh'))</TestCommand>
<TestExecutionDirectory Condition="'$(TargetArchitecture)' != 'wasm' Or '$(TargetOs)' != 'browser'">$([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'publish'))</TestExecutionDirectory>
<TestExecutionDirectory Condition="'$(TargetArchitecture)' == 'wasm' And '$(TargetOs)' == 'browser'">$([MSBuild]::NormalizeDirectory('%(ProjectDir)', 'bin', '$(Configuration)', '$(NetCoreAppCurrent)', '%(TestRuntimeIdentifier)', 'AppBundle'))</TestExecutionDirectory>
</TestConsoleAppSourceFiles>
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="!$(SkipOnTestRuntimes.Contains('$(PackageRID)'))">
<TestConsoleApps Include="@(TestConsoleAppSourceFiles->'%(ProjectFile)')" Condition="!$([System.String]::Copy('%(TestConsoleAppSourceFiles.SkipOnTestRuntimes)').Contains('$(PackageRID)'))">
<ProjectCompileItems>%(Identity)</ProjectCompileItems>
</TestConsoleApps>
Expand Down Expand Up @@ -71,12 +72,17 @@
.Replace('{MicrosoftNETCoreAppVersion}', '$(MicrosoftNETCoreAppVersion)')
.Replace('{NetCoreAppCurrent}', '$(NetCoreAppCurrent)')
.Replace('{NetCoreAppMaximumVersion}', '$(NetCoreAppMaximumVersion)')
.Replace('{RuntimePackDir}', '%(TestConsoleApps.RuntimePackDirectory)')
.Replace('{TargetingPackDir}','$(MicrosoftNetCoreAppRefPackDir)')
.Replace('{RuntimeIdentifier}','%(TestConsoleApps.TestRuntimeIdentifier)')
.Replace('{MicrosoftNETILLinkTasksVersion}', '$(MicrosoftNETILLinkTasksVersion)')
.Replace('{ExtraTrimmerArgs}', '%(TestConsoleApps.ExtraTrimmerArgs)')
.Replace('{AdditionalProjectReferences}', '$(_additionalProjectReferencesString)'))"
.Replace('{AdditionalProjectReferences}', '$(_additionalProjectReferencesString)')
.Replace('{RepositoryEngineeringDir}', '$(RepositoryEngineeringDir)')
.Replace('{MonoAOTCompilerDir}', '$(MonoAOTCompilerDir)')
.Replace('{MonoProjectRoot}', '$(MonoProjectRoot)')
.Replace('{MonoAOTCompilerTasksAssemblyPath}', '$(MonoAOTCompilerTasksAssemblyPath)')
.Replace('{WasmAppBuilderTasksAssemblyPath}', '$(WasmAppBuilderTasksAssemblyPath)')
.Replace('{MicrosoftNetCoreAppRuntimePackRidDir}', '$(MicrosoftNetCoreAppRuntimePackRidDir)'))"
Overwrite="true" />
<Copy SourceFiles="$(_projectSourceFile)"
DestinationFolder="$(_projectDir)" />
Expand All @@ -86,15 +92,21 @@
<Message Text="Generated $(_projectFile)" />
</Target>

<Target Name="GetTrimmingProjectsToRestore"
DependsOnTargets="GenerateProjects"
Returns="@(TestConsoleApps)" />

<Target Name="PublishTrimmedProjects"
DependsOnTargets="GenerateProjects">

<MSBuild Projects="@(TestConsoleApps)"
Targets="Restore"
Condition="'$(SkipTrimmingProjectsRestore)' != 'true'"
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid());Configuration=$(Configuration)" />

<MSBuild Projects="@(TestConsoleApps)"
Targets="Publish"
Properties="Configuration=$(Configuration)" />
Properties="Configuration=$(Configuration);BuildProjectReferences=false" />
</Target>

<Target Name="ExecuteApplications"
Expand All @@ -108,7 +120,7 @@
<Output TaskParameter="ExitCode" PropertyName="ExecutionExitCode" />
</Exec>

<Error Condition="'$(ExecutionExitCode)' != '100'" Text="Error: [Failed Test]: %(TestConsoleApps.ProjectCompileItems) The Command %(TestConsoleApps.TestCommand) return a non-success exit code." />
<Error Condition="'$(ExecutionExitCode)' != '100'" Text="Error: [Failed Test]: %(TestConsoleApps.ProjectCompileItems) The Command %(TestConsoleApps.TestCommand) return a non-success exit code." ContinueOnError="ErrorAndContinue" />
</Target>

<Target Name="Build" DependsOnTargets="ExecuteApplications" />
Expand Down
8 changes: 5 additions & 3 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PublishingTestsRun>true</PublishingTestsRun>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetOS)' == 'Browser'">
<PropertyGroup Condition="'$(TargetOS)' == 'Browser' And '$(UseDefaultBlazorWASMFeatureSwitches)' != 'false'">
<!-- 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'">$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'">$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 @@ -162,7 +162,9 @@

</Target>

<Target Name="ConfigureTrimming" Condition="'$(EnableAggressiveTrimming)' == 'true'" AfterTargets="AddTestRunnersToPublishedFiles">
<!-- This .targets file is also imported by the runtime Trimming tests, and we want to be able to manually configure trimming in them so this
should be considered if we ever want to change the Condition of the ConfigureTrimming target -->
<Target Name="ConfigureTrimming" Condition="'$(EnableAggressiveTrimming)' == 'true' And '$(SkipConfigureTrimming)' != 'true'" AfterTargets="AddTestRunnersToPublishedFiles">
<PropertyGroup>
<TrimMode>link</TrimMode>
</PropertyGroup>
Expand Down Expand Up @@ -245,5 +247,5 @@
AfterTargets="Build"
DependsOnTargets="Publish;BundleTestAppleApp;BundleTestAndroidApp;BundleTestWasmApp;ArchiveTests" />

<Import Project="$(RepositoryEngineeringDir)illink.targets" />
<Import Project="$(RepositoryEngineeringDir)illink.targets" Condition="'$(SkipImportRepoLinkerTargets)' != 'true'" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<PropertyGroup>
<AdditionalProjectReferences>Microsoft.Extensions.Logging.Console</AdditionalProjectReferences>
<SkipOnTestRuntimes>browser-wasm</SkipOnTestRuntimes> <!-- Justification: This depends on ConsoleLogger.Processor which requires System.Threading.Thread.Start() which throws PNSE on wasm. -->
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project DefaultTargets="Build">
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />

<PropertyGroup>
<SkipOnTestRuntimes>browser-wasm</SkipOnTestRuntimes> <!-- Justification: HttpListener.ctor() throws PNSE on wasm -->
</PropertyGroup>

<ItemGroup>
<TestConsoleAppSourceFiles Include="CookieExtensionsTest.Clone.cs">
<AdditionalSourceFiles>CookieExtensionsTest.Helper.cs</AdditionalSourceFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static int Main()
}
}

interface IFoo
public interface IFoo
{
public int Property1 { get; set; }
public int UnusedProperty { get; set; }
Expand All @@ -46,7 +46,7 @@ public void Method2() { }
public void UnusedMethod3() { }
}

class CountingProxy : DispatchProxy
public class CountingProxy : DispatchProxy
{
private IFoo _inner;
public int InvocationCount { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ItemGroup>
<TestConsoleAppSourceFiles Include="AppDomainGetThreadGenericPrincipalTest.cs" />
<TestConsoleAppSourceFiles Include="AppDomainGetThreadWindowsPrincipalTest.cs">
<SkipOnTestRuntimes>osx-x64;linux-x64</SkipOnTestRuntimes>
<SkipOnTestRuntimes>osx-x64;linux-x64;browser-wasm</SkipOnTestRuntimes>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="DebuggerTypeProxyAttributeTests.cs" />
<TestConsoleAppSourceFiles Include="DefaultValueAttributeCtorTest.cs" />
Expand All @@ -18,6 +18,11 @@
as a workaround while the linker bug is fixed. This bug has been logged in the
linker repo here: https://github.com/mono/linker/issues/1285 -->
<AdditionalArgs>/p:DebugType=Embedded</AdditionalArgs>
<!-- Justification: The implementation of StackFrame for Mono doesn't use
StackFrameHelper to get line information which is what is being annotated
and tested with this test. Issue https://github.com/dotnet/runtime/issues/48849 is
tracking investigation on why this test is failing if not skipped. -->
<SkipOnTestRuntimes>browser-wasm</SkipOnTestRuntimes>
</TestConsoleAppSourceFiles>
<TestConsoleAppSourceFiles Include="VerifyResourcesGetTrimmedTest.cs">
<!-- Setting the Trimming feature switch to make sure that the Resources get trimmed by the linker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project DefaultTargets="Build">
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />

<PropertyGroup>
<SkipOnTestRuntimes>browser-wasm</SkipOnTestRuntimes> <!-- Justification: System.Security.Cryptography.RSA.Create() throws PNSE on wasm -->
</PropertyGroup>

<ItemGroup>
<TestConsoleAppSourceFiles Include="RSAXmlTest.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project DefaultTargets="Build">
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />

<PropertyGroup>
<SkipOnTestRuntimes>browser-wasm</SkipOnTestRuntimes> <!-- Justification: System.Security.Cryptography.DeriveBytes..ctor() throws PNSE on wasm -->
</PropertyGroup>

<ItemGroup>
<TestConsoleAppSourceFiles Include="PasswordDeriveBytesTest.cs" />
</ItemGroup>
Expand Down
21 changes: 19 additions & 2 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,11 @@
Condition="'$(TestAssemblies)' == 'true'" />
<ProjectReference Include="$(MSBuildThisFileDirectory)pkg\test\testPackages.proj"
Condition="'$(TestPackages)' == 'true'" />
<ProjectReference Include="$(MSBuildThisFileDirectory)*\tests\**\*.TrimmingTests.proj"
<TrimmingTestProjects Include="$(MSBuildThisFileDirectory)*\tests\**\*.TrimmingTests.proj"
Exclude="@(ProjectExclusions)"
Condition="'$(TestTrimming)' == 'true'" />
Condition="'$(TestTrimming)' == 'true'"
AdditionalProperties="%(AdditionalProperties);SkipTrimmingProjectsRestore=true" />
<ProjectReference Include="@(TrimmingTestProjects)" />
</ItemGroup>

<ItemGroup Condition="'$(ArchiveTests)' == 'true' and '$(TargetOS)' == 'iOS'">
Expand Down Expand Up @@ -298,4 +300,19 @@
Condition="'$(TestAssemblies)' == 'true' and
'$(Coverage)' == 'true'" />

<!-- Restoring all trimming test projects upfront in one single call to RestoreTrimmingProjects
so as to avoid possible race conditions that could happen if we restore each individually. -->
<Target Name="RestoreTrimmingProjects"
BeforeTargets="Build"
Condition="'$(TestTrimming)' == 'true'">
<MSBuild Projects="@(TrimmingTestProjects)"
Targets="GetTrimmingProjectsToRestore">
<Output TaskParameter="TargetOutputs" ItemName="_TrimmingProjectsToRestore" />
</MSBuild>

<MSBuild Projects="@(_TrimmingProjectsToRestore)"
Targets="Restore"
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid());Configuration=$(Configuration)" />
</Target>

</Project>