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

Simplify scenario-tests test invocation & define dependencies #41055

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions src/SourceBuild/content/repo-projects/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,35 @@
ExtractToolPackage;
CleanupRepo" />

<Target Name="Test"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(BaseIntermediateOutputPath)Test.complete">
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Testing $(RepositoryName)" />
<Message Importance="High" Text="Running command:" />
<Message Importance="High" Text=" $(TestCommand)" />
<Message Importance="High" Text=" With Environment Variables:"/>
<Message Importance="High" Text=" %(TestEnvironmentVariable.Identity)" />

<PropertyGroup>
<FullTestCommand>$(TestCommand)</FullTestCommand>
<FullTestCommand Condition="'$(LogVerbosityOptOut)' != 'true'">$(FullTestCommand) /v:$(LogVerbosity)</FullTestCommand>
</PropertyGroup>

<Exec Command="$(FullTestCommand)"
WorkingDirectory="$(ProjectDirectory)"
EnvironmentVariables="@(TestEnvironmentVariable)">
<Output TaskParameter="ExitCode" PropertyName="RepoTestExitCode" />
</Exec>

<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Testing $(RepositoryName)...done" />

<MakeDir Directories="$(BaseIntermediateOutputPath)" />
<Touch Files="$(BaseIntermediateOutputPath)Test.complete" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
<Target Name="VSTest" DependsOnTargets="Test" />

<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.UsageReport.WritePackageUsageData" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />
<Target Name="WritePrebuiltUsageData"
Inputs="$(MSBuildProjectFullPath)"
Expand Down
42 changes: 18 additions & 24 deletions src/SourceBuild/content/repo-projects/scenario-tests.proj
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<Project Sdk="Microsoft.Build.NoTargets" TreatAsLocalProperty="CleanWhileBuilding">

<PropertyGroup>
<!-- The scenario-tests repo shouldn't be cleaned after building as we run tests from it. -->
<CleanWhileBuilding>false</CleanWhileBuilding>

<ScenarioTestsArtifactsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'scenario-tests'))</ScenarioTestsArtifactsDir>
<ScenarioTestsResultsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsTestResultsDir)', 'scenario-tests'))</ScenarioTestsResultsDir>
<NuGetConfigInputForScenarioTests>$([MSBuild]::NormalizePath('$(SrcDir)', 'sdk', 'NuGet.config'))</NuGetConfigInputForScenarioTests>
<NuGetConfigOutputForScenarioTests>$(ScenarioTestsArtifactsDir)NuGet.config</NuGetConfigOutputForScenarioTests>
</PropertyGroup>

<ItemGroup>
<RepositoryReference Include="arcade" />
<RepositoryReference Include="command-line-api" />
Expand All @@ -10,28 +20,16 @@
<RepositoryReference Include="source-build-reference-packages" />
</ItemGroup>

<PropertyGroup>
<!-- The scenario-tests repo shouldn't be cleaned after building as we run tests from it. -->
<CleanWhileBuilding>false</CleanWhileBuilding>

<ScenarioTestsArtifactsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'scenario-tests'))</ScenarioTestsArtifactsDir>
<ScenarioTestsResultsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsTestResultsDir)', 'scenario-tests'))</ScenarioTestsResultsDir>
<_ScenarioTestsNuGetConfig>$(ScenarioTestsArtifactsDir)NuGet.config</_ScenarioTestsNuGetConfig>
<_SdkNuGetConfig>$([MSBuild]::NormalizePath('$(SrcDir)', 'sdk', 'NuGet.config'))</_SdkNuGetConfig>
</PropertyGroup>

<Target Name="SetupNuGetConfig"
Inputs="$(_SdkNuGetConfig)"
Outputs="$(_ScenarioTestsNuGetConfig)">

<Copy SourceFiles="$(_SdkNuGetConfig)"
DestinationFiles="$(_ScenarioTestsNuGetConfig)" />

Inputs="$(NuGetConfigInputForScenarioTests)"
Outputs="$(NuGetConfigOutputForScenarioTests)">
<Copy SourceFiles="$(NuGetConfigInputForScenarioTests)"
DestinationFiles="$(NuGetConfigOutputForScenarioTests)" />
</Target>

<Target Name="RunScenarioTests"
DependsOnTargets="SetupNuGetConfig;DetermineSourceBuiltSdkVersion">

<Target Name="PrepareScenarioTestsInputs"
DependsOnTargets="SetupNuGetConfig;DetermineSourceBuiltSdkVersion"
BeforeTargets="Test">
<PropertyGroup>
<_CurrentDateTime>$([System.DateTime]::Now.ToString("yyyy-MM-dd_HH_mm_ss"))</_CurrentDateTime>
<_TestXmlOutputPath>$(ScenarioTestsResultsDir)$(_CurrentDateTime).xml</_TestXmlOutputPath>
Expand All @@ -49,18 +47,14 @@
<MakeDir Directories="$(ScenarioTestsResultsDir)" />

<ItemGroup>
<_ScenarioTestEnvVars Include="
<TestEnvironmentVariable Include="
TestRoot=$(_TestRoot);
DotNetRoot=$(DotNetSdkExtractDir);
TestSdkVersion=$(SourceBuiltSdkVersion);
AdditionalTestArgs=$(_ScenarioTestsAdditionalArgs);
DotNetTool=$(_DotNetTool);
_InitializeDotNetCli=$(DotNetSdkExtractDir)" />
</ItemGroup>

<Exec Command="$(TestCommand)"
WorkingDirectory="$(ProjectDirectory)"
EnvironmentVariables="@(_ScenarioTestEnvVars)" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepositoryEngineeringDir)extract-sdk-archive.proj" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\TestUtilities\TestUtilities.csproj" />
</ItemGroup>

Expand Down Expand Up @@ -71,7 +72,7 @@
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).MsftSdkTarballPath">
<Value>$(MsftSdkTarballPath)</Value>
</RuntimeHostConfigurationOption>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).PoisonReportPath"
Condition="'$(EnablePoison)' == 'true'">
<Value>$(PoisonUsageReportFile)</Value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" />
<PackageReference Include="NuGet.Protocol" />
<ProjectReference Include="$(RepositoryEngineeringDir)merge-asset-manifests.proj" ReferenceOutputAssembly="false" PrivateAssets="all" />
<ProjectReference Include="$(RepositoryEngineeringDir)extract-sdk-archive.proj" ReferenceOutputAssembly="false" />
<ProjectReference Include="$(RepositoryEngineeringDir)merge-asset-manifests.proj" ReferenceOutputAssembly="false" />
</ItemGroup>

<ItemGroup>
Expand Down

This file was deleted.

17 changes: 0 additions & 17 deletions src/SourceBuild/content/test/scenario-tests/scenario-tests.proj

This file was deleted.

9 changes: 6 additions & 3 deletions src/SourceBuild/content/test/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<_RunScenarioTests>true</_RunScenarioTests>

<!-- Skip scenario tests if the host architecture is different from the target architecture since the tests
require the ability to execute the built SDK. But the CLI is not capable of running on a host with a
require the ability to execute the built SDK. But the CLI is not capable of running on a host with a
different architecture (i.e. "cannot execute binary file: Exec format error"). -->
<_RunScenarioTests Condition="'$(BuildArchitecture.ToLowerInvariant())' != '$(TargetArchitecture.ToLowerInvariant())'">false</_RunScenarioTests>

Expand All @@ -18,12 +18,15 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(RepositoryEngineeringDir)extract-sdk-archive.proj" />
<ProjectReference Include="Microsoft.DotNet.SourceBuild.SmokeTests\Microsoft.DotNet.SourceBuild.SmokeTests.csproj"
Condition="'$(DotNetBuildSourceOnly)' == 'true'" />
<ProjectReference Include="Microsoft.DotNet.UnifiedBuild.Tests\Microsoft.DotNet.UnifiedBuild.Tests.csproj"
Condition="'$(ShortStack)' != 'true' and '$(PortableBuild)' == 'true' and '$(PgoInstrument)' != 'true'" />
<ProjectReference Include="scenario-tests\scenario-tests.proj" Condition="'$(_RunScenarioTests)' == 'true'" />

<!-- Make sure that the sdk archive is extracted before running the scenario-tests. Need to do this here as it's hard
to define the dependency directly in scneario-tests.proj. -->
<ProjectReference Include="$(RepositoryEngineeringDir)extract-sdk-archive.proj" BuildInParallel="false" />
<ProjectReference Include="$(RepoProjectsDir)scenario-tests.proj" Condition="'$(_RunScenarioTests)' == 'true'" BuildInParallel="false" />
</ItemGroup>

</Project>
Loading