sendtohelix.proj 8.7 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 9
     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
     scenario names is defined and interpreted by src\coreclr\tests\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

16
<Project DefaultTargets="RunInParallelForEachScenario">
17

18 19 20
  <!-- Helix auto-magically imports local *.props files. We're not going to import the Helix Sdk,
       so we need to import those files manually so we can reference the properties defined there.
  -->
21
  <Import Project="Directory.Build.props" />
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

  <Target Name="RunInParallelForEachScenario">

    <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);
        TestRunNamePrefixSuffix=$(TestRunNamePrefixSuffix);
        Creator=$(Creator);
        HelixAccessToken=$(HelixAccessToken);
        HelixTargetQueues=$(HelixTargetQueues);
        BuildTargetFramework=$(BuildTargetFramework);
        BuildSettings=$(BuildSettings)
      </_PropertiesToPass>
    </PropertyGroup>

    <Message Condition="'$(_Scenarios)' != ''" Importance="High" Text="Using _Scenarios: $(_Scenarios)" />
    <Message Importance="High" Text="Using Queues: $(HelixTargetQueues)" />
    <Message Importance="High" Text="BuildSettings: $(BuildSettings)" />
    <Message Importance="High" Text="BuildTargetFramework: $(BuildTargetFramework)" />
    <Message Importance="High" Text="TestArchiveTestsRoot: $(TestArchiveTestsRoot)" />
    <Message Importance="High" Text="TestHostRootPath: $(TestHostRootPath)" />
    <Message Importance="High" Text="TestArchiveRoot: $(TestArchiveRoot)" />
    <Message Importance="High" Text="TestArchiveRuntimeRoot: $(TestArchiveRuntimeRoot)" />
50
    <Message Condition="'$(TestArchiveRuntimeFile)' != ''" Importance="High" Text="TestArchiveRuntimeFile: $(TestArchiveRuntimeFile)" />
51

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

55 56 57
    <PropertyGroup>
      <PerScenarioProjectFile>$(MSBuildProjectDirectory)\sendtohelixhelp.proj</PerScenarioProjectFile>
    </PropertyGroup>
58

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
    <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>
      </_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>
78

79 80
  <PropertyGroup>
    <TargetsWindows Condition="'$(TargetOS)' == 'Windows_NT'">true</TargetsWindows>
81
    <BuildTargetFramework Condition="'$(TestPackages)' != 'true'">$([MSBuild]::ValueOrDefault('$(BuildTargetFramework)', '$(NetCoreAppCurrent)'))</BuildTargetFramework>
82

83
    <!-- The Helix correlation payload file -->
84 85
    <TestArchiveRuntimeFile Condition="'$(TestPackages)' != 'true' and
                                       '$(BuildTargetFramework)' == '$(NetCoreAppCurrent)'">$(TestArchiveRuntimeRoot)test-runtime-$(BuildSettings).zip</TestArchiveRuntimeFile>
86
    <TestArchiveRuntimeFile Condition="'$(TestPackages)' == 'true'">$(TestArchiveRuntimeRoot)packages-testPayload-$(Configuration).zip</TestArchiveRuntimeFile>
87 88
  </PropertyGroup>

89 90 91
  <PropertyGroup>
    <!-- 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).
92
    -->
93 94
    <TestEnvFileName Condition=" '$(TargetsWindows)' == 'true' ">SetStressModes_$(Scenario).cmd</TestEnvFileName>
    <TestEnvFileName Condition=" '$(TargetsWindows)' != 'true' ">SetStressModes_$(Scenario).sh</TestEnvFileName>
95 96
  </PropertyGroup>

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
  <Target Name="CreateOneScenarioTestEnvFile">
    <!-- This target creates one __TestEnv file for the single $(Scenario). -->

    <Error Condition="'$(Scenario)' == ''" Text="No Scenario specified" />

    <PropertyGroup>
      <TestEnvFilePath>$(TestHostRootPath)$(TestEnvFileName)</TestEnvFilePath>
    </PropertyGroup>

    <ItemGroup>
      <_ProjectsToBuild Include="$(RepoRoot)\src\coreclr\tests\testenvironment.proj">
        <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>

  <Target Condition="'$(Scenarios)' != ''" Name="CreateAllScenarioTestEnvFiles">
    <!-- 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>

134
  <!--
135
    We need to include all dlls in the runtime path as inputs to make it really incremental. If we use the root folder,
136 137
    if a dll is updated, the folder's timestamp is not updated, therefore skipped.
  -->
138 139 140
  <ItemGroup>
    <_RuntimeInputs Include="$(TestHostRootPath)**/*.dll" />

141 142 143
    <!-- Add the scenario TestEnv batch files -->
    <_RuntimeInputs Condition=" '$(Scenarios)' != '' and '$(TargetsWindows)' == 'true' " Include="$(TestHostRootPath)**/*.cmd" />
    <_RuntimeInputs Condition=" '$(Scenarios)' != '' and '$(TargetsWindows)' != 'true' " Include="$(TestHostRootPath)**/*.sh" />
144 145
  </ItemGroup>

146
  <Target Name="CompressRuntimeDirectory"
147
          Inputs="@(_RuntimeInputs);@(TestArchiveRuntimeDependency)"
148
          Outputs="$(TestArchiveRuntimeFile)"
149 150 151
          Condition="'$(TestPackages)' != 'true' and
                     '$(TargetsMobile)' != 'true' and
                     '$(TestArchiveRuntimeFile)' != ''">
152

153 154 155 156 157
    <!-- 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)" />
158
    <MakeDir Directories="$(TestArchiveRuntimeRoot)" />
159

160 161 162
    <ZipDirectory SourceDirectory="$(TestHostRootPath)"
                  DestinationFile="$(TestArchiveRuntimeFile)"
                  Overwrite="true" />
163 164 165

  </Target>

166 167 168 169 170 171 172
  <!--
    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" />
173
  </Target>
174

175
</Project>