Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/dotnet-tools.json6
-rw-r--r--Directory.Build.targets1
-rw-r--r--docs/workflow/building/libraries/code-coverage.md20
-rw-r--r--eng/Versions.props1
-rw-r--r--eng/referenceFromRuntime.targets4
-rw-r--r--eng/references.targets2
-rw-r--r--eng/testing/.runsettings65
-rw-r--r--eng/testing/coverage.props14
-rw-r--r--eng/testing/coverage.targets75
-rw-r--r--eng/testing/launchSettings.json19
-rw-r--r--eng/testing/launchSettings.targets22
-rw-r--r--eng/testing/runsettings.targets44
-rw-r--r--eng/testing/runtimeConfiguration.targets2
-rw-r--r--eng/testing/tests.props13
-rw-r--r--eng/testing/tests.targets38
-rw-r--r--eng/testing/xunit/vstest.props15
-rw-r--r--eng/testing/xunit/vstest.targets36
-rw-r--r--eng/testing/xunit/xunit.console.props17
-rw-r--r--eng/testing/xunit/xunit.console.targets42
-rw-r--r--eng/testing/xunit/xunit.props26
-rw-r--r--eng/testing/xunit/xunit.targets22
-rw-r--r--eng/versioning.targets4
-rw-r--r--src/libraries/Common/tests/Common.Tests.csproj1
-rw-r--r--src/libraries/Directory.Build.props25
-rw-r--r--src/libraries/Directory.Build.targets5
-rw-r--r--src/libraries/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj1
-rw-r--r--src/libraries/System.Transactions.Local/tests/System.Transactions.Local.Tests.csproj1
-rw-r--r--src/libraries/tests.proj25
28 files changed, 254 insertions, 292 deletions
diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 39540bb21cc..0626e6dbbb1 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -2,12 +2,6 @@
"version": 1,
"isRoot": true,
"tools": {
- "coverlet.console": {
- "version": "1.7.0",
- "commands": [
- "coverlet"
- ]
- },
"dotnet-reportgenerator-globaltool": {
"version": "4.5.2",
"commands": [
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 60d17334bd6..2d72cd0f912 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -26,4 +26,5 @@
<LangVersion>preview</LangVersion>
<LangVersion Condition="'$(Language)' == 'VB'">latest</LangVersion>
</PropertyGroup>
+
</Project>
diff --git a/docs/workflow/building/libraries/code-coverage.md b/docs/workflow/building/libraries/code-coverage.md
index a2b288673de..ad67ed4301d 100644
--- a/docs/workflow/building/libraries/code-coverage.md
+++ b/docs/workflow/building/libraries/code-coverage.md
@@ -28,15 +28,15 @@ An issue need not be addressed in its entirety. We happily accept contributions
You can perform code coverage runs for the entire repository locally by adding the `coverage` switch (assuming that source and test assemblies are already built):
- build -test -coverage
+ build libs.tests -test -coverage
This runs the tests and generates the full code coverage report. The resulting index.htm file providing the results of the run should be available at:
artifacts\coverage\index.htm
-You can also build and test with code coverage for a particular test project rather than for the whole repo with the ```/p:Coverage=true``` argument:
+You can also build and test with code coverage for a particular test project rather than for the whole repo with the `/p:Coverage=true` property:
- dotnet build /t:Test /p:Coverage=true
+ dotnet test -f netcoreapp5.0 /p:Coverage=true
The results for this one library will then be available in this index.htm file, where $(OutDir) is the directory where the binaries were generated.
@@ -44,24 +44,14 @@ The results for this one library will then be available in this index.htm file,
For example, to build, test, and get code coverage results for the System.Diagnostics.Debug library, from the root of the repo one can do:
- cd src\System.Diagnostics.Debug\tests\
- dotnet build /t:Test /p:Coverage=true
+ dotnet test src\libraries\System.Diagnostics.Debug -f netcoreapp5.0 /p:Coverage=true
And then once the run completes:
$(OutDir)\report\index.htm
-**Note:** If you only want to measure the coverage of your local changes (that haven't been pushed to git), run:
-
- dotnet build /t:Test /p:Coverage=true /p:CoverageSourceLink=false
-
-
## Code coverage with System.Private.CoreLib code
-Some of the libraries for which contracts and tests live in the corefx repo are actually fully or partially implemented in the core runtime library in another repo, e.g. the implementation that backs the System.Runtime contract is in System.Private.CoreLib.dll in either the coreclr or corert repo. Test projects for code that lives, fully or partially, in System.Private.CoreLib, should have the property `TestRuntime` set to `true` in order to obtain proper code coverage reports.
+Some of the libraries for which contracts and tests live in libraries are actually fully or partially implemented in the core runtime library, e.g. the implementation that backs the System.Runtime contract is in System.Private.CoreLib.dll. Test projects for code that lives, fully or partially, in System.Private.CoreLib, should have the property `TestRuntime` set to `true` in order to obtain proper code coverage reports.
If the test project does not set the property `TestRuntime` to `true` and you want to collect code coverage that includes types in System.Private.CoreLib.dll add `/p:TestRuntime=true` to the coverage build command listed above.
-
-If you want to get coverage report against a private build of System.Private.CoreLib (// TODO //).
-
-The build and test projects take care of copying assemblies and PDBs as needed for coverage runs. The resulting code coverage report should now also include details for System.Private.CoreLib.
diff --git a/eng/Versions.props b/eng/Versions.props
index 230672aec71..5406010c618 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -116,6 +116,7 @@
<MicrosoftNETTestSdkVersion>16.7.0-preview-20200429-01</MicrosoftNETTestSdkVersion>
<MicrosoftDotNetXHarnessTestsRunnersVersion>1.0.0-prerelease.20230.6</MicrosoftDotNetXHarnessTestsRunnersVersion>
<XUnitVersion>2.4.1</XUnitVersion>
+ <CoverletCollectorVersion>1.2.0</CoverletCollectorVersion>
<TraceEventVersion>2.0.5</TraceEventVersion>
<NewtonsoftJsonVersion>12.0.3</NewtonsoftJsonVersion>
<MoqVersion>4.12.0</MoqVersion>
diff --git a/eng/referenceFromRuntime.targets b/eng/referenceFromRuntime.targets
index 873e7e5ff40..26e107a1310 100644
--- a/eng/referenceFromRuntime.targets
+++ b/eng/referenceFromRuntime.targets
@@ -19,7 +19,7 @@
</PropertyGroup>
<Target Name="AddRuntimeProjectReference"
- Condition="'$(IsTestProject)'!='true' and '@(ReferenceFromRuntime)' != ''">
+ Condition="'$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true' and '@(ReferenceFromRuntime)' != ''">
<Error Text="ReferenceFromRuntime may not be used from reference assemblies."
Condition="'$(IsReferenceAssembly)' == 'true' and '$(AllowReferenceFromRuntime)' != 'true'" />
@@ -65,7 +65,7 @@
<_referencePathFromRuntime Include="@(RuntimeFiles)" Private="false" />
<_referencePathFromRuntime Include="@(_referencePathFromRestoredRuntime)" Private="false" />
<!-- If this is a test project, also use the $(RuntimePath) to find a @(ReferenceFromRuntime) assembly. -->
- <_referencePathFromRuntime Include="@(ReferenceFromRuntime->'$(RuntimePath)%(Identity).dll')" Condition="'$(IsTestProject)' == 'true'" />
+ <_referencePathFromRuntime Include="@(ReferenceFromRuntime->'$(RuntimePath)%(Identity).dll')" Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true'" />
<!-- transform to filename in order to intersect -->
<_referencePathFromRuntimeByFileName Include="@(_referencePathFromRuntime->'%(FileName)')" Condition="'%(_referencePathFromRuntime.Extension)' == '.dll'" >
<ReferencePath>%(Identity)</ReferencePath>
diff --git a/eng/references.targets b/eng/references.targets
index 0c104db2bb2..405fd07799f 100644
--- a/eng/references.targets
+++ b/eng/references.targets
@@ -36,7 +36,7 @@
</ItemGroup>
</Target>
- <Target Name="AddDefaultTestReferences" BeforeTargets="SetupDefaultReferences" Condition="'$(IsTestProject)' == 'true'">
+ <Target Name="AddDefaultTestReferences" BeforeTargets="SetupDefaultReferences" Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true'">
<ItemGroup>
<DefaultReferenceExclusions Include="@(ReferenceFromRuntime)"/>
diff --git a/eng/testing/.runsettings b/eng/testing/.runsettings
new file mode 100644
index 00000000000..138ee92187e
--- /dev/null
+++ b/eng/testing/.runsettings
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RunSettings>
+ <RunConfiguration>
+ <!-- Timeout in ms, 5 minutes -->
+ <TestSessionTimeout>300000</TestSessionTimeout>
+ <!-- Directory for test run reports. E.g. trx, coverage etc. -->
+ <ResultsDirectory>.\</ResultsDirectory>
+ <!-- Working directory for test invocation. Results directory can be relative to this. Used by IDEs. -->
+ <SolutionDirectory>.\</SolutionDirectory>
+ <!-- Degree of parallelization, spawns n test hosts to run tests. -->
+ <MaxCpuCount>$$MAXCPUCOUNT$$</MaxCpuCount>
+ <!-- Configures the architecture of test host. -->
+ <TargetPlatform>$$TARGETPLATFORM$$</TargetPlatform>
+ <!-- If true, an adapter should disable any test case parallelization. -->
+ <DisableParallelization>$$DISABLEPARALLELIZATION$$</DisableParallelization>
+ <!-- If true, an adapter shouldn't create appdomains to run tests. -->
+ <DisableAppDomain>$$DISABLEAPPDOMAIN$$</DisableAppDomain>
+ <!-- Filter out failing (wrong framwork, platform, runtime or activeissue) tests -->
+ <TestCaseFilter>$$TESTCASEFILTER$$</TestCaseFilter>
+ <DotNetHostPath>$$DOTNETHOSTPATH$$</DotNetHostPath>
+ <EnvironmentVariables>
+ <!-- Use our self-built framework on .NET Framework -->
+ <DEVPATH>$$DEVPATH$$</DEVPATH>
+ </EnvironmentVariables>
+ </RunConfiguration>
+ <LoggerRunSettings>
+ <Loggers>
+ <Logger uri="logger://Microsoft/TestPlatform/TrxLogger/v1">
+ <Configuration>
+ <LogFileName>testResults.trx</LogFileName>
+ </Configuration>
+ </Logger>
+ <Logger uri="logger://Microsoft/TestPlatform/HtmlLogger/v1">
+ <Configuration>
+ <LogFileName>testResults.html</LogFileName>
+ </Configuration>
+ </Logger>
+ <Logger friendlyName="console">
+ <Configuration>
+ <Verbosity>Minimal</Verbosity>
+ </Configuration>
+ </Logger>
+ </Loggers>
+ </LoggerRunSettings>
+ <DataCollectionRunSettings>
+ <DataCollectors>
+ <DataCollector friendlyName="XPlat code coverage" enabled="$$COVERAGE_ENABLED$$">
+ <Configuration>
+ <Include>$$COVERAGE_INCLUDE$$</Include>
+ <ExcludeByFile>$$COVERAGE_EXCLUDEBYFILE$$</ExcludeByFile>
+ <IncludeDirectory>$$COVERAGE_INCLUDEDIRECTORY$$</IncludeDirectory>
+ <Format>opencover</Format>
+ <SingleHit>false</SingleHit>
+ <UseSourceLink>true</UseSourceLink>
+ <IncludeTestAssembly>false</IncludeTestAssembly>
+ </Configuration>
+ </DataCollector>
+ <DataCollector friendlyName="blame" enabled="true">
+ <Configuration>
+ <CollectDump CollectAlways="false" DumpType="mini" />
+ </Configuration>
+ </DataCollector>
+ </DataCollectors>
+ </DataCollectionRunSettings>
+</RunSettings> \ No newline at end of file
diff --git a/eng/testing/coverage.props b/eng/testing/coverage.props
deleted file mode 100644
index 7af30267a56..00000000000
--- a/eng/testing/coverage.props
+++ /dev/null
@@ -1,14 +0,0 @@
-<Project>
- <PropertyGroup>
- <CoverageOutputPath Condition="'$(CoverageOutputPath)' == ''">coverage.xml</CoverageOutputPath>
- <CoverageThreshold Condition="$(CoverageThreshold) == ''">0</CoverageThreshold>
- <CoverageThresholdType Condition="$(CoverageThresholdType) == ''">line,branch,method</CoverageThresholdType>
- <CoverageFormat Condition="'$(CoverageFormat)' == ''">opencover</CoverageFormat>
- <CoverageSourceLink Condition="'$(CoverageSourceLink)' == ''">true</CoverageSourceLink>
- <CoverageVerbosity Condition="'$(CoverageVerbosity)' == ''">normal</CoverageVerbosity>
-
- <CoverageReportInputPath Condition="'$(CoverageReportInputPath)' == ''">$(CoverageOutputPath)</CoverageReportInputPath>
- <CoverageReportTypes Condition="'$(CoverageReportTypes)' == ''">Html</CoverageReportTypes>
- <CoverageReportVerbosity Condition="'$(CoverageReportVerbosity)' == ''">Info</CoverageReportVerbosity>
- </PropertyGroup>
-</Project>
diff --git a/eng/testing/coverage.targets b/eng/testing/coverage.targets
index 3638e3efd7c..35b89936046 100644
--- a/eng/testing/coverage.targets
+++ b/eng/testing/coverage.targets
@@ -1,39 +1,5 @@
-<Project InitialTargets="SetupCoverageFilter">
- <!-- Wrap RunCommand and RunArguments inside code coverage invocation. -->
- <PropertyGroup>
- <RunArguments>"$(TargetFileName)" --target "$(RunCommand)" --targetargs "$(RunArguments)" --format "$(CoverageFormat)" --output "$(CoverageOutputPath)" --threshold "$(CoverageThreshold)" --threshold-type "$(CoverageThresholdType)" --verbosity "$(CoverageVerbosity)"</RunArguments>
- <RunArguments Condition="'$(CoverageSourceLink)' == 'true'">$(RunArguments) --use-source-link</RunArguments>
- <RunCommand>"$(DotNetTool)" tool run coverlet</RunCommand>
- </PropertyGroup>
-
- <!-- Coverage report -->
- <PropertyGroup>
- <CoverageReportDir Condition="'$(CoverageReportDir)' == ''">$([MSBuild]::NormalizeDirectory('$(OutDir)', 'report'))</CoverageReportDir>
- <CoverageReportResultsPath>$([MSBuild]::NormalizePath('$(CoverageReportDir)', 'index.htm'))</CoverageReportResultsPath>
- <CoverageReportCommandLine>"$(DotNetTool)" tool run reportgenerator "-reports:$(CoverageReportInputPath)" "-targetdir:$(CoverageReportDir.TrimEnd('\/'))" "-reporttypes:$(CoverageReportTypes)" "-verbosity:$(CoverageReportVerbosity)"</CoverageReportCommandLine>
- </PropertyGroup>
-
- <!-- Skip generating individual reports if a full report is generated. -->
- <ItemGroup Condition="'$(BuildAllProjects)' != 'true' and '$(SkipCoverageReport)' != 'true'">
- <PostRunScriptCommands Include="$(CoverageReportCommandLine)" />
- </ItemGroup>
-
+<Project>
<Target Name="SetupCoverageFilter">
- <PropertyGroup Condition="'@(CoverageExcludeFile)' != ''">
- <CoverageExcludeByFileFilter>--exclude-by-file @(CoverageExcludeFile -> '"%(Identity)"', ' --exclude-by-file ')</CoverageExcludeByFileFilter>
- <RunArguments>$(RunArguments) $(CoverageExcludeByFileFilter)</RunArguments>
- </PropertyGroup>
-
- <PropertyGroup Condition="'@(CoverageProbePath)' != ''">
- <IncludeDirectoriesFilter>--include-directory @(CoverageProbePath -> '"$(RunScriptHostDir)%(Identity)"', ' --include-directory ')</IncludeDirectoriesFilter>
- <RunArguments>$(RunArguments) $(IncludeDirectoriesFilter)</RunArguments>
- </PropertyGroup>
-
- <PropertyGroup Condition="'@(CoverageExclude)' != ''">
- <CoverageExcludeFilter>--exclude @(CoverageExclude -> '"%(Identity)"', ' --exclude ')</CoverageExcludeFilter>
- <RunArguments>$(RunArguments) $(CoverageExcludeFilter)</RunArguments>
- </PropertyGroup>
-
<!--
We need to filter the data to only the assembly being tested. Otherwise we will gather tons of data about other assemblies.
If the code being tested is part of the runtime itself, it requires special treatment.
@@ -48,15 +14,40 @@
CoverageAssemblies can be passed in to the build to gather coverage on additional assemblies.
-->
<ItemGroup>
- <_CoverageAssemblies Include="$(AssemblyBeingTested)" />
- <_CoverageAssemblies Include="System.Private.CoreLib" Condition="'$(TestRuntime)' == 'true'" />
- <_CoverageAssemblies Include="@(AssembliesBeingTested)" />
- <_CoverageAssemblies Include="$(CoverageAssemblies)" Condition="'$(CoverageAssemblies)' != ''" />
+ <CoverageInclude Include="$(AssemblyBeingTested)" />
+ <CoverageInclude Include="System.Private.CoreLib" Condition="'$(TestRuntime)' == 'true'" />
+ <CoverageInclude Include="@(AssembliesBeingTested)" />
+ <CoverageInclude Include="$(CoverageAssemblies)" Condition="'$(CoverageAssemblies)' != ''" />
</ItemGroup>
- <PropertyGroup Condition="'$(CoverageType)' != 'all'">
- <CoverageFilter>--include @(_CoverageAssemblies -> '"[%(Identity)]*"', ' --include ')</CoverageFilter>
- <RunArguments>$(RunArguments) $(CoverageFilter)</RunArguments>
+ <PropertyGroup>
+ <CoverageIncludeFilter>@(CoverageInclude -> '[%(Identity)]*', ',')</CoverageIncludeFilter>
</PropertyGroup>
+
+ <PropertyGroup Condition="'@(CoverageExcludeByFile)' != ''">
+ <CoverageExcludeByFileFilter>@(CoverageExcludeByFile -> '%(Identity)', ',')</CoverageExcludeByFileFilter>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'@(CoverageIncludeDirectory)' != ''">
+ <CoverageIncludeDirectoryFilter>@(CoverageIncludeDirectory -> '$(TestHostRootPath)%(Identity)', ',')</CoverageIncludeDirectoryFilter>
+ </PropertyGroup>
+ </Target>
+
+ <Target Name="GenerateCoverageReport"
+ Condition="'$(Coverage)' == 'true' and '$(SkipCoverageReport)' != 'true'"
+ AfterTargets="VSTest">
+ <ItemGroup Condition="'$(CoverageReportInputPath)' == ''">
+ <CoverageOutputFile Include="$(OutDir)*\coverage.opencover.xml" />
+ </ItemGroup>
+
+ <PropertyGroup>
+ <CoverageReportInputPath Condition="'$(CoverageReportInputPath)' == ''">%(CoverageOutputFile.Identity)</CoverageReportInputPath>
+ <CoverageReportTypes Condition="'$(CoverageReportTypes)' == ''">Html</CoverageReportTypes>
+ <CoverageReportVerbosity Condition="'$(CoverageReportVerbosity)' == ''">Info</CoverageReportVerbosity>
+ <CoverageReportDir Condition="'$(CoverageReportDir)' == ''">$([MSBuild]::NormalizeDirectory('$(OutDir)', 'report'))</CoverageReportDir>
+ <CoverageReportCommand>"$(DotNetTool)" tool run reportgenerator "-reports:$(CoverageReportInputPath)" "-targetdir:$(CoverageReportDir.TrimEnd('\/'))" "-reporttypes:$(CoverageReportTypes)" "-verbosity:$(CoverageReportVerbosity)"</CoverageReportCommand>
+ </PropertyGroup>
+
+ <Exec Command="$(CoverageReportCommand)" />
</Target>
</Project>
diff --git a/eng/testing/launchSettings.json b/eng/testing/launchSettings.json
deleted file mode 100644
index 62d099feb3b..00000000000
--- a/eng/testing/launchSettings.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "profiles": {
- ".NET Core xUnit Console": {
- "commandName": "Executable",
- "executablePath": "$(TestHostRootPath)dotnet.exe",
- "commandLineArgs": "$(RunArguments) -parallel none",
- "workingDirectory": "$(RunWorkingDirectory)"
- },
- ".NET Framework xUnit Console": {
- "commandName": "Executable",
- "executablePath": "$(RunWorkingDirectory)$(RunCommand)",
- "commandLineArgs": "$(RunArguments) -parallel none",
- "workingDirectory": "$(RunWorkingDirectory)",
- "environmentVariables": {
- "DEVPATH": "$(TestHostRootPath)"
- }
- }
- }
-}
diff --git a/eng/testing/launchSettings.targets b/eng/testing/launchSettings.targets
deleted file mode 100644
index 6caf9475304..00000000000
--- a/eng/testing/launchSettings.targets
+++ /dev/null
@@ -1,22 +0,0 @@
-<Project>
- <!--
- Generates the launch settings file in case it doesn't exist yet.
- This supports scenarios when new projects are added or the file was deleted.
- -->
- <PropertyGroup>
- <LaunchSettingsInputFileFullPath Condition="'$(LaunchSettingsInputFileFullPath)' == ''">$(MSBuildThisFileDirectory)launchSettings.json</LaunchSettingsInputFileFullPath>
- <LaunchSettingsOutputFileFullPath Condition="'$(LaunchSettingsOutputFileFullPath)' == ''">$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '$(AppDesignerFolder)', 'launchSettings.json'))</LaunchSettingsOutputFileFullPath>
- <PrepareForRunDependsOn Condition="!Exists($(LaunchSettingsOutputFileFullPath))">GenerateLaunchSettingsFile;$(PrepareForRunDependsOn);</PrepareForRunDependsOn>
- </PropertyGroup>
-
- <!--
- Target to generate the launch settings file.
- Either called by PrepareForRunDependsOn if the file doesn't already exist when building
- the test assembly or invoked manually from the build.proj when doing a full build.
- -->
- <Target Name="GenerateLaunchSettingsFile">
- <Copy SourceFiles="$(LaunchSettingsInputFileFullPath)"
- DestinationFiles="$(LaunchSettingsOutputFileFullPath)"
- SkipUnchangedFiles="true" />
- </Target>
-</Project> \ No newline at end of file
diff --git a/eng/testing/runsettings.targets b/eng/testing/runsettings.targets
new file mode 100644
index 00000000000..ea508d50c3c
--- /dev/null
+++ b/eng/testing/runsettings.targets
@@ -0,0 +1,44 @@
+<Project>
+ <PropertyGroup>
+ <RunSettingsInputFilePath Condition="'$(RunSettingsInputFilePath)' == ''">$(MSBuildThisFileDirectory).runsettings</RunSettingsInputFilePath>
+ <RunSettingsOutputFilePath Condition="'$(RunSettingsOutputFilePath)' == ''">$(OutDir).runsettings</RunSettingsOutputFilePath>
+ <!-- Set RunSettingsFilePath property which is read by VSTest. -->
+ <RunSettingsFilePath Condition="Exists('$(RunSettingsOutputFilePath)')">$(RunSettingsOutputFilePath)</RunSettingsFilePath>
+ <PrepareForRunDependsOn>GenerateRunSettingsFile;$(PrepareForRunDependsOn)</PrepareForRunDependsOn>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <_testFilter Condition="'$(_withCategories)' != ''">$(_withCategories.Replace(';', '&amp;amp;category='))</_testFilter>
+ <_testFilter Condition="'$(_withoutCategories)' != ''">$(_testFilter)$(_withoutCategories.Replace(';', '&amp;amp;category!='))</_testFilter>
+ <_testFilter>$(_testFilter.Trim('&amp;amp;'))</_testFilter>
+ </PropertyGroup>
+
+ <Target Name="GenerateRunSettingsFile"
+ DependsOnTargets="SetupCoverageFilter">
+ <PropertyGroup>
+ <RunSettingsFileContent>$([System.IO.File]::ReadAllText('$(RunSettingsInputFilePath)'))</RunSettingsFileContent>
+ <RunSettingsFileContent Condition="'$(TestDisableParallelization)' == 'true'">$(RunSettingsFileContent.Replace('$$MAXCPUCOUNT$$', '1'))</RunSettingsFileContent>
+ <RunSettingsFileContent Condition="'$(TestDisableParallelization)' != 'true'">$(RunSettingsFileContent.Replace('$$MAXCPUCOUNT$$', '0'))</RunSettingsFileContent>
+ <RunSettingsFileContent>$(RunSettingsFileContent.Replace('$$COVERAGE_INCLUDE$$', '$(CoverageIncludeFilter)')
+ .Replace('$$COVERAGE_EXCLUDEBYFILE$$', '$(CoverageExcludeByFileFilter)')
+ .Replace('$$COVERAGE_INCLUDEDIRECTORY$$', '$(CoverageIncludeDirectoryFilter)')
+ .Replace('$$COVERAGE_ENABLED$$', '$([MSBuild]::ValueOrDefault('$(Coverage)', 'false'))')
+ .Replace('$$TARGETPLATFORM$$', '$(TargetArchitecture)')
+ .Replace('$$DISABLEPARALLELIZATION$$', '$([MSBuild]::ValueOrDefault('$(TestDisableParallelization)', 'false'))')
+ .Replace('$$DISABLEAPPDOMAIN$$', '$([MSBuild]::ValueOrDefault('$(TestDisableAppDomain)', 'false'))')
+ .Replace('$$TESTCASEFILTER$$', '$(_testFilter)')
+ .Replace('$$DEVPATH$$', '$(TestHostRootPath)')
+ .Replace('$$DOTNETHOSTPATH$$', '$(TestHostRootPath)$([System.IO.Path]::GetFileName('$(DotNetTool)'))'))</RunSettingsFileContent>
+ </PropertyGroup>
+
+ <WriteLinesToFile File="$(RunSettingsOutputFilePath)"
+ Lines="$(RunSettingsFileContent)"
+ WriteOnlyWhenDifferent="true"
+ Overwrite="true" />
+
+ <!-- Set RunSettingsFilePath property which is read by VSTest. -->
+ <PropertyGroup>
+ <RunSettingsFilePath>$(RunSettingsOutputFilePath)</RunSettingsFilePath>
+ </PropertyGroup>
+ </Target>
+</Project>
diff --git a/eng/testing/runtimeConfiguration.targets b/eng/testing/runtimeConfiguration.targets
index fdb81abbb18..c92c6ff627d 100644
--- a/eng/testing/runtimeConfiguration.targets
+++ b/eng/testing/runtimeConfiguration.targets
@@ -4,7 +4,7 @@
<TestRuntimeConfigurationFile Condition="'$(TargetsNetFx)' == 'true'">$(MSBuildThisFileDirectory)netfx.exe.config</TestRuntimeConfigurationFile>
<!-- By default copy the test runtime config file for executable test projects (+ test support projects). -->
- <GenerateRuntimeConfigurationFiles Condition="'$(IsTestProject)' == 'true' and ('$(IsTestSupportProject)' != 'true' or '$(OutputType.ToLower())' == 'exe')">true</GenerateRuntimeConfigurationFiles>
+ <GenerateRuntimeConfigurationFiles Condition="'$(IsTestProject)' == 'true' or '$(OutputType.ToLower())' == 'exe'">true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<ItemGroup Condition="'$(GenerateRuntimeConfigurationFiles)' == 'true'">
diff --git a/eng/testing/tests.props b/eng/testing/tests.props
index dfaabfa18db..0c792a6d116 100644
--- a/eng/testing/tests.props
+++ b/eng/testing/tests.props
@@ -5,6 +5,19 @@
<!-- Implicit test build support when invoking the Test target on the project directly. -->
<TestDependsOn Condition="'$(TestNoBuild)' != 'true' and '$(BuildAllProjects)' != 'true'">Build</TestDependsOn>
<TestDependsOn>$(TestDependsOn);GenerateRunScript;RunTests</TestDependsOn>
+ <VSTestNoLogo>true</VSTestNoLogo>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <!-- Default and user defined categories -->
+ <_withCategories Condition="'$(WithCategories)' != ''">;$(WithCategories.Trim(';'))</_withCategories>
+ <_withoutCategories Condition="'$(WithoutCategories)' != ''">;$(WithoutCategories.Trim(';'))</_withoutCategories>
+
+ <TestScope Condition="'$(TestScope)' == '' and '$(Outerloop)' == 'true'">all</TestScope>
+ <_withCategories Condition="'$(TestScope)' == 'outerloop'">$(_withCategories);OuterLoop</_withCategories>
+ <_withoutCategories Condition="'$(ArchiveTests)' == 'true'">$(_withoutCategories);IgnoreForCI</_withoutCategories>
+ <_withoutCategories Condition="'$(TestScope)' == '' or '$(TestScope)' == 'innerloop'">$(_withoutCategories);OuterLoop</_withoutCategories>
+ <_withoutCategories Condition="!$(_withCategories.Contains('failing'))">$(_withoutCategories);failing</_withoutCategories>
</PropertyGroup>
<!-- Set env variable to use the local netfx assemblies instead of the ones in the GAC. -->
diff --git a/eng/testing/tests.targets b/eng/testing/tests.targets
index b90176bd9bb..faaffc411b3 100644
--- a/eng/testing/tests.targets
+++ b/eng/testing/tests.targets
@@ -1,7 +1,5 @@
<Project>
<PropertyGroup>
- <RunWorkingDirectory>$(OutDir)</RunWorkingDirectory>
-
<RunScriptInputName Condition="'$(TargetOS)' == 'Windows_NT'">RunnerTemplate.cmd</RunScriptInputName>
<RunScriptInputName Condition="'$(TargetOS)' != 'Windows_NT'">RunnerTemplate.sh</RunScriptInputName>
<RunScriptInputName Condition="'$(TargetOS)' == 'iOS'">AppleRunnerTemplate.sh</RunScriptInputName>
@@ -18,7 +16,6 @@
<RunScriptHost Condition="'$(TargetOS)' == 'Windows_NT'">$(RunScriptHostDir)dotnet.exe</RunScriptHost>
<RunScriptHost Condition="'$(TargetOS)' != 'Windows_NT'">$(RunScriptHostDir)dotnet</RunScriptHost>
-
</PropertyGroup>
<!-- Archive test binaries. -->
@@ -38,13 +35,11 @@
<Target Name="GenerateRunScript">
<PropertyGroup>
<!-- RSP file support. -->
- <RunArguments Condition="'$(TargetOS)' == 'Windows_NT'">$(RunArguments) %RSP_FILE%</RunArguments>
- <RunArguments Condition="'$(TargetOS)' != 'Windows_NT'">$(RunArguments) $RSP_FILE</RunArguments>
+ <RunScriptCommand Condition="'$(TargetOS)' == 'Windows_NT'">$(RunScriptCommand) %RSP_FILE%</RunScriptCommand>
+ <RunScriptCommand Condition="'$(TargetOS)' != 'Windows_NT'">$(RunScriptCommand) $RSP_FILE</RunScriptCommand>
- <!-- Escape arguments with user inputs. -->
- <RunArguments>$([MSBuild]::Escape('$(RunArguments)'))</RunArguments>
-
- <RunScriptCommand Condition="'$(RunScriptCommand)' == ''">$(RunCommand) $(RunArguments)</RunScriptCommand>
+ <!-- Escape potential user input. -->
+ <RunScriptCommand>$([MSBuild]::Escape('$(RunScriptCommand)'))</RunScriptCommand>
</PropertyGroup>
<!-- Set $(TestDebugger) to eg c:\debuggers\windbg.exe to run tests under a debugger. -->
@@ -74,28 +69,10 @@
TemplatePath="$(RunScriptInputPath)"
OutputPath="$(RunScriptOutputPath)" />
- <Exec Condition="'$(TargetOS)' != 'Windows_NT'" Command="chmod +x $(RunScriptOutputPath)" />
-
- </Target>
-
- <Target Name="ValidateTestPlatform">
- <ItemGroup>
- <UnsupportedPlatformsItems Include="$(UnsupportedPlatforms)" />
- </ItemGroup>
-
- <PropertyGroup>
- <TestDisabled Condition="'%(UnsupportedPlatformsItems.Identity)' == '$(TargetOS)' or '$(ConfigurationErrorMsg)' != ''">true</TestDisabled>
- </PropertyGroup>
-
- <Message Text="ValidateTestPlatform found TargetOS of [$(TargetOS)]." Importance="Low" />
-
- <Message Condition="'%(UnsupportedPlatformsItems.Identity)' == '$(TargetOS)'"
- Text="Skipping tests in $(AssemblyName) because it is not supported on $(TargetOS)" />
+ <Exec Condition="'$(TargetOS)' != 'Windows_NT' and '$(OS)' != 'Windows_NT'" Command="chmod +x $(RunScriptOutputPath)" />
</Target>
- <Target Name="RunTests"
- Condition="'$(TestDisabled)' != 'true'"
- DependsOnTargets="ValidateTestPlatform">
+ <Target Name="RunTests">
<PropertyGroup>
<RunTestsCommand>"$(RunScriptOutputPath)" --runtime-path "$(TestHostRootPath.TrimEnd('\/'))"</RunTestsCommand>
<RunTestsCommand Condition="'$(TestRspFile)' != '' and '$(RuntimeFlavor)' != 'Mono'">$(RunTestsCommand) --rsp-file "$(TestRspFile)"</RunTestsCommand>
@@ -111,7 +88,7 @@
</Exec>
<PropertyGroup Condition="'$(TestRunExitCode)' != '0'">
- <TestResultsPath>$(RunWorkingDirectory)$(TestResultsName)</TestResultsPath>
+ <TestResultsPath>$(OutputPath)$(TestResultsName)</TestResultsPath>
<TestRunErrorMessage>One or more tests failed while running tests from '$(TestProjectName)'.</TestRunErrorMessage>
<TestRunErrorMessage Condition="Exists('$(TestResultsPath)')">$(TestRunErrorMessage) Please check $(TestResultsPath) for details!</TestRunErrorMessage>
</PropertyGroup>
@@ -231,6 +208,7 @@
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
</Target>
+ <Import Project="$(MSBuildThisFileDirectory)runsettings.targets" />
<Import Project="$(MSBuildThisFileDirectory)xunit\xunit.targets" Condition="'$(TestFramework)' == 'xunit'" />
<!-- Main test targets -->
diff --git a/eng/testing/xunit/vstest.props b/eng/testing/xunit/vstest.props
deleted file mode 100644
index 152ca6e67db..00000000000
--- a/eng/testing/xunit/vstest.props
+++ /dev/null
@@ -1,15 +0,0 @@
-<Project>
- <PropertyGroup>
- <!-- Microsoft.Net.Test.Sdk brings a lot of satellite assemblies in. -->
- <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
- <TrxTestResultsName>testResults.trx</TrxTestResultsName>
- <HtmlTestResultsName>testResults.html</HtmlTestResultsName>
- <TestResultsName>$(HtmlTestResultsName)</TestResultsName>
- </PropertyGroup>
-
- <ItemGroup>
- <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
- <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
- </ItemGroup>
-</Project>
diff --git a/eng/testing/xunit/vstest.targets b/eng/testing/xunit/vstest.targets
deleted file mode 100644
index 3a638a442c0..00000000000
--- a/eng/testing/xunit/vstest.targets
+++ /dev/null
@@ -1,36 +0,0 @@
-<Project>
- <PropertyGroup>
- <RunCommand>"$(DotNetTool)"</RunCommand>
- <RunCommand Condition="'$(ContinuousIntegrationBuild)' == 'true'">dotnet</RunCommand>
- <RunArguments>test $(TargetFileName)</RunArguments>
-
- <!-- CLI options -->
- <RunArguments>$(RunArguments) --nologo</RunArguments>
- <RunArguments>$(RunArguments) --logger "trx;LogFileName=$(TrxTestResultsName)"</RunArguments>
- <RunArguments>$(RunArguments) --logger "html;LogFileName=$(HtmlTestResultsName)"</RunArguments>
- <RunArguments>$(RunArguments) --framework $(TargetFramework)</RunArguments>
- <RunArguments>$(RunArguments) --platform $(TargetArchitecture)</RunArguments>
- <RunArguments Condition="'$(TestDisableParallelization)' != 'true'">$(RunArguments) --parallel</RunArguments>
- <RunArguments Condition="'$(TestBlame)' == 'true'">$(RunArguments) --blame</RunArguments>
-
- <!-- Categories -->
- <_testFilter Condition="'$(_withCategories)' != ''">$(_withCategories.Replace(';', '&amp;category='))</_testFilter>
- <_testFilter Condition="'$(_withoutCategories)' != ''">$(_testFilter)$(_withoutCategories.Replace(';', '&amp;category!='))</_testFilter>
- <!-- On Windows in bat scripts with delayed expansion enabled we need to escape the bang operator. -->
- <_testFilter Condition="'$(TargetOS)' == 'Windows_NT'">$(_testFilter.Replace('!=', '^!='))</_testFilter>
- <_testFilter>$(_testFilter.Trim('&amp;'))</_testFilter>
- <!-- On Windows in bat scripts with delayed expansion enabled we need to escape the bang operator. -->
- <_testFilter Condition="'$(TestFilter)' != ''">$(_testFilter)&amp;$(TestFilter.Replace('!=', '^!='))</_testFilter>
-
- <RunArguments>$(RunArguments) --filter "($(_testFilter))"</RunArguments>
-
- <!-- User passed in options. -->
- <RunArguments Condition="'$(XUnitOptions)' != ''">$(RunArguments) $(XUnitOptions)</RunArguments>
-
- <!-- RunConfiguration settings. -->
- <RunSettingsOptions Condition="'$(TestDisableParallelization)' == 'true'">$(RunSettingsOptions) RunConfiguration.DisableParallelization=true</RunSettingsOptions>
- <RunSettingsOptions Condition="'$(TestDisableAppDomain)' == 'true'">$(RunSettingsOptions) RunConfiguration.DisableAppDomain=true</RunSettingsOptions>
- <RunSettingsOptions>$(RunSettingsOptions) RunConfiguration.DotNetHostPath="$(RunScriptHost)"</RunSettingsOptions>
- <RunArguments>$(RunArguments) --$(RunSettingsOptions)</RunArguments>
- </PropertyGroup>
-</Project> \ No newline at end of file
diff --git a/eng/testing/xunit/xunit.console.props b/eng/testing/xunit/xunit.console.props
index 59554280e98..36950a75c5b 100644
--- a/eng/testing/xunit/xunit.console.props
+++ b/eng/testing/xunit/xunit.console.props
@@ -2,27 +2,10 @@
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TestResultsName>testResults.xml</TestResultsName>
- <TestRunnerConfigPath>$(MSBuildThisFileDirectory)xunit.runner.json</TestRunnerConfigPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Condition="'$(TargetsNetCoreApp)' == 'true'" Include="Microsoft.DotNet.XUnitConsoleRunner" Version="$(MicrosoftDotNetXUnitConsoleRunnerVersion)" />
<PackageReference Condition="'$(TargetsNetFx)' == 'true'" Include="xunit.runner.console" Version="$(XUnitVersion)" />
-
- <!-- Microsoft.Net.Test.Sdk brings a lot of assemblies with it. To reduce helix payload submission size we disable it on CI. -->
- <PackageReference Condition="'$(ArchiveTests)' != 'true'" Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
- <PackageReference Condition="'$(ArchiveTests)' != 'true'" Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
- <!--
- Microsoft.Net.Test.Sdk has a dependency on Newtonsoft.Json v9.0.1. We upgrade the dependency version
- with the one used in corefx to have a consistent set of dependency versions. Additionally this works
- around a dupliate type between System.Runtime.Serialization.Formatters and Newtonsoft.Json.
- -->
- <PackageReference Condition="'$(ArchiveTests)' != 'true'" Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
- </ItemGroup>
-
- <ItemGroup>
- <None Include="$(TestRunnerConfigPath)"
- CopyToOutputDirectory="PreserveNewest"
- Visible="false" />
</ItemGroup>
</Project>
diff --git a/eng/testing/xunit/xunit.console.targets b/eng/testing/xunit/xunit.console.targets
index 059eede7dcf..ce234b69e83 100644
--- a/eng/testing/xunit/xunit.console.targets
+++ b/eng/testing/xunit/xunit.console.targets
@@ -1,23 +1,27 @@
<Project>
<PropertyGroup>
- <RunArguments>$(TargetFileName)</RunArguments>
- <RunArguments>$(RunArguments) -xml $(TestResultsName)</RunArguments>
- <RunArguments>$(RunArguments) -nologo</RunArguments>
- <RunArguments Condition="'$(ArchiveTests)' == 'true'">$(RunArguments) -nocolor</RunArguments>
+ <_depsFileArgument Condition="'$(GenerateDependencyFile)' == 'true'">--depsfile $(AssemblyName).deps.json</_depsFileArgument>
+ <RunScriptCommand Condition="'$(TargetsNetCoreApp)' == 'true'">"$(RunScriptHost)" exec --runtimeconfig $(AssemblyName).runtimeconfig.json $(_depsFileArgument) xunit.console.dll</RunScriptCommand>
+ <RunScriptCommand Condition="'$(TargetsNetFx)' == 'true'">xunit.console.exe</RunScriptCommand>
+
+ <RunScriptCommand>$(RunScriptCommand) $(TargetFileName)</RunScriptCommand>
+ <RunScriptCommand>$(RunScriptCommand) -xml $(TestResultsName)</RunScriptCommand>
+ <RunScriptCommand>$(RunScriptCommand) -nologo</RunScriptCommand>
+ <RunScriptCommand Condition="'$(ArchiveTests)' == 'true'">$(RunScriptCommand) -nocolor</RunScriptCommand>
<!-- Add local and global options to the argument stack. -->
- <RunArguments Condition="'$(TestDisableParallelization)' == 'true'">$(RunArguments) -maxthreads 1</RunArguments>
- <RunArguments Condition="'$(XUnitMethodName)' != ''">$(RunArguments) -method $(XUnitMethodName)</RunArguments>
- <RunArguments Condition="'$(XUnitClassName)' != ''">$(RunArguments) -class $(XUnitClassName)</RunArguments>
- <RunArguments Condition="'$(XUnitShowProgress)' == 'true'">$(RunArguments) -verbose</RunArguments>
- <RunArguments Condition="'$(TargetsNetFx)' == 'true' and '$(TestDisableAppDomain)' == 'true'">$(RunArguments) -noappdomain</RunArguments>
+ <RunScriptCommand Condition="'$(TestDisableParallelization)' == 'true'">$(RunScriptCommand) -maxthreads 1</RunScriptCommand>
+ <RunScriptCommand Condition="'$(XUnitMethodName)' != ''">$(RunScriptCommand) -method $(XUnitMethodName)</RunScriptCommand>
+ <RunScriptCommand Condition="'$(XUnitClassName)' != ''">$(RunScriptCommand) -class $(XUnitClassName)</RunScriptCommand>
+ <RunScriptCommand Condition="'$(XUnitShowProgress)' == 'true'">$(RunScriptCommand) -verbose</RunScriptCommand>
+ <RunScriptCommand Condition="'$(TargetsNetFx)' == 'true' and '$(TestDisableAppDomain)' == 'true'">$(RunScriptCommand) -noappdomain</RunScriptCommand>
<!-- Add to run argument string -->
- <RunArguments>$(RunArguments)$(_withCategories.Replace(';', ' -trait category='))</RunArguments>
- <RunArguments>$(RunArguments)$(_withoutCategories.Replace(';', ' -notrait category='))</RunArguments>
+ <RunScriptCommand>$(RunScriptCommand)$(_withCategories.Replace(';', ' -trait category='))</RunScriptCommand>
+ <RunScriptCommand>$(RunScriptCommand)$(_withoutCategories.Replace(';', ' -notrait category='))</RunScriptCommand>
<!-- User passed in options. -->
- <RunArguments Condition="'$(XUnitOptions)' != ''">$(RunArguments) $(XUnitOptions)</RunArguments>
+ <RunScriptCommand Condition="'$(XUnitOptions)' != ''">$(RunScriptCommand) $(XUnitOptions)</RunScriptCommand>
</PropertyGroup>
<!-- Overwrite the runner config file with the app local one. -->
@@ -27,7 +31,7 @@
<ItemGroup>
<_testRunnerConfigSourceFile Include="$(TargetDir)$(TargetName).exe.config" />
- <_testRunnerConfigDestFile Include="$(TargetDir)$(_testRunnerName).config" />
+ <_testRunnerConfigDestFile Include="$(TargetDir)xunit.console.exe.config" />
</ItemGroup>
<Copy SourceFiles="@(_testRunnerConfigSourceFile)"
@@ -37,18 +41,6 @@
</Target>
- <!-- Setup run commands. -->
- <PropertyGroup Condition="'$(TargetsNetCoreApp)' == 'true'">
- <RunCommand>"$(RunScriptHost)"</RunCommand>
- <_depsFileRunArgument Condition="'$(GenerateDependencyFile)' == 'true'">--depsfile $(AssemblyName).deps.json</_depsFileRunArgument>
- <RunArguments>exec --runtimeconfig $(AssemblyName).runtimeconfig.json $(_depsFileRunArgument) xunit.console.dll $(RunArguments)</RunArguments>
- </PropertyGroup>
-
- <PropertyGroup Condition="'$(TargetsNetFx)' == 'true'">
- <_testRunnerName>xunit.console.exe</_testRunnerName>
- <RunCommand>$(_testRunnerName)</RunCommand>
- </PropertyGroup>
-
<!-- ResolveAssemblyReferences is the target that populates ReferenceCopyLocalPaths which is what is copied to output directory. -->
<Target Name="CopyRunnerToOutputDirectory" BeforeTargets="ResolveAssemblyReferences">
<ItemGroup>
diff --git a/eng/testing/xunit/xunit.props b/eng/testing/xunit/xunit.props
index 0b6289b9a22..4fed5c3990f 100644
--- a/eng/testing/xunit/xunit.props
+++ b/eng/testing/xunit/xunit.props
@@ -1,6 +1,8 @@
<Project>
<PropertyGroup>
- <TestRunner Condition="'$(TestRunner)' == ''">xunit.console</TestRunner>
+ <!-- Microsoft.Net.Test.Sdk brings a lot of satellite assemblies in. -->
+ <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
+ <TestRunnerConfigPath>$(MSBuildThisFileDirectory)xunit.runner.json</TestRunnerConfigPath>
</PropertyGroup>
<ItemGroup>
@@ -11,6 +13,24 @@
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
</ItemGroup>
- <Import Project="$(MSBuildThisFileDirectory)xunit.console.props" Condition="'$(TestRunner)' == 'xunit.console'" />
- <Import Project="$(MSBuildThisFileDirectory)vstest.props" Condition="'$(TestRunner)' == 'vstest'" />
+ <ItemGroup Condition="'$(ArchiveTests)' != 'true'">
+ <!-- Microsoft.Net.Test.Sdk brings a lot of assemblies with it. To reduce helix payload submission size we disable it on CI. -->
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
+ <PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
+ <!--
+ Microsoft.Net.Test.Sdk has a dependency on Newtonsoft.Json v9.0.1. We upgrade the dependency version
+ with the one used in libraries to have a consistent set of dependency versions. Additionally this works
+ around a dupliate type between System.Runtime.Serialization.Formatters and Newtonsoft.Json.
+ -->
+ <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
+ <PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Include="$(TestRunnerConfigPath)"
+ CopyToOutputDirectory="PreserveNewest"
+ Visible="false" />
+ </ItemGroup>
+
+ <Import Project="$(MSBuildThisFileDirectory)xunit.console.props" />
</Project>
diff --git a/eng/testing/xunit/xunit.targets b/eng/testing/xunit/xunit.targets
index 348be251a9f..b14d3b7cbf2 100644
--- a/eng/testing/xunit/xunit.targets
+++ b/eng/testing/xunit/xunit.targets
@@ -1,16 +1,18 @@
<Project>
+ <!-- Run target (F5) support. -->
<PropertyGroup>
- <!-- Default and user defined categories -->
- <_withCategories Condition="'$(WithCategories)' != ''">;$(WithCategories.Trim(';'))</_withCategories>
- <_withoutCategories Condition="'$(WithoutCategories)' != ''">;$(WithoutCategories.Trim(';'))</_withoutCategories>
+ <RunWorkingDirectory>$(OutDir)</RunWorkingDirectory>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
+ <RunCommand>$(DotNetTool)</RunCommand>
+ <RunArguments>test $(TargetPath) --settings $(OutDir).runsettings</RunArguments>
+ </PropertyGroup>
- <TestScope Condition="'$(TestScope)' == '' and '$(Outerloop)' == 'true'">all</TestScope>
- <_withCategories Condition="'$(TestScope)' == 'outerloop'">$(_withCategories);OuterLoop</_withCategories>
- <_withoutCategories Condition="'$(ArchiveTests)' == 'true'">$(_withoutCategories);IgnoreForCI</_withoutCategories>
- <_withoutCategories Condition="'$(TestScope)' == '' or '$(TestScope)' == 'innerloop'">$(_withoutCategories);OuterLoop</_withoutCategories>
- <_withoutCategories Condition="!$(_withCategories.Contains('failing'))">$(_withoutCategories);failing</_withoutCategories>
+ <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
+ <RunCommand>$(DevEnvDir)Extensions\TestPlatform\vstest.console.exe</RunCommand>
+ <RunArguments>$(TargetPath) --settings:$(OutDir).runsettings</RunArguments>
</PropertyGroup>
- <Import Project="$(MSBuildThisFileDirectory)xunit.console.targets" Condition="'$(TestRunner)' == 'xunit.console'" />
- <Import Project="$(MSBuildThisFileDirectory)vstest.targets" Condition="'$(TestRunner)' == 'vstest'" />
+ <Import Project="$(MSBuildThisFileDirectory)xunit.console.targets" />
</Project>
diff --git a/eng/versioning.targets b/eng/versioning.targets
index 18dc8a1163d..21a442a03f3 100644
--- a/eng/versioning.targets
+++ b/eng/versioning.targets
@@ -10,7 +10,7 @@
<!-- Assembly metadata indicating that an assembly is a framework (as opposed to user) assembly:
Test projects need to not have this because of the way "IsFrameworkAssembly" APIs work to check this. -->
- <ItemGroup Condition="'$(IsTestProject)' != 'true'" >
+ <ItemGroup Condition="'$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'" >
<AssemblyMetadata Include=".NETFrameworkAssembly">
<Value></Value>
</AssemblyMetadata>
@@ -23,7 +23,7 @@
</ItemGroup>
<Target Name="DecideIfWeNeedToIncludeDllSafeSearchPathAttribute"
- Condition="'$(IsDotNetFrameworkProductAssembly)' == 'true' and '$(IsTestProject)' != 'true'">
+ Condition="'$(IsDotNetFrameworkProductAssembly)' == 'true' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'">
<!-- We want to apply the IncludeDllSafeSearchPathAttribute on all DotNet assemblies (non test) that have a reference to System.Runtime.InteropServices -->
<PropertyGroup Condition="'$(IncludeDllSafeSearchPathAttribute)'==''">
diff --git a/src/libraries/Common/tests/Common.Tests.csproj b/src/libraries/Common/tests/Common.Tests.csproj
index 82c731c02af..313fb9f76de 100644
--- a/src/libraries/Common/tests/Common.Tests.csproj
+++ b/src/libraries/Common/tests/Common.Tests.csproj
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CoverageSupported>false</CoverageSupported>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX</TargetFrameworks>
<Nullable>annotations</Nullable>
diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props
index 94ea6b7259a..c24defef879 100644
--- a/src/libraries/Directory.Build.props
+++ b/src/libraries/Directory.Build.props
@@ -57,10 +57,9 @@
<IsTestSupportProject>false</IsTestSupportProject>
<IsTestSupportProject Condition="($(MSBuildProjectFullPath.Contains('\tests\')) or $(MSBuildProjectFullPath.Contains('/tests/'))) and '$(IsTestProject)' != 'true'">true</IsTestSupportProject>
- <IsTestProject Condition="'$(IsTestSupportProject)' == 'true'">true</IsTestProject>
<!-- Treat test assemblies as non-shipping (do not publish or sign them). -->
- <IsShipping Condition="'$(IsTestProject)' == 'true'">false</IsShipping>
+ <IsShipping Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true'">false</IsShipping>
</PropertyGroup>
<!-- Common repo directories -->
@@ -316,35 +315,33 @@
<PlatformManifestFile Condition="'$(BinPlaceTestSharedFramework)' == 'true'">$(TestHostRuntimePath)PlatformManifest.txt</PlatformManifestFile>
</PropertyGroup>
- <ItemGroup Condition="'$(PlatformManifestFile)' != '' and '$(IsTestProject)' == 'true'">
+ <ItemGroup Condition="'$(PlatformManifestFile)' != '' and ('$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true')">
<PackageConflictPlatformManifests Include="$(PlatformManifestFile)" />
</ItemGroup>
- <ItemGroup Condition="'$(IsTestProject)' == 'true' and '$(IsTestSupportProject)' != 'true'">
+ <ItemGroup Condition="'$(IsTestProject)' == 'true'">
<ProjectReference Include="$(CommonTestPath)TestUtilities\TestUtilities.csproj" />
</ItemGroup>
- <PropertyGroup Condition="'$(IsTestProject)' == 'true' and '$(IsTestSupportProject)' != 'true'">
+ <PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<EnableTestSupport>true</EnableTestSupport>
- <EnableCoverageSupport Condition="'$(Coverage)' == 'true' and '$(CoverageSupported)' != 'false'">true</EnableCoverageSupport>
- <EnableLaunchSettings Condition="'$(DotNetBuildFromSource)' != 'true' and '$(BuildAllConfigurations)' != 'true'">true</EnableLaunchSettings>
+ <EnableCoverageSupport>true</EnableCoverageSupport>
</PropertyGroup>
<Import Project="$(RepositoryEngineeringDir)testing\tests.props" Condition="'$(EnableTestSupport)' == 'true'" />
- <Import Project="$(RepositoryEngineeringDir)testing\coverage.props" Condition="'$(EnableCoverageSupport)' == 'true'" />
<!-- Use msbuild path functions as that property is used in bash scripts. -->
<ItemGroup>
- <CoverageExcludeFile Include="$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Common', 'src', 'System', 'SR.*'))" />
- <CoverageExcludeFile Include="$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Common', 'src', 'System', 'NotImplemented.cs'))" />
+ <CoverageExcludeByFile Include="$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Common', 'src', 'System', 'SR.*'))" />
+ <CoverageExcludeByFile Include="$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Common', 'src', 'System', 'NotImplemented.cs'))" />
</ItemGroup>
<ItemGroup>
<!-- Link to the testhost folder to probe additional assemblies. -->
- <CoverageProbePath Include="shared\Microsoft.NETCore.App\$(ProductVersion)" />
+ <CoverageIncludeDirectory Include="shared\Microsoft.NETCore.App\$(ProductVersion)" />
</ItemGroup>
- <ItemDefinitionGroup Condition="'$(IsTestProject)' != 'true'">
+ <ItemDefinitionGroup Condition="'$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'">
<!-- Project references for non-test assemblies should never be copied to the output. -->
<ProjectReference>
<Private>false</Private>
@@ -356,12 +353,12 @@
feature unless they explicitly opt in to it. (Source projects explicitly reference their dependencies,
so they can't inadvertently take a dependency on it.)
-->
- <ItemGroup Condition="'$(IsTestProject)' == 'true' and '$(IncludeUtf8StringAsmRef)' != 'true'">
+ <ItemGroup Condition="('$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true') and '$(IncludeUtf8StringAsmRef)' != 'true'">
<DefaultReferenceExclusions Include="System.Utf8String.Experimental" />
</ItemGroup>
<PropertyGroup>
- <CLSCompliant Condition="'$(CLSCompliant)' == '' and '$(IsTestProject)' == 'true'">false</CLSCompliant>
+ <CLSCompliant Condition="'$(CLSCompliant)' == '' and ('$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true')">false</CLSCompliant>
<CLSCompliant Condition="'$(CLSCompliant)' == ''">true</CLSCompliant>
</PropertyGroup>
</Project>
diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets
index 63c66e0226b..435e3f5be24 100644
--- a/src/libraries/Directory.Build.targets
+++ b/src/libraries/Directory.Build.targets
@@ -31,7 +31,7 @@
Tests which wish to control this should set TestStrongNameKeyId. -->
<TestStrongNameKeyId Condition="'$(TestStrongNameKeyId)' == '' and $(MSBuildProjectName.StartsWith('Microsoft.Extensions.'))">MicrosoftAspNetCore</TestStrongNameKeyId>
<TestStrongNameKeyId Condition="'$(TestStrongNameKeyId)' == ''">Open</TestStrongNameKeyId>
- <StrongNameKeyId Condition="'$(IsTestProject)' == 'true'">$(TestStrongNameKeyId)</StrongNameKeyId>
+ <StrongNameKeyId Condition="'$(IsTestProject)' == 'true' or '$(IsTestSupportProject)' == 'true'">$(TestStrongNameKeyId)</StrongNameKeyId>
</PropertyGroup>
<Import Project="$(MSBuildThisDirectory)intellisense.targets" Condition="'$(DesignTimeBuild)' == 'true'" />
@@ -51,7 +51,7 @@
<!-- Corefx-specific binplacing properties -->
<PropertyGroup>
- <IsRuntimeAssembly Condition="'$(IsRuntimeAssembly)'=='' and '$(IsReferenceAssembly)' != 'true' and '$(BinPlaceRef)' != 'true' and '$(IsTestProject)' != 'true'">true</IsRuntimeAssembly>
+ <IsRuntimeAssembly Condition="'$(IsRuntimeAssembly)'=='' and '$(IsReferenceAssembly)' != 'true' and '$(BinPlaceRef)' != 'true' and '$(IsTestProject)' != 'true' and '$(IsTestSupportProject)' != 'true'">true</IsRuntimeAssembly>
<!-- Try to determine if this is a simple library without a ref project.
https://github.com/dotnet/corefx/issues/14291 is tracking cleaning this up -->
<IsRuntimeAndReferenceAssembly Condition="'$(IsRuntimeAndReferenceAssembly)' == '' and '$(IsRuntimeAssembly)' == 'true' and Exists('$(LibrariesProjectRoot)$(MSBuildProjectName)') and !Exists('$(LibrariesProjectRoot)$(MSBuildProjectName)/ref') and !$(MSBuildProjectName.StartsWith('System.Private'))">true</IsRuntimeAndReferenceAssembly>
@@ -142,7 +142,6 @@
<Import Project="$(RepositoryEngineeringDir)references.targets" />
<Import Project="$(RepositoryEngineeringDir)resolveContract.targets" />
<Import Project="$(RepositoryEngineeringDir)testing\runtimeConfiguration.targets" />
- <Import Project="$(RepositoryEngineeringDir)testing\launchSettings.targets" Condition="'$(EnableLaunchSettings)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)testing\tests.targets" Condition="'$(EnableTestSupport)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)testing\coverage.targets" Condition="'$(EnableCoverageSupport)' == 'true'" />
diff --git a/src/libraries/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj b/src/libraries/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj
index 88cd7f62673..7cffe3caa31 100644
--- a/src/libraries/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj
+++ b/src/libraries/Microsoft.XmlSerializer.Generator/tests/Microsoft.XmlSerializer.Generator.Tests.csproj
@@ -2,7 +2,6 @@
<PropertyGroup>
<DefineConstants>$(DefineConstants);XMLSERIALIZERGENERATORTESTS</DefineConstants>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
- <CoverageSupported>false</CoverageSupported>
<SkipTestsOnPlatform Condition="'$(TargetsMobile)' == 'true' or '$(TargetOS)' == 'FreeBSD' or '$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'armel' or '$(TargetArchitecture)' == 'wasm'">true</SkipTestsOnPlatform>
</PropertyGroup>
<PropertyGroup>
diff --git a/src/libraries/System.Transactions.Local/tests/System.Transactions.Local.Tests.csproj b/src/libraries/System.Transactions.Local/tests/System.Transactions.Local.Tests.csproj
index 750635dac0a..97efb68bab6 100644
--- a/src/libraries/System.Transactions.Local/tests/System.Transactions.Local.Tests.csproj
+++ b/src/libraries/System.Transactions.Local/tests/System.Transactions.Local.Tests.csproj
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <CoverageSupported>false</CoverageSupported>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
</PropertyGroup>
diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj
index f2e7cb3a071..fcacce32125 100644
--- a/src/libraries/tests.proj
+++ b/src/libraries/tests.proj
@@ -1,15 +1,21 @@
<Project Sdk="Microsoft.Build.Traversal">
- <Import Project="$(RepositoryEngineeringDir)testing\coverage.props" Condition="'$(Coverage)' == 'true'" />
-
<PropertyGroup>
- <TestInParallel Condition="'$(Coverage)' != 'true'">true</TestInParallel>
+ <TestInParallel Condition="'$(Coverage)' == 'true'">false</TestInParallel>
<!-- For tests we want to continue running if a test run failed. -->
<TestContinueOnError>ErrorAndContinue</TestContinueOnError>
<TraversalGlobalProperties>BuildAllProjects=true</TraversalGlobalProperties>
- <CoverageReportInputPath>$(ArtifactsBinDir)*.Tests/**/coverage.xml</CoverageReportInputPath>
+ <CoverageReportInputPath>$(ArtifactsBinDir)*.Tests\*\coverage.opencover.xml</CoverageReportInputPath>
<CoverageReportDir>$(ArtifactsDir)coverage</CoverageReportDir>
+ <EnableCoverageSupport>true</EnableCoverageSupport>
</PropertyGroup>
+
+ <!-- Projects that don't support code coverage measurement. -->
+ <ItemGroup Condition="'$(Coverage)' == 'true'">
+ <ProjectExclusions Include="$(CommonTestPath)Common.Tests.csproj" />
+ <ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj" />
+ <ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Transactions.Local\tests\System.Transactions.Local.Tests.csproj" />
+ </ItemGroup>
<ItemGroup>
<!-- We currently only test with C# projects. -->
@@ -20,14 +26,9 @@
Condition="'$(BuildAllConfigurations)' == 'true'" />
</ItemGroup>
- <Target Name="GenerateCoverageReport"
- Condition="'$(Coverage)' == 'true' and '$(SkipCoverageReport)' != 'true'"
+ <Target Name="GenerateMergedCoverageReport"
+ Condition="'$(Coverage)' == 'true'"
AfterTargets="Test"
- Inputs="$(CoverageReportInputPath)"
- Outputs="$(CoverageReportResultsPath)">
- <Exec Command="$(CoverageReportCommandLine)" />
- </Target>
-
- <Import Project="$(RepositoryEngineeringDir)testing\coverage.targets" Condition="'$(Coverage)' == 'true'" />
+ DependsOnTargets="GenerateCoverageReport" />
</Project>