sendtohelix.proj 11.8 KB
Newer Older
1 2 3
<!-- This project constructs the Helix "correlation payload", the set of files needed to run a set of tests,
     and then invokes sendtohelixhelp.proj for each test assembly and scenario combination to get Helix to
     invoke the tests.
4

5 6 7 8
     In the simple case, no scenarios are specified and the default CoreCLR optimization configuration
     is used to run the tests. If a set of comma-separated scenarios are specified in the `_Scenarios`
     property, then each test is run for each of the specified CoreCLR scenarios (e.g., COMPlus_JitStress=1;
     COMPlus_JitStressRegs=4; COMPlus_JitStress=2 + COMPlus_JitStressRegs=0x1000). The set of acceptable
9
     scenario names is defined and interpreted by src\tests\Common\testenvironment.proj.
10

11 12 13 14
    "RunInParallelForEachScenario" is the "root" target for this Project. It first creates the
    "correlation payload", which is the set of files used by all Helix submissions
    (which we compress into a single file).
-->
15
<Project Sdk="Microsoft.Build.NoTargets" InitialTargets="_SetTestArchiveRuntimeFile">
16

17
  <PropertyGroup>
18
    <BuildTargetFramework Condition="'$(BuildTargetFramework)' == ''">$(NetCoreAppCurrent)</BuildTargetFramework>
19

20 21
    <!-- Set the name of the scenario file. Note that this is only used in invocations where $(Scenario) is set
         (which is when this project is invoked to call the "CreateOneScenarioTestEnvFile" target). -->
22 23
    <TestEnvFileName Condition=" '$(TargetOS)' == 'windows' ">SetStressModes_$(Scenario).cmd</TestEnvFileName>
    <TestEnvFileName Condition=" '$(TargetOS)' != 'windows' ">SetStressModes_$(Scenario).sh</TestEnvFileName>
24

25
  </PropertyGroup>
26 27 28 29 30 31 32 33
  
  <!-- The Helix correlation payload file -->
  <Target Name="_SetTestArchiveRuntimeFile"
          Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)'">
    <PropertyGroup>
      <TestArchiveRuntimeFile>$(TestArchiveRuntimeRoot)test-runtime-$(NetCoreAppCurrentBuildSettings).zip</TestArchiveRuntimeFile>
    </PropertyGroup>
  </Target>
34

35 36
  <Target Name="RunInParallelForEachScenario"
          AfterTargets="Build">
37 38 39 40 41 42 43
    <PropertyGroup>
      <!-- This specifies what properties are needed to be passed down as global properties to a child project invocation. -->
      <_PropertiesToPass>
        RuntimeFlavor=$(RuntimeFlavor);
        TargetArchitecture=$(TargetArchitecture);
        Configuration=$(Configuration);
        TargetOS=$(TargetOS);
V
Viktor Hofer 已提交
44
        TargetRuntimeIdentifier=$(TargetRuntimeIdentifier);
45 46 47 48
        TestRunNamePrefixSuffix=$(TestRunNamePrefixSuffix);
        Creator=$(Creator);
        HelixAccessToken=$(HelixAccessToken);
        HelixTargetQueues=$(HelixTargetQueues);
49
        BuildTargetFramework=$(BuildTargetFramework)
50
      </_PropertiesToPass>
51
      <_DebuggerHosts Condition="'$(_DebuggerHosts)' == ''">chrome</_DebuggerHosts>
52 53 54
    </PropertyGroup>

    <Message Condition="'$(_Scenarios)' != ''" Importance="High" Text="Using _Scenarios: $(_Scenarios)" />
55
    <Message Condition="'$(_DebuggerHosts)' != ''" Importance="High" Text="Using _DebuggerHosts: $(_DebuggerHosts)" />
56 57 58 59 60
    <Message Importance="High" Text="Using Queues: $(HelixTargetQueues)" />
    <Message Importance="High" Text="BuildTargetFramework: $(BuildTargetFramework)" />
    <Message Importance="High" Text="TestArchiveTestsRoot: $(TestArchiveTestsRoot)" />
    <Message Importance="High" Text="TestArchiveRoot: $(TestArchiveRoot)" />
    <Message Importance="High" Text="TestArchiveRuntimeRoot: $(TestArchiveRuntimeRoot)" />
61
    <Message Condition="'$(TestArchiveRuntimeFile)' != ''" Importance="High" Text="TestArchiveRuntimeFile: $(TestArchiveRuntimeFile)" />
62

63 64
    <!-- Re-invoke MSBuild on this project to create the correlation payload -->
    <MSBuild Projects="$(MSBuildProjectFile)" Targets="PrepareCorrelationPayloadDirectory" Properties="Scenarios=$(_Scenarios)" />
65

66
    <PropertyGroup>
67
      <PerScenarioProjectFile>$(MSBuildThisFileDirectory)sendtohelixhelp.proj</PerScenarioProjectFile>
68
    </PropertyGroup>
69

70 71 72 73
    <ItemGroup>
      <_Scenarios Include="$(_Scenarios.Split(','))" />

      <!-- MSBuild creates a new instance of the project for each %(_Scenarios.Identity) and can build them in parallel. -->
74
      <_BaseProjectsToBuild Include="$(PerScenarioProjectFile)" Condition="'%(_Scenarios.Identity)' != 'buildwasmapps' and '%(_Scenarios.Identity)' != 'buildiosapps' and '%(_Scenarios.Identity)' != 'wasmdebuggertests'">
75
        <AdditionalProperties>$(_PropertiesToPass);Scenario=%(_Scenarios.Identity);TestArchiveRuntimeFile=$(TestArchiveRuntimeFile)</AdditionalProperties>
76 77 78 79 80 81 82 83 84 85 86 87 88 89
        <AdditionalProperties Condition="'$(NeedsToBuildWasmAppsOnHelix)' != ''">%(_BaseProjectsToBuild.AdditionalProperties);NeedsToBuildWasmAppsOnHelix=$(NeedsToBuildWasmAppsOnHelix)</AdditionalProperties>
      </_BaseProjectsToBuild>
    </ItemGroup>

    <!-- For BuildWasmApps we want to build the project twice, with: TestUsingWorkloads=true, and TestUsingWorkloads=false -->
    <ItemGroup Condition="'@(_Scenarios -> AnyHaveMetadataValue('Identity', 'buildwasmapps'))' == 'true'">
      <_TestUsingWorkloadsValues Include="true;false" />

      <_BuildWasmAppsProjectsToBuild Include="$(PerScenarioProjectFile)">
        <AdditionalProperties>$(_PropertiesToPass);Scenario=BuildWasmApps;TestArchiveRuntimeFile=$(TestArchiveRuntimeFile);TestUsingWorkloads=%(_TestUsingWorkloadsValues.Identity)</AdditionalProperties>
        <AdditionalProperties Condition="'$(NeedsToBuildWasmAppsOnHelix)' != ''">%(_BuildWasmAppsProjectsToBuild.AdditionalProperties);NeedsToBuildWasmAppsOnHelix=$(NeedsToBuildWasmAppsOnHelix)</AdditionalProperties>
      </_BuildWasmAppsProjectsToBuild>
    </ItemGroup>

90 91 92 93 94 95 96 97
    <ItemGroup Condition="'@(_Scenarios -> AnyHaveMetadataValue('Identity', 'wasmdebuggertests'))' == 'true'">
      <_DebuggerHostsItem Include="$(_DebuggerHosts.Split('/'))" />

      <_WasmDebuggerTestsProjectsToBuild Include="$(PerScenarioProjectFile)">
        <AdditionalProperties>$(_PropertiesToPass);Scenario=WasmDebuggerTests;TestArchiveRuntimeFile=$(TestArchiveRuntimeFile);DebuggerHost=%(_DebuggerHostsItem.Identity)</AdditionalProperties>
      </_WasmDebuggerTestsProjectsToBuild>
    </ItemGroup>

98 99 100 101 102 103 104 105 106 107
    <!-- For BuildWasmApps we want to build the project twice, with: TestUsingWorkloads=true, and TestUsingWorkloads=false -->
    <ItemGroup Condition="'@(_Scenarios -> AnyHaveMetadataValue('Identity', 'buildiosapps'))' == 'true'">
      <_TestUsingWorkloadsValues Include="false" />

      <_BuildiOSAppsProjectsToBuild Include="$(PerScenarioProjectFile)">
        <AdditionalProperties>$(_PropertiesToPass);Scenario=BuildiOSApps;TestArchiveRuntimeFile=$(TestArchiveRuntimeFile);TestUsingWorkloads=%(_TestUsingWorkloadsValues.Identity)</AdditionalProperties>
        <AdditionalProperties Condition="'$(NeedsToBuildAppsOnHelix)' != ''">%(_BuildiOSAppsProjectsToBuild.AdditionalProperties);NeedsToBuildAppsOnHelix=$(NeedsToBuildAppsOnHelix)</AdditionalProperties>
      </_BuildiOSAppsProjectsToBuild>
    </ItemGroup>

108
    <ItemGroup>
109
      <_ProjectsToBuild Include="@(_BuildWasmAppsProjectsToBuild);@(_WasmDebuggerTestsProjectsToBuild);@(_BuildiOSAppsProjectsToBuild);@(_BaseProjectsToBuild)" />
110 111 112 113 114 115 116 117 118 119 120 121
    </ItemGroup>

    <PropertyGroup>
      <_BuildInParallel>false</_BuildInParallel>
      <_BuildInParallel Condition=" '@(_ProjectsToBuild->Count())' &gt; '1' ">true</_BuildInParallel>
    </PropertyGroup>

    <!-- Invoke MSBuild once for each Scenario (because of the "batching" defined in "_ProjectsToBuild").
         Create the Helix work items and start the jobs. This is done by invoking the "Test" Helix target.
    -->
    <MSBuild Projects="@(_ProjectsToBuild)" Targets="Test" BuildInParallel="$(_BuildInParallel)" StopOnFirstFailure="false" />
  </Target>
122

123 124 125 126 127
  <Target Name="CreateOneScenarioTestEnvFile">
    <!-- This target creates one __TestEnv file for the single $(Scenario). -->
    <Error Condition="'$(Scenario)' == ''" Text="No Scenario specified" />

    <PropertyGroup>
128
      <TestEnvFilePath>$(NetCoreAppCurrentTestHostPath)$(TestEnvFileName)</TestEnvFilePath>
129
      <_targetsWindows Condition="'$(TargetOS)' == 'windows'">true</_targetsWindows>
130 131 132
    </PropertyGroup>

    <ItemGroup>
133
      <_ProjectsToBuild Include="$(RepoRoot)\src\tests\Common\testenvironment.proj">
134
        <Properties>Scenario=$(Scenario);TestEnvFileName=$(TestEnvFilePath);TargetsWindows=$(_targetsWindows)</Properties>
135 136 137 138 139 140 141 142 143 144
      </_ProjectsToBuild>
    </ItemGroup>

    <Message Importance="High" Text="Creating $(TestEnvFilePath) for scenario $(Scenario)" />

    <MSBuild Projects="@(_ProjectsToBuild)" Targets="CreateTestEnvFile" StopOnFirstFailure="true" />

    <Error Condition="!Exists('$(TestEnvFilePath)')" Text="File $(TestEnvFilePath) not found!" />
  </Target>

145
  <Target Condition="'$(Scenarios)' != '' and '$(TargetOS)' != 'Browser' and '$(TargetOS)' != 'iOS' and '$(TargetOS)' != 'iOSSimulator'" Name="CreateAllScenarioTestEnvFiles">
146 147 148 149 150 151 152 153 154 155 156 157 158 159
    <!-- This target creates one __TestEnv file for each of the scenarios in the $(Scenarios) comma-separated list. -->

    <Message Importance="High" Text="Creating per-scenario TestEnv files for scenarios $(Scenarios)" />

    <ItemGroup>
      <_Scenario Include="$(Scenarios.Split(','))" />
      <_ProjectsToBuild Include="$(MSBuildProjectFile)">
        <AdditionalProperties>Scenario=%(_Scenario.Identity)</AdditionalProperties>
      </_ProjectsToBuild>
    </ItemGroup>

    <MSBuild Projects="@(_ProjectsToBuild)" Targets="CreateOneScenarioTestEnvFile" StopOnFirstFailure="true" />
  </Target>

160 161 162 163 164 165 166
  <Target Name="_CollectRuntimeInputs">
    <!--
      We need to include all dlls in the runtime path as inputs to make it really incremental. If we use the root folder,
      if a dll is updated, the folder's timestamp is not updated, therefore skipped.
    -->
    <ItemGroup>
      <_RuntimeInput Include="$(NetCoreAppCurrentTestHostPath)**\*.dll" />
167

168
      <!-- Add the scenario TestEnv batch files -->
169 170
      <_RuntimeInput Condition="'$(Scenarios)' != '' and '$(TargetOS)' == 'windows'" Include="$(NetCoreAppCurrentTestHostPath)**\*.cmd" />
      <_RuntimeInput Condition="'$(Scenarios)' != '' and '$(TargetOS)' != 'windows'" Include="$(NetCoreAppCurrentTestHostPath)**\*.sh" />
171 172
    </ItemGroup>
  </Target>
173

174 175 176 177 178 179 180 181 182 183
  <Target Name="IncludeDumpDocsInTesthost"
          Condition="'$(RuntimeFlavor)' == 'CoreCLR'">
    <ItemGroup>
      <DebugDocsFiles Include="$(RepositoryEngineeringDir)testing\debug-dump-template.md" />
      <DebugDocsFiles Include="$(RepositoryEngineeringDir)testing\gen-debug-dump-docs.py" />

      <_RuntimeInputs Include="@(DebugDocsFiles)" />
    </ItemGroup>

    <Copy SourceFiles="@(DebugDocsFiles)"
184
          DestinationFolder="$(NetCoreAppCurrentTestHostPath)"
185 186 187
          SkipUnchangedFiles="true" />
  </Target>

188
  <Target Name="CompressRuntimeDirectory"
189 190
          DependsOnTargets="IncludeDumpDocsInTesthost;_CollectRuntimeInputs"
          Inputs="@(_RuntimeInput);@(TestArchiveRuntimeDependency)"
191
          Outputs="$(TestArchiveRuntimeFile)"
192
          Condition="'$(TargetsMobile)' != 'true' and
193
                     '$(TestArchiveRuntimeFile)' != ''">
194 195 196 197 198
    <!-- Compress the test files, testhost, and per-scenario scripts into a single ZIP file for sending to the Helix machines. -->

    <Message Importance="High" Text="Compressing runtime directory" />

    <Message Importance="High" Text="Creating directory $(TestArchiveRuntimeRoot)" />
199
    <MakeDir Directories="$(TestArchiveRuntimeRoot)" />
200

201
    <ZipDirectory SourceDirectory="$(NetCoreAppCurrentTestHostPath)"
202 203
                  DestinationFile="$(TestArchiveRuntimeFile)"
                  Overwrite="true" />
204 205
  </Target>

206 207 208 209 210 211 212
  <!--
    Collect all the tasks needed to be run once, to prepare the Helix correlation payload directory.
    There's no actual work here; this target just causes its dependent targets to be run.
  -->
  <Target Name="PrepareCorrelationPayloadDirectory"
          DependsOnTargets="CreateAllScenarioTestEnvFiles;CompressRuntimeDirectory" >
    <Message Importance="High" Text="Correlation directory prepared" />
213
  </Target>
214

215
</Project>