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

Enable scenario test execution in VMR build #19222

Merged
merged 55 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6611f11
Enable scenario test execution in VMR build
mthalman Mar 27, 2024
4790dc9
Merge branch 'main' into sb3819-scenario-tests
mthalman Apr 1, 2024
aa1f65e
Update descriptions of script options
mthalman Apr 1, 2024
81af398
Provide option to specify the test projects to run
mthalman Apr 1, 2024
b74d5fb
Use "archive" instead of "tarball"
mthalman Apr 2, 2024
5599561
Merge branch 'main' into sb3819-scenario-tests
mthalman Apr 4, 2024
28ddf27
Revert test project selection option
mthalman Apr 4, 2024
1b4412e
Delete runTests param usage for Shortstack jobs
mthalman Apr 4, 2024
f5a97a3
Move extraction of SDK to installer
mthalman Apr 10, 2024
6450dbc
Delete unnecessary local package feed
mthalman Apr 10, 2024
7e91377
Update testRunner name
mthalman Apr 10, 2024
4ad4063
Update ExtractScenarioTestsPackage target name
mthalman Apr 10, 2024
7bef2e3
Move more test execution MSBuild logic to scenario-tests
mthalman Apr 11, 2024
54ca111
Merge branch 'main' into sb3819-scenario-tests
mthalman Apr 17, 2024
2621b96
Integrate with test infra after merge from main
mthalman Apr 17, 2024
49c04fc
Remove unnecessary changes in build.ps1
mthalman Apr 18, 2024
877fc86
Clean up pipeline
mthalman Apr 18, 2024
d979155
Clean up D.B.props
mthalman Apr 18, 2024
c56edf5
Skip scenario tests for cross platform scenarios
mthalman Apr 18, 2024
3de2045
Merge branch 'main' into sb3819-scenario-tests
mthalman Apr 18, 2024
fa6b2e4
Revert refactoring of DetermineSourceBuiltSdkVersion
mthalman Apr 19, 2024
41b46b4
Move SDK extraction
mthalman Apr 19, 2024
09b93d4
Run build/test from repo-project
mthalman Apr 22, 2024
8e9b075
Delete obsolete pipeline step
mthalman Apr 22, 2024
7bb0e4a
Clarify path for scenario-tests test results for publishing
mthalman Apr 22, 2024
b7bf1bb
Consume BuildArchitecture property
mthalman Apr 22, 2024
1c9cdd7
Use proj reference for scenario-tests
mthalman Apr 23, 2024
9745f7a
Allow scenario tests to run on Windows
mthalman Apr 23, 2024
069f2a6
Set targetOS for Alpine SB legs
mthalman Apr 23, 2024
1760ffa
disable cleaning for scenario tests repo
mthalman Apr 23, 2024
ef2a81a
Merge branch 'main' into sb3819-scenario-tests
mthalman Apr 23, 2024
1e5f256
Use BuildOS instead of OS property
mthalman Apr 23, 2024
4176797
Fix disabling of build clean for scenario-tests
mthalman Apr 24, 2024
def2454
Add back missing symbol task fix
mthalman Apr 24, 2024
f7e0a03
Fix repository name for clean
mthalman Apr 24, 2024
479d957
Remove ContinueOnError to allow non-zero exit code
mthalman Apr 24, 2024
71a9649
Fixes to call scenario tests
mthalman Apr 24, 2024
c39accb
Revert property name changes for UB tests
mthalman Apr 24, 2024
0da9a75
Fix property name typo
mthalman Apr 24, 2024
003fbc4
Set _InitializeDotNetCli to support custom SDK (source build)
mthalman Apr 24, 2024
c0f5a56
Override CleanWhileBuilding in scenario-tests.proj
mthalman Apr 25, 2024
d14add1
Set fx-version
mthalman Apr 25, 2024
cb6d71a
Use local package feed to support DevVersions leg
mthalman Apr 25, 2024
d2d54f5
Revert "Use local package feed to support DevVersions leg"
mthalman Apr 25, 2024
3575d65
Revert "Set fx-version"
mthalman Apr 25, 2024
a5b08c2
Disable scenario tests for unofficial build versioning
mthalman Apr 25, 2024
9b2c707
Delete src/SourceBuild/content/test/scenario-tests.proj
ViktorHofer Apr 26, 2024
83b9e46
Apply suggestions from code review
mthalman Apr 26, 2024
497ba53
Fix binlog option to work for windows
mthalman Apr 26, 2024
75a5684
Fix typo
mthalman Apr 26, 2024
2574442
Merge branch 'main' into sb3819-scenario-tests
mthalman Apr 26, 2024
ee9f229
Publish binlogs from scenario tests
mthalman Apr 26, 2024
1d24ea4
Publish binlogs from scenario tests for windows
mthalman Apr 29, 2024
bf33d8c
Patches to disable scenario tests
mthalman Apr 30, 2024
54b299a
Merge branch 'main' into sb3819-scenario-tests
mthalman Apr 30, 2024
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: 23 additions & 6 deletions eng/pipelines/templates/jobs/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ jobs:
set -ex

dockerVolumeArgs="-v $(sourcesPath):/vmr"
sourceOnlyArgs=''
customBuildArgs=''
extraBuildProperties=''

if [[ ! -z '${{ parameters.targetOS }}' ]]; then
Expand All @@ -374,11 +374,15 @@ jobs:
extraBuildProperties="$extraBuildProperties /p:TargetArchitecture=${{ parameters.targetArchitecture }}"
fi

if [[ '${{ parameters.useDevVersions }}' == 'True' ]]; then
customBuildArgs="$customBuildArgs --dev"
fi

if [[ '${{ parameters.buildSourceOnly }}' == 'True' ]]; then
if [[ '${{ parameters.enablePoison }}' == 'True' ]]; then
sourceOnlyArgs='--poison'
customBuildArgs="$customBuildArgs --poison"
fi
sourceOnlyArgs="$sourceOnlyArgs --source-only /p:SmokeTestsWarnOnSdkContentDiffs=true /p:SmokeTestsExcludeOmniSharpTests=${{ parameters.excludeOmniSharpTests }}"
customBuildArgs="$customBuildArgs --source-only /p:SmokeTestsWarnOnSdkContentDiffs=true /p:SmokeTestsExcludeOmniSharpTests=${{ parameters.excludeOmniSharpTests }}"
fi

if [[ -n "${{ parameters.extraProperties }}" ]]; then
Expand All @@ -387,10 +391,10 @@ jobs:

# Only use Docker when a container is specified
if [[ -n "${{ parameters.container }}" ]]; then
docker run --rm $dockerVolumeArgs -w /vmr ${{ parameters.container }} ./build.sh /bl:artifacts/log/Release/Test.binlog --test $sourceOnlyArgs $extraBuildProperties $(additionalBuildArgs)
docker run --rm $dockerVolumeArgs -w /vmr ${{ parameters.container }} ./build.sh /bl:artifacts/log/Release/Test.binlog --test $customBuildArgs $extraBuildProperties $(additionalBuildArgs)
else
cd $(sourcesPath)
./build.sh /bl:artifacts/log/Release/Test.binlog --test $sourceOnlyArgs $extraBuildProperties $(additionalBuildArgs)
./build.sh /bl:artifacts/log/Release/Test.binlog --test $customBuildArgs $extraBuildProperties $(additionalBuildArgs)
fi

displayName: Run Tests
Expand Down Expand Up @@ -474,18 +478,31 @@ jobs:

# Only upload test results if enabled
- ${{ if eq(parameters.runTests, 'True') }}:

mthalman marked this conversation as resolved.
Show resolved Hide resolved
- task: PublishTestResults@2
displayName: Publish Test Results
condition: succeededOrFailed()
continueOnError: true
inputs:
testRunner: vSTest
testRunner: VSTest
testResultsFiles: 'artifacts/TestResults/Release/*.trx'
searchFolder: $(sourcesPath)
mergeTestResults: true
publishRunAttachments: true
testRunTitle: Tests_$(Agent.JobName)

- task: PublishTestResults@2
displayName: Publish Scenario Test Results
condition: succeededOrFailed()
continueOnError: true
inputs:
testRunner: xUnit
testResultsFiles: 'artifacts/TestResults/**/scenario-tests/*.xml'
searchFolder: $(sourcesPath)
mergeTestResults: true
publishRunAttachments: true
testRunTitle: ScenarioTests_$(Agent.JobName)

- task: CopyFiles@2
inputs:
SourceFolder: $(sourcesPath)/artifacts
Expand Down
2 changes: 2 additions & 0 deletions eng/pipelines/templates/stages/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ stages:
artifactsRid: alpine.3.19-x64
pool: ${{ parameters.pool_Linux }}
container: ${{ variables.alpine319Container }}
targetOS: linux-musl
buildFromArchive: false # 🚫
buildSourceOnly: true #
enablePoison: true #
Expand All @@ -143,6 +144,7 @@ stages:
architecture: x64
pool: ${{ parameters.pool_Linux }}
container: ${{ variables.alpine319Container }}
targetOS: linux-musl
buildFromArchive: false # 🚫
buildSourceOnly: true #
enablePoison: false # 🚫
Expand Down
1 change: 1 addition & 0 deletions src/SourceBuild/content/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<IntermediateSymbolsRootDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'Symbols'))</IntermediateSymbolsRootDir>
<AssetManifestsIntermediateDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'AssetManifests'))</AssetManifestsIntermediateDir>
<ArtifactsAssetsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'assets', '$(Configuration)'))</ArtifactsAssetsDir>
<DotNetSdkExtractDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'extracted-dotnet-sdk'))</DotNetSdkExtractDir>

<PrebuiltPackagesPath>$([MSBuild]::NormalizeDirectory('$(PrereqsPackagesDir)', 'prebuilt'))</PrebuiltPackagesPath>
<PreviouslyRestoredPackagesPath>$([MSBuild]::NormalizeDirectory('$(PrereqsPackagesDir)', 'previouslyRestored'))</PreviouslyRestoredPackagesPath>
Expand Down
2 changes: 1 addition & 1 deletion src/SourceBuild/content/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ while [[ $# > 0 ]]; do
;;

# Advanced settings
-build-tests)
-build-repo-tests)
properties="$properties /p:DotNetBuildTests=true"
;;
-ci)
Expand Down
2 changes: 1 addition & 1 deletion src/SourceBuild/content/eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $targets = "/t:Build"
# This repo uses the VSTest integration instead of the Arcade Test target
if ($test) {
$project = Join-Path (Join-Path $RepoRoot "test") "tests.proj"
$targets += ";VSTest"
$targets = "$targets;VSTest"
mthalman marked this conversation as resolved.
Show resolved Hide resolved
}

if ($buildRepoTests) {
Expand Down
18 changes: 18 additions & 0 deletions src/SourceBuild/content/eng/extract-sdk-archive.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.Build.NoTargets">

<PropertyGroup>
<TargetFramework>$(NetCurrent)</TargetFramework>
</PropertyGroup>

<Target Name="ExtractSdkArchive" BeforeTargets="AfterBuild" DependsOnTargets="DetermineSourceBuiltSdkVersion">
mthalman marked this conversation as resolved.
Show resolved Hide resolved

mthalman marked this conversation as resolved.
Show resolved Hide resolved
<MakeDir Directories="$(DotNetSdkExtractDir)" />
<Exec Condition="'$(ArchiveExtension)' == '.tar.gz'"
Command="tar -xzf $(SdkTarballPath) -C $(DotNetSdkExtractDir)" />
<Unzip Condition="'$(ArchiveExtension)' == '.zip'"
SourceFiles="$(SdkTarballPath)"
DestinationFolder="$(DotNetSdkExtractDir)" />

mthalman marked this conversation as resolved.
Show resolved Hide resolved
</Target>

</Project>
8 changes: 2 additions & 6 deletions src/SourceBuild/content/eng/finish-source-only.proj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="$(TasksDir)Microsoft.DotNet.UnifiedBuild.Tasks\Microsoft.DotNet.UnifiedBuild.Tasks.csproj" />
<ProjectReference Include="$(TasksDir)Microsoft.DotNet.SourceBuild.Tasks.LeakDetection\Microsoft.DotNet.SourceBuild.Tasks.LeakDetection.csproj" />
<ProjectReference Include="$(RepositoryEngineeringDir)extract-sdk-archive.proj" />
<ProjectReference Include="$(RepositoryEngineeringDir)merge-asset-manifests.proj" />
</ItemGroup>

Expand Down Expand Up @@ -59,13 +60,9 @@
Outputs="$(SdkSymbolsTarball)">
<PropertyGroup>
<IntermediateSdkSymbolsLayout>$(BaseIntermediateOutputPath)SdkSymbols</IntermediateSdkSymbolsLayout>
<IntermediateSdkLayout>$(BaseIntermediateOutputPath)Sdk</IntermediateSdkLayout>
</PropertyGroup>

<MakeDir Directories="$(IntermediateSdkLayout)" />
<Exec Command="tar -xzf $(SdkTarballPath) -C $(IntermediateSdkLayout)" />

<CreateSdkSymbolsLayout SdkLayoutPath="$(IntermediateSdkLayout)"
<CreateSdkSymbolsLayout SdkLayoutPath="$(DotNetSdkExtractDir)"
AllSymbolsPath="$(IntermediateSymbolsRootDir)"
SdkSymbolsLayoutPath="$(IntermediateSdkSymbolsLayout)"
FailOnMissingPDBs="false" />
Expand All @@ -76,7 +73,6 @@
<Message Importance="High" Text="Packaged sdk symbols in '$(SdkSymbolsTarball)'" />

<RemoveDir Directories="$(IntermediateSdkSymbolsLayout)" />
<RemoveDir Directories="$(IntermediateSdkLayout)" />
</Target>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ private IList<string> GenerateSymbolsLayout(Hashtable allPdbGuids)
{
// Copy matching pdb to symbols path, preserving sdk binary's hierarchy
string sourcePath = (string)allPdbGuids[debugId]!;
string fileRelativePath = file.Substring(SdkLayoutPath.Length);
string destinationPath =
file.Replace(SdkLayoutPath, SdkSymbolsLayoutPath)
Path.Combine(SdkSymbolsLayoutPath, fileRelativePath)
.Replace(Path.GetFileName(file), Path.GetFileName(sourcePath));

Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)!);
Expand Down
11 changes: 11 additions & 0 deletions src/SourceBuild/content/repo-projects/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
<BuildArgs>$(BuildArgs) /p:ReferencePackageNupkgCacheDir="$(ReferencePackagesDir)"</BuildArgs>
</PropertyGroup>

<PropertyGroup>
<TestActions>$(FlagParameterPrefix)restore</TestActions>
<TestActions>$(TestActions) $(FlagParameterPrefix)test</TestActions>

<TestArgs>$(FlagParameterPrefix)ci</TestArgs>
mthalman marked this conversation as resolved.
Show resolved Hide resolved
<TestArgs>$(TestArgs) $(FlagParameterPrefix)configuration $(Configuration)</TestArgs>
<TestArgs>$(TestArgs) -bl:artifacts/log/$(Configuration)/Test.binlog</TestArgs>

<TestCommand>$(BuildScript) $(TestActions) $(TestArgs)</TestCommand>
</PropertyGroup>

<PropertyGroup Condition="'$(EnableExtraDebugging)' == 'true'">
<MSBuildDebugPathTargetDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'msbuild-debug'))</MSBuildDebugPathTargetDir>
<RoslynDebugPathTargetDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'roslyn-debug'))</RoslynDebugPathTargetDir>
Expand Down
2 changes: 2 additions & 0 deletions src/SourceBuild/content/repo-projects/installer.proj
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@
<Target Name="CopySdkArchive"
AfterTargets="Build"
DependsOnTargets="DetermineSourceBuiltSdkVersion">

mthalman marked this conversation as resolved.
Show resolved Hide resolved
<Copy SourceFiles="$(SdkTarballPath)"
DestinationFolder="$(ArtifactsAssetsDir)"
SkipUnchangedFiles="true"
UseHardlinksIfPossible="true" />

mthalman marked this conversation as resolved.
Show resolved Hide resolved
</Target>

</Project>
56 changes: 55 additions & 1 deletion src/SourceBuild/content/repo-projects/scenario-tests.proj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Project Sdk="Microsoft.Build.NoTargets" TreatAsLocalProperty="CleanWhileBuilding">

<ItemGroup>
<RepositoryReference Include="arcade" />
Expand All @@ -10,4 +10,58 @@
<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>
<_InstallerNuGetConfig>$(RepoRoot)src/installer/NuGet.config</_InstallerNuGetConfig>
</PropertyGroup>
mthalman marked this conversation as resolved.
Show resolved Hide resolved

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

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

</Target>

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

<PropertyGroup>
<_CurrentDateTime>$([System.DateTime]::Now.ToString("yyyy-MM-dd_HH_mm_ss"))</_CurrentDateTime>
<_TestXmlOutputPath>$(ScenarioTestsResultsDir)$(_CurrentDateTime).xml</_TestXmlOutputPath>
<_ScenarioTestsAdditionalArgs>--xml $(_TestXmlOutputPath) --target-rid $(TargetRid) --no-cleanup --no-traits Category=MultiTFM</_ScenarioTestsAdditionalArgs>

<!-- Define the test root as a sub-directory of the scenario test artifacts directory. It needs to be a sub-directory because the scenario test execution
will clean that directory. Since we need the NuGet.config file that we copied in to be preserved, that's stored in the directory above the test root. -->
<_TestRoot>$(ScenarioTestsArtifactsDir)artifacts/</_TestRoot>

<!-- It's necessary to explicitly define the path to the dotnet tool to prevent Arcade from attempting to derive it. Otherwise, it will run the dotnet
install script to get a new one. We must use the locally built SDK instead in order to support non-portable RIDs for source build. -->
<_DotNetTool Condition="'$(BuildOS)' == 'windows'">$(DotNetSdkExtractDir)dotnet.exe</_DotNetTool>
<_DotNetTool Condition="'$(BuildOS)' != 'windows'">$(DotNetSdkExtractDir)dotnet</_DotNetTool>
</PropertyGroup>
mthalman marked this conversation as resolved.
Show resolved Hide resolved

<MakeDir Directories="$(ScenarioTestsResultsDir)" />

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

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

</Project>
53 changes: 53 additions & 0 deletions src/SourceBuild/content/test/scenario-tests.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<Project Sdk="Microsoft.Build.Traversal">
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved

<PropertyGroup>
<ScenarioTestsArtifactsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'scenario-tests'))</ScenarioTestsArtifactsDir>
<ScenarioTestsResultsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsTestResultsDir)', 'scenario-tests'))</ScenarioTestsResultsDir>
<_ScenarioTestsNuGetConfig>$(ScenarioTestsArtifactsDir)NuGet.config</_ScenarioTestsNuGetConfig>
<_InstallerNuGetConfig>$(RepoRoot)src/installer/NuGet.config</_InstallerNuGetConfig>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../src/scenario-tests/src/**/*.csproj" />
</ItemGroup>

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

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

</Target>

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

<PropertyGroup>
<_CurrentDateTime>$([System.DateTime]::Now.ToString("yyyy-MM-dd_HH_mm_ss"))</_CurrentDateTime>
<_TestXmlOutputPath>$(ScenarioTestsResultsDir)$(_CurrentDateTime).xml</_TestXmlOutputPath>
<_ScenarioTestsAdditionalArgs>--xml $(_TestXmlOutputPath) --target-rid $(TargetRid) --no-cleanup --no-traits Category=MultiTFM</_ScenarioTestsAdditionalArgs>

<!-- Define the test root as a sub-directory of the scenario test artifacts directory. It needs to be a sub-directory because the scenario test execution
will clean that directory. Since we need the NuGet.config file that we copied in to be preserved, that's stored in the directory above the test root. -->
<_TestRoot>$(ScenarioTestsArtifactsDir)artifacts/</_TestRoot>
</PropertyGroup>

<MakeDir Directories="$(ScenarioTestsResultsDir)" />

<ItemGroup>
<_ScenarioTestProperties Include="
Configuration=$(Configuration);
RunScenarioTests=true;
TestRoot=$(_TestRoot);
DotNetRoot=$(DotNetSdkExtractDir);
NETCoreSdkVersion=$(SourceBuiltSdkVersion);
AdditionalTestArgs=$(_ScenarioTestsAdditionalArgs);
DOTNET_INSTALL_DIR=$(DotNetRoot)" />
</ItemGroup>

<MSBuild Projects="$(MSBuildThisFileFullPath)"
Properties="@(_ScenarioTestProperties)"
Targets="Restore;Build;Test" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />

<!-- scenario-tests test execution requires a custom test target. -->
<Target Name="Test" DependsOnTargets="RunScenarioTests" />
<Target Name="VSTest" DependsOnTargets="RunScenarioTests" />

</Project>
16 changes: 16 additions & 0 deletions src/SourceBuild/content/test/scenario-tests/scenario-tests.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
mthalman marked this conversation as resolved.
Show resolved Hide resolved
<TargetFramework>$(NetCurrent)</TargetFramework>
<IsTestProject>true</IsTestProject>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my own understanding, why did you need to add this property?

</PropertyGroup>

<!-- Scenarios tests are handled separately from the other test projects. This is because the output of the scenario tests is
an executable that is used to run the tests and so using the VSTest runner doesn't work with them. They also require
some setup steps to be configured with the VMR. -->
<Target Name="RunScenarioTests">
<MSBuild Projects="$(RepoProjectsDir)scenario-tests.proj"
Properties="Configuration=$(Configuration)"
Targets="RunScenarioTests" />
</Target>

</Project>
21 changes: 20 additions & 1 deletion src/SourceBuild/content/test/tests.proj
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
<Project Sdk="Microsoft.Build.Traversal">

<PropertyGroup>
<_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
different architecture (i.e. "cannot execute binary file: Exec format error"). -->
<_RunScenarioTests Condition="'$(BuildArchitecture.ToLower())' != '$(TargetArchitecture.ToLower())'">false</_RunScenarioTests>
mthalman marked this conversation as resolved.
Show resolved Hide resolved

<!-- Skip scenario tests if the portable OS (determined from the host machine) is different from the target OS
since the tests require the ability to execute the built SDK. An example of where this would be disabled is
cross-build of using Mariner to build for Alpine (linux vs linux-musl). -->
<_RunScenarioTests Condition="'$(BuildOS)' != 'windows' and '$(__PortableTargetOS.ToLower())' != '$(TargetOS.ToLower())'">false</_RunScenarioTests>
mthalman marked this conversation as resolved.
Show resolved Hide resolved

<!-- The scenario tests are not supported when unofficial build versioning is used. -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file a tracking issue for that and link to it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<_RunScenarioTests Condition="'$(UseOfficialBuildVersioning)' == 'false'">false</_RunScenarioTests>
</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'" />
</ItemGroup>

</Project>
</Project>
Loading