Use vstest xml logger for helix (#18491)

This commit is contained in:
Hao Kung 2020-01-24 09:38:16 -08:00 committed by GitHub
parent 524bba8ff4
commit 9501874f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 9 deletions

View File

@ -44,7 +44,7 @@ REM only puts the explicit filter traits the user provided in
REM Filter syntax: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md
set NONFLAKY_FILTER="Flaky:All!=true&Flaky:Helix:All!=true&Flaky:Helix:Queue:All!=true&Flaky:Helix:Queue:%HELIX%!=true"
echo Running non-flaky tests.
%DOTNET_ROOT%\dotnet vstest %target% --logger:trx --TestCaseFilter:%NONFLAKY_FILTER%
%DOTNET_ROOT%\dotnet vstest %target% --logger:xunit --TestCaseFilter:%NONFLAKY_FILTER%
if errorlevel 1 (
echo Failure in non-flaky test 1>&2
set exit_code=1
@ -59,5 +59,8 @@ if errorlevel 1 (
REM DO NOT EXIT and DO NOT SET EXIT_CODE to 1
)
echo "Copying TestResults\TestResults.xml to ."
copy TestResults\TestResults.xml testResults.xml
exit /b %exit_code%

View File

@ -30,7 +30,6 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Used by SkipOnHelix attribute
export helix="$helix_queue_name"
RESET="\033[0m"
RED="\033[0;31m"
YELLOW="\033[0;33m"
@ -94,7 +93,7 @@ fi
# Filter syntax: https://github.com/Microsoft/vstest-docs/blob/master/docs/filter.md
NONFLAKY_FILTER="Flaky:All!=true&Flaky:Helix:All!=true&Flaky:Helix:Queue:All!=true&Flaky:Helix:Queue:$helix_queue_name!=true"
echo "Running non-flaky tests."
$DOTNET_ROOT/dotnet vstest $test_binary_path --logger:trx --TestCaseFilter:"$NONFLAKY_FILTER"
$DOTNET_ROOT/dotnet vstest $test_binary_path --logger:xunit --TestCaseFilter:"$NONFLAKY_FILTER"
nonflaky_exitcode=$?
if [ $nonflaky_exitcode != 0 ]; then
echo "Non-flaky tests failed!" 1>&2
@ -109,6 +108,8 @@ if [ $? != 0 ]; then
# DO NOT EXIT
fi
echo "Copying TestResults/TestResults to ."
cp TestResults/TestResults.xml testResults.xml
echo "Copying artifacts/logs to $HELIX_WORKITEM_UPLOAD_ROOT/../"
shopt -s globstar
cp artifacts/log/**/*.log $HELIX_WORKITEM_UPLOAD_ROOT/../

View File

@ -1,14 +1,10 @@
<Project>
<!-- Item group has to be defined here becasue Helix.props is evaluated before xunit.runner.console.props -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<HelixContent Condition="'$(XunitConsole472Path)' != ''" Include="$([System.IO.Path]::GetDirectoryName('$(XunitConsole472Path)'))/**/*" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="$(BuildHelixPayload)">
<Content Include="@(HelixContent)" />
</ItemGroup>
<!--
This target is meant to be used when invoking helix tests on one project at a time.
@ -35,6 +31,10 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
</MSBuild>
</Target>
<ItemGroup>
<PackageReference Include="XunitXml.TestLogger" Version="2.1.26" />
</ItemGroup>
<Target Name="_SetCreateHelixPayload">
<PropertyGroup>
<_SelectedPlatforms>@(HelixProjectPlatform)</_SelectedPlatforms>
@ -60,6 +60,11 @@ Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
<Target Name="_CreateHelixWorkItem" Condition="$(BuildHelixPayload)">
<ItemGroup>
<HelixContent Include="$(OutputPath)/Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestAdapter.dll" />
<HelixContent Include="$(OutputPath)/Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.dll" />
</ItemGroup>
<PropertyGroup>
<!-- Extract the effective queue name from this format "(name)host@dockerimage". This is sometimes used in test code to skip tests. -->
<_HelixFriendlyNameTargetQueue>$(HelixTargetQueue)</_HelixFriendlyNameTargetQueue>