sendtohelix.proj 9.1 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
    <TargetsWindows Condition="'$(TargetOS)' == 'windows'">true</TargetsWindows>
20

21 22 23 24
    <!-- 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). -->
    <TestEnvFileName Condition=" '$(TargetsWindows)' == 'true' ">SetStressModes_$(Scenario).cmd</TestEnvFileName>
    <TestEnvFileName Condition=" '$(TargetsWindows)' != 'true' ">SetStressModes_$(Scenario).sh</TestEnvFileName>
25

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

36 37
  <Target Name="RunInParallelForEachScenario"
          AfterTargets="Build">
38 39 40 41 42 43 44
    <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 已提交
45
        TargetRuntimeIdentifier=$(TargetRuntimeIdentifier);
46 47 48 49
        TestRunNamePrefixSuffix=$(TestRunNamePrefixSuffix);
        Creator=$(Creator);
        HelixAccessToken=$(HelixAccessToken);
        HelixTargetQueues=$(HelixTargetQueues);
50
        BuildTargetFramework=$(BuildTargetFramework)
51 52 53 54 55 56 57 58 59
      </_PropertiesToPass>
    </PropertyGroup>

    <Message Condition="'$(_Scenarios)' != ''" Importance="High" Text="Using _Scenarios: $(_Scenarios)" />
    <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)" />
60
    <Message Condition="'$(TestArchiveRuntimeFile)' != ''" Importance="High" Text="TestArchiveRuntimeFile: $(TestArchiveRuntimeFile)" />
61

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

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

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

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

90 91 92 93 94
  <Target Name="CreateOneScenarioTestEnvFile">
    <!-- This target creates one __TestEnv file for the single $(Scenario). -->
    <Error Condition="'$(Scenario)' == ''" Text="No Scenario specified" />

    <PropertyGroup>
95
      <TestEnvFilePath>$(NetCoreAppCurrentTestHostPath)$(TestEnvFileName)</TestEnvFilePath>
96 97 98
    </PropertyGroup>

    <ItemGroup>
99
      <_ProjectsToBuild Include="$(RepoRoot)\src\tests\Common\testenvironment.proj">
100 101 102 103 104 105 106 107 108 109 110
        <Properties>Scenario=$(Scenario);TestEnvFileName=$(TestEnvFilePath);TargetsWindows=$(TargetsWindows)</Properties>
      </_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>

111
  <Target Condition="'$(Scenarios)' != '' and '$(TargetOS)' != 'Browser'" Name="CreateAllScenarioTestEnvFiles">
112 113 114 115 116 117 118 119 120 121 122 123 124 125
    <!-- 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>

126 127 128 129 130 131 132
  <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" />
133

134 135 136 137 138
      <!-- Add the scenario TestEnv batch files -->
      <_RuntimeInput Condition=" '$(Scenarios)' != '' and '$(TargetsWindows)' == 'true' " Include="$(NetCoreAppCurrentTestHostPath)**\*.cmd" />
      <_RuntimeInput Condition=" '$(Scenarios)' != '' and '$(TargetsWindows)' != 'true' " Include="$(NetCoreAppCurrentTestHostPath)**\*.sh" />
    </ItemGroup>
  </Target>
139

140 141 142 143 144 145 146 147 148 149
  <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)"
150
          DestinationFolder="$(NetCoreAppCurrentTestHostPath)"
151 152 153
          SkipUnchangedFiles="true" />
  </Target>

154
  <Target Name="CompressRuntimeDirectory"
155 156
          DependsOnTargets="IncludeDumpDocsInTesthost;_CollectRuntimeInputs"
          Inputs="@(_RuntimeInput);@(TestArchiveRuntimeDependency)"
157
          Outputs="$(TestArchiveRuntimeFile)"
158
          Condition="'$(TargetsMobile)' != 'true' and
159
                     '$(TestArchiveRuntimeFile)' != ''">
160 161 162 163 164
    <!-- 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)" />
165
    <MakeDir Directories="$(TestArchiveRuntimeRoot)" />
166

167
    <ZipDirectory SourceDirectory="$(NetCoreAppCurrentTestHostPath)"
168 169
                  DestinationFile="$(TestArchiveRuntimeFile)"
                  Overwrite="true" />
170 171
  </Target>

172 173 174 175 176 177 178
  <!--
    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" />
179
  </Target>
180

181
</Project>