summaryrefslogtreecommitdiff
path: root/packages/microsoft.dotnet.buildtools/2.1.0-rc1-02804-05/lib/tests.targets
diff options
context:
space:
mode:
Diffstat (limited to 'packages/microsoft.dotnet.buildtools/2.1.0-rc1-02804-05/lib/tests.targets')
-rwxr-xr-xpackages/microsoft.dotnet.buildtools/2.1.0-rc1-02804-05/lib/tests.targets559
1 files changed, 559 insertions, 0 deletions
diff --git a/packages/microsoft.dotnet.buildtools/2.1.0-rc1-02804-05/lib/tests.targets b/packages/microsoft.dotnet.buildtools/2.1.0-rc1-02804-05/lib/tests.targets
new file mode 100755
index 0000000000..a86d2c28bf
--- /dev/null
+++ b/packages/microsoft.dotnet.buildtools/2.1.0-rc1-02804-05/lib/tests.targets
@@ -0,0 +1,559 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <!-- This is the target that copies the test assets to the test output -->
+ <Import Project="$(MSBuildThisFileDirectory)publishtest.targets" />
+ <Import Project="$(ToolsDir)PerfTesting.targets" Condition="Exists('$(ToolsDir)PerfTesting.targets') and '$(Performance)' == 'true'"/>
+ <UsingTask TaskName="GenerateTestExecutionScripts" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
+ <UsingTask TaskName="GetTargetMachineInfo" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
+ <UsingTask Condition="'$(BuildingUAPVertical)' == 'true'" TaskName="ExtractResWResourcesFromAssemblies" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
+
+ <!-- Which categories of tests to run by default -->
+ <PropertyGroup>
+ <TestDisabled>false</TestDisabled>
+ <TestDisabled Condition="'$(IsTestProject)'!='true' Or '$(SkipTests)'=='true' Or '$(RunTestsForProject)'=='false'">true</TestDisabled>
+ <TestsSuccessfulSemaphore>tests.passed</TestsSuccessfulSemaphore>
+ </PropertyGroup>
+
+ <!-- In case that TestPath is not yet set, default it here -->
+ <PropertyGroup>
+ <TestPath Condition="'$(TestPath)'==''">$(OutDir)</TestPath>
+ </PropertyGroup>
+
+ <!-- In case that XunitPerfMaxIteration is not yet set, default it here -->
+ <PropertyGroup>
+ <XunitPerfMaxIteration Condition="'$(XunitPerfMaxIteration)'==''">1</XunitPerfMaxIteration>
+ <XunitPerfMaxIterationInner Condition="'$(XunitPerfMaxIterationInner)'==''">1</XunitPerfMaxIterationInner>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <!-- Split semicolon separated lists -->
+ <WithCategoriesItems Include="$(WithCategories)" />
+ <WithoutCategoriesItems Include="$(WithoutCategories)" />
+ <DefaultNoCategories Include="$(DefaultNoCategories)" />
+ <UnsupportedPlatformsItems Include="$(UnsupportedPlatforms)"/>
+ </ItemGroup>
+
+ <PropertyGroup Condition="'$(BuildingNETFxVertical)' != 'true'">
+ <XunitRuntimeConfig>$(ToolsDir)\xunit.console.netcore.runtimeconfig.json</XunitRuntimeConfig>
+ <TestRuntimeEnvVar Condition="'$(RunningOnUnix)'!='true'">%RUNTIME_PATH%\</TestRuntimeEnvVar>
+ <TestRuntimeEnvVar Condition="'$(RunningOnUnix)'=='true'">$RUNTIME_PATH/</TestRuntimeEnvVar>
+ <TestHostExecutablePath Condition="'$(RunningOnUnix)'!='true' AND '$(TestHostExecutablePath)' == '' AND '$(BuildingUAPAOTVertical)' != 'true'">$(TestRuntimeEnvVar)dotnet.exe</TestHostExecutablePath>
+ <TestHostExecutablePath Condition="'$(RunningOnUnix)'=='true' AND '$(TestHostExecutablePath)' == '' AND '$(BuildingUAPAOTVertical)' != 'true'">$(TestRuntimeEnvVar)dotnet</TestHostExecutablePath>
+
+ <XunitExecutable Condition="'$(XunitExecutable)' == ''">xunit.console.netcore.exe</XunitExecutable>
+
+ <DebugEngines>{2E36F1D4-B23C-435D-AB41-18E608940038}</DebugEngines>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(BuildingNETFxVertical)' == 'true'">
+ <XunitExecutable Condition="'$(XunitExecutable)' == ''">xunit.console.exe</XunitExecutable>
+ </PropertyGroup>
+
+ <!-- General xunit options -->
+ <PropertyGroup>
+ <XunitResultsFileName>testResults.xml</XunitResultsFileName>
+
+ <_XunitOptions Condition="'$(BuildingNETFxVertical)' == 'true'">$(_XunitOptions) -noshadow</_XunitOptions>
+ <_XunitOptions Condition="'$(BuildingNETFxVertical)' == 'true' and '$(XUnitNoAppdomain)' == 'true'">$(_XunitOptions) -noappdomain </_XunitOptions>
+ <_XunitOptions>$(_XunitOptions) -xml $(XunitResultsFileName)</_XunitOptions>
+
+ <_XunitOptions Condition="'$(Performance)'!='true' and '$(Outerloop)' != 'true'">$(_XunitOptions) -notrait Benchmark=true</_XunitOptions>
+ <!-- Don't run performance tests in parallel, even in "functional" outerloop runs. -->
+ <_XunitOptions Condition="'$(Performance)'!='true' and '$(Outerloop)' == 'true' and '$(IncludePerformanceTests)' == 'true'">$(_XunitOptions) -parallel none</_XunitOptions>
+ <_XunitOptions Condition="'$(BuildingUAPAOTVertical)'=='true'">$(_XunitOptions) -redirectoutput</_XunitOptions>
+ <_XunitOptions>$(_XunitOptions) -notrait category=non$(_bc_TargetGroup)tests</_XunitOptions>
+
+ <TargetOS Condition="'$(TargetOS)' == ''">$(DefaultOSGroup)</TargetOS>
+ <TargetOSTrait Condition="'$(TargetOS)'=='Windows_NT'">nonwindowstests</TargetOSTrait>
+ <TargetOSTrait Condition="'$(TargetOS)'=='Linux'">nonlinuxtests</TargetOSTrait>
+ <TargetOSTrait Condition="'$(TargetOS)'=='OSX'">nonosxtests</TargetOSTrait>
+ <TargetOSTrait Condition="'$(TargetOS)'=='FreeBSD'">nonfreebsdtests</TargetOSTrait>
+ <TargetOSTrait Condition="'$(TargetOS)'=='NetBSD'">nonnetbsdtests</TargetOSTrait>
+ <_XunitOptions Condition="'$(TargetOSTrait)' != ''">$(_XunitOptions) -notrait category=$(TargetOSTrait)</_XunitOptions>
+
+ <_XunitOptions Condition="'$(XunitMaxThreads)'!=''">$(_XunitOptions) -maxthreads $(XunitMaxThreads)</_XunitOptions>
+ <_XunitOptions Condition="'$(XunitOptions)' != ''">$(_XunitOptions) $(XunitOptions)</_XunitOptions>
+ <_XunitOptions Condition="'$(XunitMethodName)' != ''">$(_XunitOptions) -method $(XunitMethodName)</_XunitOptions>
+ <_XunitOptions Condition="'$(XunitClassName)' != ''">$(_XunitOptions) -class $(XunitClassName)</_XunitOptions>
+ <_XunitOptions Condition="'$(XunitShowProgress)' == 'true' and '$(BuildingNETFxVertical)' != 'true'">$(_XunitOptions) -showprogress</_XunitOptions>
+ <XunitTestAssembly Condition="'$(XunitTestAssembly)' == ''">$(TargetFileName)</XunitTestAssembly>
+ <XunitArguments>$(XunitTestAssembly) $(_XunitOptions)</XunitArguments>
+
+ <TestProgram Condition="'$(TestHostExecutablePath)'!=''">$(TestHostExecutablePath)</TestProgram>
+ <TestArguments Condition="'$(TestHostExecutablePath)'!=''">$(XunitExecutable) $(XunitArguments)</TestArguments>
+
+ <TestProgram Condition="'$(TestHostExecutablePath)'==''">$(XunitExecutable)</TestProgram>
+ <TestArguments Condition="'$(TestHostExecutablePath)'==''">$(XunitArguments)</TestArguments>
+
+ <TestCommandLine Condition="'$(Performance)'!='true'">$(TestProgram) $(TestArguments) {XunitTraitOptions}</TestCommandLine>
+
+ <!-- set $(TestDebugger) to eg c:\debuggers\windbg.exe to run tests under a debugger -->
+ <TestCommandLine Condition="'$(TestDebugger)' != '' and !$(TestDebugger.Contains('devenv'))">$(TestDebugger) $(TestCommandLine)</TestCommandLine>
+ <TestCommandLine Condition="'$(TestDebugger)' != '' and $(TestDebugger.Contains('devenv'))">$(TestDebugger) /debugexe $(TestCommandLine)</TestCommandLine>
+
+ </PropertyGroup>
+
+ <!-- The Code Coverage targets will override TestHost and TestCommandLine if coverage is enabled -->
+ <Import Project="$(MSBuildThisFileDirectory)CodeCoverage.targets" />
+
+ <!-- In VS (2015 Preview or later currently required): Debug to run unit tests on CoreCLR. -->
+ <PropertyGroup Condition="'$(IsTestProject)'=='true'">
+ <StartWorkingDirectory Condition="'$(StartWorkingDirectory)'==''">$(TestPath)</StartWorkingDirectory>
+ <StartAction Condition="'$(StartAction)'==''">Program</StartAction>
+ <StartProgram Condition="'$(StartProgram)'==''">$(TestHostRootPath)dotnet.exe</StartProgram>
+ <StartArguments Condition="'$(StartArguments)'==''">$(TestArguments) -wait -parallel none</StartArguments>
+ </PropertyGroup>
+
+ <Target Name="DiscoverTestInputs" DependsOnTargets="ResolveReferences;GetCopyToOutputDirectoryItems">
+ <ItemGroup>
+ <RunTestsForProjectInputs Include="@(ReferenceCopyLocalPaths)" />
+ <RunTestsForProjectInputs Include="@(Content)" />
+ <RunTestsForProjectInputs Include="@(IntermediateAssembly)" />
+ <RunTestsForProjectInputs Include="@(_DebugSymbolsIntermediatePath)" />
+ <RunTestsForProjectInputs Include="@(AllItemsFullPathWithTargetPath)" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(BuildingNETFxVertical)' != 'true'">
+ <SupplementalTestData Condition="'$(SkipXunitRuntimeConfigCopying)' != 'true'" Include="$(XunitRuntimeConfig)" />
+ <SupplementalTestData Include="$(RuntimePath)xunit.console.netcore.exe" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(BuildingNETFxVertical)' == 'true'">
+ <SupplementalTestData Include="$(RuntimePath)xunit.console.exe" />
+ <SupplementalTestData Include="$(RuntimePath)xunit.execution.desktop.dll" />
+ </ItemGroup>
+ </Target>
+
+ <Target Name="AddDefaultTestReferences" BeforeTargets="SetupDefaultReferences">
+ <ItemGroup Condition="'$(IsTestProject)'=='true' and '$(IncludeDefaultReferences)' == 'true'">
+ <TargetingPackExclusions Include="System.Runtime.WindowsRuntime.UI.Xaml" /> <!-- Harmless, but causes PRI targets to run -->
+ <TargetingPackExclusions Include="@(ReferenceFromRuntime)"/>
+
+ <!-- Whitelisted runtime assemblies that are OK to reference. -->
+ <ReferenceFromRuntime Include="xunit.core" />
+ <ReferenceFromRuntime Include="Xunit.NetCore.Extensions" />
+ <ReferenceFromRuntime Include="xunit.assert" />
+ <ReferenceFromRuntime Include="xunit.abstractions" />
+ <ReferenceFromRuntime Include="xunit.performance.core" />
+ <ReferenceFromRuntime Include="xunit.performance.api" />
+
+ <!-- Reference everything in the targeting pack directory -->
+ <TargetingPackItems Include="%(TargetingPackDirs.Identity)/*.dll" />
+
+ <DefaultReference Include="%(TargetingPackItems.Filename)" Exclude="@(TargetingPackExclusions)" />
+ </ItemGroup>
+ </Target>
+
+ <!-- We need to generate a simple config file for desktop test executors to tell them to use DEVPATH environment variable to use their dependencies from there.
+ DEVPATH is being set for desktop runs in RunTests.cmd to the TestHostPath. We need this approach to have desktop Helix runs. -->
+ <Target Name="CopyDesktopExecutorsConfigFiles"
+ BeforeTargets="GenerateTestExecutionScripts"
+ Condition="'$(BuildingNETFxVertical)' == 'true'">
+ <PropertyGroup>
+ <NETFxTestRunnerAppConfig Condition="'$(NETFxTestRunnerAppConfig)' == ''">$(ToolsDir)\DesktopRunnerConfigFile.config</NETFxTestRunnerAppConfig>
+ <XunitRunnerNETFxConfigFile>$(TestPath)\$(XunitExecutable).config</XunitRunnerNETFxConfigFile>
+ <RemoteExecutorConfigFile>$(TestPath)\RemoteExecutorConsoleApp.exe.config</RemoteExecutorConfigFile>
+ </PropertyGroup>
+
+ <Copy SourceFiles="$(NETFxTestRunnerAppConfig)"
+ DestinationFiles="$(XunitRunnerNETFxConfigFile)"
+ SkipUnchangedFiles="true"
+ />
+
+ <Copy Condition="Exists('$(TestPath)\RemoteExecutorConsoleApp.exe')"
+ SourceFiles="$(NETFxTestRunnerAppConfig)"
+ DestinationFiles="$(RemoteExecutorConfigFile)"
+ SkipUnchangedFiles="true"
+ />
+ </Target>
+
+ <!-- Properties needed to create resources.pri for UAP runner -->
+ <PropertyGroup Condition="'$(BuildingUAPVertical)' == 'true'">
+ <_CommonPriFile Condition="'$(_CommonPriFile)' == ''">$(RuntimePath)resw/resources.pri</_CommonPriFile>
+ <_TestSpecificPriFile>$(TestPath)resources.pri</_TestSpecificPriFile>
+ <_MakePriExecutable>$(ToolsDir)net46/makepri.exe</_MakePriExecutable>
+ <_MakePriHelpersDir>$(IntermediateOutputPath)makepri</_MakePriHelpersDir>
+ <_MakePriConfigTemplate>$(ToolsDir)MakePriConfigFile.xml</_MakePriConfigTemplate>
+ <_MakePriConfigFile>$(_MakePriHelpersDir)/ModifiedConfigFile.xml</_MakePriConfigFile>
+ <_ReswListFile>$(_MakePriHelpersDir)/reswlist.RESFILES</_ReswListFile>
+ <_PriListFile>$(_MakePriHelpersDir)/prilist.RESFILES</_PriListFile>
+ <_ExternalReswOutputPath>$(ResourcesFolderPath)/external/</_ExternalReswOutputPath>
+ </PropertyGroup>
+
+ <ItemGroup Condition="'$(BuildingUAPVertical)' == 'true'">
+ <_AllRuntimeDllFiles Include="$(RuntimePath)\*.dll" />
+ <_ExternalReswFiles Include="$(_ExternalReswOutputPath)*.resw" />
+
+ <!-- The first time the CreateReswFilesForExternalDependencies target is executed the itemgroup _ExternalReswFiles will be empty
+ and that will avoid the target from executing, so we add a dummy file if they are empty so that the target is executed the first time. -->
+ <_ExternalReswFiles Condition="@(_ExternalReswFiles) == ''" Include="$(_ExternalReswOutputPath)dummy.resw" />
+ </ItemGroup>
+
+ <Target Name="CreateReswFilesForExternalDependencies"
+ Condition="'$(BuildingUAPVertical)' == 'true' AND '$(ShouldSkipExternalResources)' != 'true'"
+ Inputs="@(_AllRuntimeDllFiles)"
+ Outputs="@(_ExternalReswFiles)">
+
+ <ExtractResWResourcesFromAssemblies InputAssemblies="@(_AllRuntimeDllFiles)"
+ OutputPath="$(_ExternalReswOutputPath)"
+ InternalReswDirectory="$(ResourcesFolderPath)" />
+
+ </Target>
+
+ <!-- This target the necessary config file in order to create the UAP runner's resources.pri file using MakePri.exe -->
+ <Target Name="CreateMakePriConfigFileFromTemplate"
+ Condition="'$(BuildingUAPVertical)' == 'true'"
+ Inputs="$(_MakePriConfigTemplate)"
+ Outputs="$(_MakePriConfigFile)">
+
+ <MakeDir Directories="$(_MakePriHelpersDir)" />
+
+ <WriteLinesToFile File="$(_MakePriConfigFile)"
+ Lines="$([System.IO.File]::ReadAllText('$(_MakePriConfigTemplate)').Replace('{reswfilelist}', '$(_ReswListFile)').Replace('{prireslist}', '$(_PriListFile)'))"
+ Overwrite="true" />
+
+ <ItemGroup>
+ <FileWrites Include="$(_MakePriConfigFile)" />
+ </ItemGroup>
+
+ </Target>
+
+ <!-- This target gets all the resw files to be used to create the UAP runner's resources.pri file -->
+ <Target Name="CalculateResWFiles"
+ Condition="'$(BuildingUAPVertical)' == 'true'"
+ DependsOnTargets="CreateReswFilesForExternalDependencies">
+
+ <ItemGroup>
+ <_TestResWFiles Include="$(TestResourcesFolderPath)\*.resw" />
+ <_CommonResWFiles Include="$(ResourcesFolderPath)\**\*.resw" />
+ </ItemGroup>
+ </Target>
+
+ <!-- This target creates a resources.pri file that contains all the framework resources, this is a common file used by all of our test assemblies that have no specific resources. -->
+ <Target Name="MakeCommonResourcesPriFile"
+ DependsOnTargets="CalculateResWFiles;CreateMakePriConfigFileFromTemplate"
+ Condition="'$(BuildingUAPVertical)' == 'true'"
+ Inputs="@(_CommonResWFiles)"
+ Outputs="$(_CommonPriFile)">
+
+ <!-- We write the list of resw files that have to be indexed by makepri.exe -->
+ <WriteLinesToFile File="$(_ReswListFile)"
+ Lines="@(_CommonResWFiles)"
+ Overwrite="true" />
+
+ <!-- We write the list of base pri files to merge with the resw files by makepri.exe -->
+ <WriteLinesToFile File="$(_PriListFile)"
+ Lines="$(TestHostRootPath)\Runner\resources.pri"
+ Overwrite="true" />
+
+ <PropertyGroup>
+ <_MakePriCommand>$(_MakePriExecutable) versioned /o /pr "$(TestHostRootPath)\Runner" /cf "$(_MakePriConfigFile)" /of "$(_CommonPriFile)" /if "$(TestHostRootPath)\Runner\resources.pri"</_MakePriCommand>
+ </PropertyGroup>
+
+ <!-- We call MakePri.exe to create common resources.pri file -->
+ <Exec Command="$(_MakePriCommand)" StandardOutputImportance="Low" StdErrEncoding="Unicode"/>
+
+ <ItemGroup>
+ <FileWrites Include="$(_CommonPriFile)" />
+ </ItemGroup>
+
+ </Target>
+
+ <!-- This target creates the resources.pri file for every test assembly in order to be able to run the tests inside an appx. -->
+ <Target Name="MakeTestSpecificResourcesPriFile"
+ DependsOnTargets="MakeCommonResourcesPriFile"
+ Condition="'$(BuildingUAPVertical)' == 'true'">
+
+ <!-- We write the list of resw files that have to be indexed by makepri.exe only if this test project has its own resources. -->
+ <WriteLinesToFile Condition="'$(TestProjectNeedsModifiedPriFile)' == 'true'"
+ File="$(_ReswListFile)"
+ Lines="@(_TestResWFiles)"
+ Overwrite="true" />
+
+ <!-- We write the list of base pri files to merge with the resw files by makepri.exe only if this test project has its own resources. -->
+ <WriteLinesToFile Condition="'$(TestProjectNeedsModifiedPriFile)' == 'true'"
+ File="$(_PriListFile)"
+ Lines="$(_CommonPriFile)"
+ Overwrite="true" />
+
+ <PropertyGroup Condition="'$(TestProjectNeedsModifiedPriFile)' == 'true'">
+ <_MakePriCommand>$(_MakePriExecutable) versioned /o /pr "$(RuntimePath)resw" /cf "$(_MakePriConfigFile)" /of "$(TestPath)" /if "$(_CommonPriFile)"</_MakePriCommand>
+ </PropertyGroup>
+
+ <!-- We call MakePri.exe to create common resources.pri file only if this test project has its own resources. -->
+ <Exec Command="$(_MakePriCommand)" StandardOutputImportance="Low" StdErrEncoding="Unicode" Condition="'$(TestProjectNeedsModifiedPriFile)' == 'true'" />
+
+ <Copy Condition="'$(TestProjectNeedsModifiedPriFile)' != 'true' AND Exists('$(_CommonPriFile)')"
+ SourceFiles="$(_CommonPriFile)"
+ DestinationFiles="$(TestPath)\resources.pri"
+ SkipUnchangedFiles="true" />
+
+ <Copy Condition="'$(TestProjectNeedsModifiedPriFile)' != 'true' AND !Exists('$(_CommonPriFile)')"
+ SourceFiles="$(TestHostRootPath)\Runner\resources.pri"
+ DestinationFiles="$(TestPath)\resources.pri"
+ SkipUnchangedFiles="true" />
+
+ </Target>
+
+ <!-- Generate the script to run the tests. The script performs two high-level steps:
+ 1. Copies the common test runtime dependencies calculated in DiscoverTestDependencies to the test
+ execution directory. Each copy command no-ops if the file already exists in the test execution
+ directory.
+ 2. Runs the tests. -->
+ <Target Name="GenerateTestExecutionScripts"
+ DependsOnTargets="DiscoverTestInputs;SetupTestProperties;MakeTestSpecificResourcesPriFile;MakeCommonResourcesPriFile">
+ <Error Condition="'$(TargetOSTrait)' == ''" Text="TargetOS [$(TargetOS)] is unknown so we don't know how to configure the test run for this project [$(MSBuildProjectName)]" />
+
+ <PropertyGroup>
+ <RunnerScriptName Condition="'$(TargetOS)'=='Windows_NT'" >RunTests.cmd</RunnerScriptName>
+ <RunnerTemplateName Condition="'$(TargetOS)'=='Windows_NT'" >RunnerTemplate.Windows.txt</RunnerTemplateName>
+ <RunnerScriptName Condition="'$(TargetOS)'!='Windows_NT'" >RunTests.sh</RunnerScriptName>
+ <RunnerTemplateName Condition="'$(TargetOS)'!='Windows_NT'" >RunnerTemplate.Unix.txt</RunnerTemplateName>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <XunitTraitOptions Condition="'@(RunWithTraits)'!=''">$(XunitTraitOptions) -trait category=@(RunWithTraits, ' -trait category=') </XunitTraitOptions>
+ <XunitTraitOptions Condition="'@(RunWithoutTraits)'!=''">$(XunitTraitOptions) -notrait category=@(RunWithoutTraits, ' -notrait category=') </XunitTraitOptions>
+ </PropertyGroup>
+
+ <!-- Replace the {XunitTraitOptions} place holder with the actual traits. We use the place holder
+ because code coverage needs to have a bit of the test command line after the traits (it adds ending quotes
+ to one of its options). Simply appending the traits would break code coverage.
+ Additionally, replace CoreRun.exe with ./corerun on Non-Windows OSes (this is the only difference in the command)
+ Future refactoring will allow us to construct this correctly initially, but we don't always know the TargetOS
+ when the properties are set currently. -->
+ <PropertyGroup>
+ <TestCommandLine>$(TestCommandLine.Replace('{XunitTraitOptions}', '$(XunitTraitOptions)'))</TestCommandLine>
+
+ <!-- We also need to replace {CoverageFilter} with its true value, which should be evaluated correctly at this point. -->
+ <TestCommandLine>$(TestCommandLine.Replace('{CoverageFilter}', '$(CoverageFilter)'))</TestCommandLine>
+
+ <OutputFolderForScriptGenerator>$(TestPath)</OutputFolderForScriptGenerator>
+ <OutputPathForScriptGenerator>$(OutputFolderForScriptGenerator)/$(RunnerScriptName)</OutputPathForScriptGenerator>
+ <OutputFolderForTestDependencies>$(BinDir)/TestDependencies</OutputFolderForTestDependencies>
+ </PropertyGroup>
+
+ <MakeDir Condition="'$(CoverageEnabledForProject)'=='true'" Directories="$(CoverageReportDir)" />
+
+ <MakeDir Directories="$(OutputFolderForTestDependencies)" />
+ <PropertyGroup>
+ <_TestDependencyListRoot>$(MSBuildProjectName)-$(TestConfiguration)</_TestDependencyListRoot>
+ <_TestDependencyListFileName>$(_TestDependencyListRoot).dependencylist.txt</_TestDependencyListFileName>
+ <TestDependencyListFilePath>$(OutputFolderForTestDependencies)/$(_TestDependencyListFileName)</TestDependencyListFilePath>
+ </PropertyGroup>
+ <Message Text="Generating $(TestDependencyListFilePath)" />
+ <WriteLinesToFile
+ File="$(TestDependencyListFilePath)"
+ Lines="@(IncludedFileForRunnerScript -> '%(PackageRelativePath)')"
+ Overwrite="true"
+ Encoding="Ascii" />
+
+ <!--======================================================
+ Section for netfx test runs
+ ====================================================== -->
+ <ItemGroup Condition="'$(BuildingNETFxVertical)' == 'true'" >
+ <TestCommandLines Include="set DEVPATH=%RUNTIME_PATH%" />
+ </ItemGroup>
+
+ <!--======================================================
+ Section for uapaot ilc test runs
+ ====================================================== -->
+ <PropertyGroup Condition="'$(UseDotNetNativeToolchain)' == 'true'">
+ <ILCBuildType Condition="'$(ILCBuildType)' == ''">ret</ILCBuildType>
+ <_UseSharedAssemblies Condition="'$(EnableMultiFileILCTests)' == 'true'">-useSharedAssemblies</_UseSharedAssemblies>
+ <_TestILCFolder>%RUNTIME_PATH%\TestILC</_TestILCFolder>
+ <_Runtime_Path>%RUNTIME_PATH%\ILCInputFolder\</_Runtime_Path>
+ <!-- Currently (and probably forever) we can't build UAPAOT on ARM,
+ So if we're running on ARM, what we really want to do is encapsulate
+ the test command into a script that can be run on another machine -->
+ <TestCommandLine Condition="'$(ArchGroup)'=='arm'">echo $(TestCommandLine)> .\RunContinuation.cmd </TestCommandLine>
+ </PropertyGroup>
+
+ <ItemGroup Condition="'$(UseDotNetNativeToolchain)' == 'true' AND '$(Performance)'!='true'" >
+ <TargetExecutableNames Include="xunit.console.netcore.exe"/>
+ <TargetExecutableNames Condition="'%(ProjectReference.Filename)' == 'RemoteExecutorConsoleApp'" Include="RemoteExecutorConsoleApp.exe"/>
+ <IlcInputFolderContents Include="$(ILCFXInputFolder)/*" />
+ <TestCommandLines Include="mklink /H %(IlcInputFolderContents.Filename)%(IlcInputFolderContents.Extension) $(_Runtime_Path)%(IlcInputFolderContents.Filename)%(IlcInputFolderContents.Extension)" />
+ <TestCommandLines Include="copy /y $(_TestILCFolder)\default.rd.xml %EXECUTION_DIR%" />
+ <TestCommandLines Include="rmdir /S /Q %EXECUTION_DIR%int" />
+ <TestCommandLines Include="rmdir /S /Q %EXECUTION_DIR%native" />
+ <TestCommandLines Include="@(TargetExecutableNames -> '
+call %RUNTIME_PATH%\TestILC\ilc.exe -ExeName %(Identity) -in %EXECUTION_DIR% -out %EXECUTION_DIR%int\%(Identity)\ -usedefaultpinvoke -buildtype $(ILCBuildType) -v diag $(_UseSharedAssemblies)
+set ILCERRORLEVEL=%ERRORLEVEL%
+if NOT [%ILCERRORLEVEL%] == [0] exit /b %ILCERRORLEVEL%
+robocopy /S /NP %EXECUTION_DIR%int\%(Identity)\ %EXECUTION_DIR%native\
+')"/>
+ <TestCommandLines Include="copy /y $(_TestILCFolder)\CRT\vcruntime140_app.dll %EXECUTION_DIR%native" />
+ <TestCommandLines Include="echo > %EXECUTION_DIR%\native\$(XunitTestAssembly)"/>
+ <TestCommandLines Include="cd native"/>
+ <!-- These will cause failures if execution is skipped, such as on ARM -->
+ <PostExecutionTestCommandLines Condition="'$(ArchGroup)'!='arm'" Include="type Xunit.Console.Output.txt" />
+ <!-- The result XML part is basically unnecessary but the console output is useful. -->
+ <PostExecutionTestCommandLines Condition="'$(ArchGroup)'=='arm'" Include="echo type Xunit.Console.Output.txt >> .\RunCompiledTest.cmd" />
+ <PostExecutionTestCommandLines Condition="'$(ArchGroup)'!='arm'" Include="copy /y testResults.xml %EXECUTION_DIR%\" />
+ </ItemGroup>
+
+ <!--======================================================
+ Section for uap F5 test runs
+ ====================================================== -->
+ <PropertyGroup Condition="'$(BuildingUAPVertical)' == 'true'">
+ <!-- The location where the logs will be written by the test runner -->
+ <UAP_Results_Path Condition="'$(UAP_Results_Path)'==''">%USERPROFILE%\Documents\TestResults\</UAP_Results_Path>
+
+ <_Runtime_Path>%RUNTIME_PATH%\UAPLayout\</_Runtime_Path>
+ <!-- Make sure the path only has one type of slashes -->
+ <_Runtime_Path>$(_Runtime_Path.Replace('/', '\'))</_Runtime_Path>
+
+ <!-- The test execution command is different for UAP. -->
+ <TestCommandLine>%RUNTIME_PATH%\Launcher\WindowsStoreAppLauncher.exe -test appxmanifest.xml $(XunitArguments) $(XunitTraitOptions)</TestCommandLine>
+ </PropertyGroup>
+
+ <ItemGroup Condition="'$(BuildingUAPVertical)' == 'true'" >
+ <!-- Copy the runner files into the test directory -->
+ <RunnerFolderContents Include="$(TestHostRootPath)\Runner\**\*" Exclude="$(TestHostRootPath)\Runner\**\*.pri"/>
+
+ <TestCommandLines Include="mkdir Assets" />
+ <TestCommandLines Include="mkdir entrypoint" />
+ <TestCommandLines Include="mkdir Properties" />
+ <TestCommandLines Include="mkdir WinMetadata" />
+ <TestCommandLines Include="mklink /H %(RunnerFolderContents.RecursiveDir)%(RunnerFolderContents.Filename)%(RunnerFolderContents.Extension) %RUNTIME_PATH%\Runner\%(RunnerFolderContents.RecursiveDir)%(RunnerFolderContents.Filename)%(RunnerFolderContents.Extension)" />
+
+ <!-- Copy the runtime binaries over -->
+ <RuntimePathContents Include="$(TestHostRootPath)\UAPLayout\*"/>
+ <TestCommandLines Include="mklink /H %(RuntimePathContents.RecursiveDir)%(RuntimePathContents.Filename)%(RuntimePathContents.Extension) $(_Runtime_Path)%(RuntimePathContents.Filename)%(RuntimePathContents.Extension)" />
+
+ <!-- We need to have the ni as well as the non-ni version of the binary. The host (being a rather old build) looks for the ni name first (so we need that as well for now.) -->
+ <TestCommandLines Include="copy /y $(_Runtime_Path)System.Private.CoreLib.dll System.Private.CoreLib.ni.dll" />
+
+ <!-- Copy the log files and the results files from the Documents folder to the test folder -->
+ <PostExecutionTestCommandLines Include="move $(UAP_Results_Path)$(XunitTestAssembly).xml .\$(XunitResultsFileName)" />
+ </ItemGroup>
+
+ <!-- If the PreExecutionTestScript property is set, then it should be set to the full path to a script that will be directly incorporated
+ into the generated runtests script, immediately before the test is run. This can be used to set a number of JIT stress modes,
+ for example. It is intended that this be as late as possible in the generated script, as close as possible to the running of the
+ test. That is why this doesn't appear higher in this file. The idea is that if the included script alters managed code behavior, such as
+ setting various JIT stress modes, we don't want those changes to affect any other managed code invocation (such as test infrastructure
+ written in managed code).
+ -->
+ <ItemGroup Condition="'$(PreExecutionTestScript)'!=''">
+ <TestCommandLines Include="$([System.IO.File]::ReadAllText('$(PreExecutionTestScript)'))" />
+ </ItemGroup>
+
+ <ItemGroup Condition="'$(Performance)'!='true'">
+ <!-- On Windows, call prevents the test command from making execution end prematurely -->
+ <TestCommandLines Condition="'$(TargetOS)'=='Windows_NT' and '$(TestGCStressLevel)' != ''" Include="set COMPlus_GCStress=$(TestGCStressLevel)"/>
+ <TestCommandLines Condition="'$(TargetOS)'=='Windows_NT' and '$(OuterLoop)' == 'true'" Include="set XUNIT_PERFORMANCE_MIN_ITERATION=1"/>
+ <TestCommandLines Condition="'$(TargetOS)'=='Windows_NT' and '$(OuterLoop)' == 'true'" Include="set XUNIT_PERFORMANCE_MAX_ITERATION=$(XunitPerfMaxIteration)"/>
+ <TestCommandLines Condition="'$(TargetOS)'=='Windows_NT' and '$(OuterLoop)' == 'true'" Include="set XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED=$(XunitPerfMaxIterationInner)"/>
+ <TestCommandLines Condition="'$(TargetOS)'=='Windows_NT'" Include="call $(TestCommandLine)"/>
+
+ <TestCommandLines Condition="'$(TargetOS)'!='Windows_NT' and '$(TestGCStressLevel)' != ''" Include="export COMPlus_GCStress=$(TestGCStressLevel)"/>
+ <TestCommandLines Condition="'$(TargetOS)'!='Windows_NT' and '$(OuterLoop)' == 'true'" Include="export XUNIT_PERFORMANCE_MIN_ITERATION=1"/>
+ <TestCommandLines Condition="'$(TargetOS)'!='Windows_NT' and '$(OuterLoop)' == 'true'" Include="export XUNIT_PERFORMANCE_MAX_ITERATION=$(XunitPerfMaxIteration)"/>
+ <TestCommandLines Condition="'$(TargetOS)'!='Windows_NT' and '$(OuterLoop)' == 'true'" Include="export XUNIT_PERFORMANCE_MAX_ITERATION_INNER_SPECIFIED=$(XunitPerfMaxIterationInner)"/>
+ <!-- Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424 -->
+ <TestCommandLines Condition="'$(TargetOS)'!='Windows_NT'" Include="chmod +x $(TestProgram)"/>
+ <TestCommandLines Condition="'$(TargetOS)'!='Windows_NT'" Include="$(TestCommandLine)"/>
+ </ItemGroup>
+
+ <ItemGroup Condition ="'$(Performance)'=='true'">
+ <TestCommandLines Include="@(PerfTestCommandLines)" />
+ </ItemGroup>
+
+ <!-- Do not put anything between this Item Group and the GenerateTestExecutionScripts invocation -->
+ <ItemGroup>
+ <TestCommandLines Include="@(PostExecutionTestCommandLines)" />
+ </ItemGroup>
+
+ <GenerateTestExecutionScripts
+ TestCommands="@(TestCommandLines)"
+ TestDependencies="@(DontIncludeAnything)"
+ RunnerScriptTemplate="$(MSBuildThisFileDirectory)/$(RunnerTemplateName)"
+ ScriptOutputPath ="$(OutputPathForScriptGenerator)"
+ />
+ <!-- Executables restored with .NET Core 2.0 do not have executable permission flags. https://github.com/NuGet/Home/issues/4424 -->
+ <Exec Condition="'$(TargetOS)'!='Windows_NT'" Command="chmod +x $(OutputPathForScriptGenerator)" />
+ </Target>
+
+ <Target Name="RunTestsForProject"
+ Condition="'$(TestDisabled)' != 'true'"
+ DependsOnTargets="DiscoverTestInputs;CheckTestCategories"
+ Inputs="@(RunTestsForProjectInputs)"
+ Outputs="$(TestsSuccessfulSemaphore);$(TestPath)/$(XunitResultsFileName);$(CoverageOutputFilePath)"
+ >
+
+ <MakeDir Condition="'$(CoverageEnabledForProject)'=='true'" Directories="$(CoverageReportDir)" />
+ <Error Text="TestILCFolder property is required for running uapaot tests. Please pass in the full path to the directory that contains ilc.exe to msbuild using /p:TestILCFolder=path_to_ilc_dir.exe" Condition="'$(BuildingUAPAOTVertical)' == 'true' AND !Exists('$(TestHostRootPath)\TestILC')" />
+
+ <!-- For UAP, make sure the Runner and Launcher folder exist, otherwise the tests cannot run -->
+ <Error Text="We cannot run the tests for UAP because either the Runner or the Launcher could not be found. You need to specify the UAPToolsFolder property when calling build.cmd to fix this."
+ Condition="'$(BuildingUAPVertical)'=='true' and (!Exists('$(TestHostRootPath)\Runner') or !Exists('$(TestHostRootPath)\Launcher'))" />
+
+ <Exec Command="$(TestPath)/$(RunnerScriptName) $(TestHostRootPath)"
+ CustomErrorRegularExpression="Failed: [^0]"
+ ContinueOnError="true"
+ IgnoreStandardErrorWarningFormat="true"
+ >
+ <Output PropertyName="TestRunExitCode" TaskParameter="ExitCode" />
+ </Exec>
+
+ <Error Condition="'$(TestDisabled)'!='true' And '$(TestRunExitCode)' != '0'" Text="One or more tests failed while running tests from '$(MSBuildProjectName)' please check $(TestPath)$(XunitResultsFileName) for details!" />
+ <Touch Condition="'$(TestRunExitCode)' == '0'" Files="$(TestsSuccessfulSemaphore)" AlwaysCreate="true" />
+ </Target>
+
+ <!-- Needs to run before RunTestsForProject target as it computes categories and set TestDisabled -->
+ <Target Name="CheckTestCategories">
+
+ <!-- Default behavior is to disable OuterLoop and failing tests if not specified in WithCategories. -->
+ <ItemGroup>
+ <DefaultNoCategories Condition="'$(Outerloop)'!='true'" Include="OuterLoop" />
+ <DefaultNoCategories Include="failing" />
+ <WithoutCategoriesItems Include="@(DefaultNoCategories)" Exclude="@(WithCategoriesItems)" />
+ <WithoutCategoriesItemsDistinct Include="@(WithoutCategoriesItems->Distinct())" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <RunWithTraits Condition="'@(WithCategoriesItems)'!=''" Include="@(WithCategoriesItems)" />
+ <RunWithoutTraits Condition="'@(WithoutCategoriesItemsDistinct)'!=''" Include="@(WithoutCategoriesItemsDistinct)" />
+ </ItemGroup>
+
+ <PropertyGroup>
+ <TestsSuccessfulSemaphore Condition="'@(RunWithTraits)' != ''">$(TestsSuccessfulSemaphore).with.@(RunWithTraits, '.')</TestsSuccessfulSemaphore>
+ <TestsSuccessfulSemaphore Condition="'@(RunWithoutTraits)' != ''">$(TestsSuccessfulSemaphore).without.@(RunWithoutTraits, '.')</TestsSuccessfulSemaphore>
+ <TestsSuccessfulSemaphore>$(TestPath)/$(TestsSuccessfulSemaphore)</TestsSuccessfulSemaphore>
+ </PropertyGroup>
+
+ <Delete Condition="'$(ForceRunTests)'=='true' And Exists($(TestsSuccessfulSemaphore))"
+ Files="$(TestsSuccessfulSemaphore)" />
+ </Target>
+
+ <Target Name="CheckTestPlatforms">
+ <PropertyGroup>
+ <TestDisabled Condition="'%(UnsupportedPlatformsItems.Identity)' == '$(TargetOS)' Or '$(ConfigurationErrorMsg)' != ''">true</TestDisabled>
+ </PropertyGroup>
+ <Message Text="CheckTestPlatforms found TargetOS of [$(TargetOS)]." Importance="Low" />
+ <Message Condition="'%(UnsupportedPlatformsItems.Identity)' == '$(TargetOS)'"
+ Text="Skipping tests in $(AssemblyName) because it is not supported on $(TargetOS)" />
+ <Message Condition="'$(ConfigurationErrorMsg)' != ''"
+ Text="Skipping tests in $(AssemblyName) because there is no configuration compatible with the current BuildConfiguration." />
+ </Target>
+
+ <Target Name="SetupTestProperties" DependsOnTargets="CheckTestPlatforms;CheckTestCategories" />
+
+ <PropertyGroup>
+ <TestDependsOn>
+ $(TestDependsOn);
+ CopySupplementalTestData;
+ GenerateTestExecutionScripts;
+ RunTestsForProject;
+ ArchiveTestBuild
+ </TestDependsOn>
+ </PropertyGroup>
+
+ <Target Name="Test" DependsOnTargets="$(TestDependsOn)" />
+ <Target Name="BuildAndTest" DependsOnTargets="Build;Test" />
+ <Target Name="RebuildAndTest" DependsOnTargets="Rebuild;Test" />
+
+ <!-- This helps collect crash dumps and requires python installed -->
+ <Import Project="$(MSBuildThisFileDirectory)Dumpling.targets" Condition="'$(EnableDumpling)' == 'true' OR '$(EnableCloudTest)' == 'true'" />
+</Project>