Skip to content

Do not fail tests immediately #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions Runtime.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<BuildPortable Condition=" '$(BuildPortable)' == '' ">true</BuildPortable>
<BuildInParallel Condition=" '$(BuildInParallel)' == '' And $(MSBuildNodeCount) &gt; 1 ">true</BuildInParallel>
<BuildInParallel Condition=" '$(BuildInParallel)' == '' ">false</BuildInParallel>
<TestInParallel Condition=" '$(TestInParallel)' == '' ">$(BuildInParallel)</TestInParallel>
<TestInParallel Condition=" '$(TestInParallel)' == '' ">false</TestInParallel>
<TestResultsDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\test\TestResults\</TestResultsDirectory>
<SkipStrongNamesExe>$(MSBuildThisFileDirectory)packages\Microsoft.Web.SkipStrongNames.1.0.0\tools\SkipStrongNames.exe</SkipStrongNamesExe>
<SkipStrongNamesXml>$(MSBuildThisFileDirectory)tools\SkipStrongNames.xml</SkipStrongNamesXml>
Expand Down Expand Up @@ -65,25 +65,24 @@

<Target Name="RestorePackages" DependsOnTargets="DownloadNuGet">
<ItemGroup>
<_NuGetPackagesAndSolutions Include="src\System.Net.Http.Formatting.NetCore\packages.config;
test\System.Net.Http.Formatting.NetCore.Test\packages.config;
Runtime.sln" />
<_NuGetPackagesAndSolutions Include="Runtime.sln" />

<!-- Avoid restoring RuntimePortable.sln directly. -->
<_NuGetPackagesAndSolutions Include="src\System.Net.Http.Formatting.NetCore\packages.config;
test\System.Net.Http.Formatting.NetCore.Test\packages.config"
Condition=" '$(BuildPortable)' == 'true' " />
<_ProjectsToRestore Include="src\System.Net.Http.Formatting.NetStandard\System.Net.Http.Formatting.NetStandard.csproj;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

another nit: this project is restored transitively and it's more reliable not to kick that off at the same time as the test project

test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj"
<_ProjectsToRestore Include="test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj"
Condition=" '$(BuildPortable)' == 'true' " />
</ItemGroup>

<Message Text="Restoring NuGet packages..." Importance="High" />
<Exec Command='"$(NuGetExe)" restore "%(_NuGetPackagesAndSolutions.Identity)" ^
-PackagesDirectory packages -NonInteractive ^
-Verbosity normal -ConfigFile "$(MSBuildThisFileDirectory)\.nuget\NuGet.Config"' />
<MSBuild Projects="@(_ProjectsToRestore)" Targets="Restore" Properties="Configuration=$(Configuration)"
Condition=" '$(BuildPortable)' == 'true' " />
-Verbosity quiet -ConfigFile "$(MSBuildThisFileDirectory)\.nuget\NuGet.Config"' />
<MSBuild Projects="@(_ProjectsToRestore)" Targets="Restore"
BuildInParallel="$(BuildInParallel)"
Condition=" '$(BuildPortable)' == 'true' "
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);VisualStudioVersion=$(VisualStudioVersion)" />
</Target>

<!-- Pick the right Microsoft.Web.FxCop package to use and copy it to a standard location. -->
Expand All @@ -110,9 +109,7 @@
Properties="Configuration=$(Configuration);CodeAnalysis=$(CodeAnalysis);StyleCopEnabled=$(StyleCopEnabled);VisualStudioVersion=$(VisualStudioVersion)" />
</Target>

<Target Name="UnitTest" DependsOnTargets="CheckSkipStrongNames;Build">
<CallTarget Targets="RunTests;PrintTestRunSummary" RunEachTargetSeparately="True" />
</Target>
<Target Name="UnitTest" DependsOnTargets="Build;PrintTestRunSummary" />

<Target Name="RunTests" DependsOnTargets="CheckSkipStrongNames">
<ItemGroup>
Expand All @@ -128,7 +125,9 @@
<RemoveDir Directories="$(TestResultsDirectory)" />
<MakeDir Directories="$(TestResultsDirectory)" />

<MSBuild Projects="@(_XunitProject)" BuildInParallel="$(TestInParallel)" Targets="Xunit" />
<MSBuild Projects="@(_XunitProject)" BuildInParallel="$(TestInParallel)" Targets="Xunit">
<Output TaskParameter="TargetOutputs" ItemName="_ExitCodes" />
</MSBuild>

<!-- Failures in this project will fail build. But, results will not be included in test run summary. -->
<MSBuild
Expand All @@ -145,7 +144,11 @@
<Error Text="Unit tests will not run correctly unless SkipStrongNames is Enabled. Current status: $(Status). Run build.cmd EnableSkipStrongNames to fix this problem." Condition="'$(Status)' != 'Enabled'" />
</Target>

<Target Name="PrintTestRunSummary">
<Target Name="PrintTestRunSummary" DependsOnTargets="RunTests">
<PrintTestRunSummary TestResultsDirectory="$(TestResultsDirectory)" />

<!-- PrintTestRunSummary stops MSBuild if tests failed. But the Xunit target may fail for other reasons... -->
<Error Text="Testing failed with exit code '%(Code)':%0A@(_ExitCodes -> ' %(Identity)', '%0A')"
Condition=" '%(Code)' != '0' " />
</Target>
</Project>
6 changes: 4 additions & 2 deletions build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (

if "%1" == "" goto BuildDefaults

%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal /t:%*
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M ^
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary /t:%*
if %ERRORLEVEL% neq 0 goto BuildFail
goto BuildSuccess

:BuildDefaults
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M ^
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary
if %ERRORLEVEL% neq 0 goto BuildFail
goto BuildSuccess

Expand Down
8 changes: 4 additions & 4 deletions src/Common/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static T[] AppendAndReallocate<T>(this T[] array, T value)
}

/// <summary>
/// Return the enumerable as an Array, copying if required. Optimized for common case where it is an Array.
/// Return the enumerable as an Array, copying if required. Optimized for common case where it is an Array.
/// Avoid mutating the return value.
/// </summary>
public static T[] AsArray<T>(this IEnumerable<T> values)
Expand All @@ -43,7 +43,7 @@ public static T[] AsArray<T>(this IEnumerable<T> values)
}

/// <summary>
/// Return the enumerable as a Collection of T, copying if required. Optimized for the common case where it is
/// Return the enumerable as a Collection of T, copying if required. Optimized for the common case where it is
/// a Collection of T and avoiding a copy if it implements IList of T. Avoid mutating the return value.
/// </summary>
public static Collection<T> AsCollection<T>(this IEnumerable<T> enumerable)
Expand Down Expand Up @@ -78,9 +78,9 @@ public static IList<T> AsIList<T>(this IEnumerable<T> enumerable)
}
return new List<T>(enumerable);
}

/// <summary>
/// Return the enumerable as a List of T, copying if required. Optimized for common case where it is an List of T
/// Return the enumerable as a List of T, copying if required. Optimized for common case where it is an List of T
/// or a ListWrapperCollection of T. Avoid mutating the return value.
/// </summary>
public static List<T> AsList<T>(this IEnumerable<T> enumerable)
Expand Down
24 changes: 12 additions & 12 deletions src/Common/CommonWebApiResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Common/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ internal static ArgumentException ArgumentUriNotAbsolute(string parameterName, U
}

/// <summary>
/// Creates an <see cref="ArgumentException"/> with a message saying that the argument must be an absolute URI
/// Creates an <see cref="ArgumentException"/> with a message saying that the argument must be an absolute URI
/// without a query or fragment identifier and then logs it with <see cref="F:TraceLevel.Error"/>.
/// </summary>
/// <param name="parameterName">The name of the parameter that caused the current exception.</param>
Expand Down
28 changes: 14 additions & 14 deletions src/System.Net.Http.Formatting/ByteRangeStreamContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace System.Net.Http
{
/// <summary>
/// <see cref="HttpContent"/> implementation which provides a byte range view over a stream used to generate HTTP
/// 206 (Partial Content) byte range responses. The <see cref="ByteRangeStreamContent"/> supports one or more
/// byte ranges regardless of whether the ranges are consecutive or not. If there is only one range then a
/// 206 (Partial Content) byte range responses. The <see cref="ByteRangeStreamContent"/> supports one or more
/// byte ranges regardless of whether the ranges are consecutive or not. If there is only one range then a
/// single partial response body containing a Content-Range header is generated. If there are more than one
/// ranges then a multipart/byteranges response is generated where each body part contains a range indicated
/// by the associated Content-Range header field.
Expand All @@ -33,9 +33,9 @@ public class ByteRangeStreamContent : HttpContent

/// <summary>
/// <see cref="HttpContent"/> implementation which provides a byte range view over a stream used to generate HTTP
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// </summary>
/// <param name="content">The stream over which to generate a byte range view.</param>
/// <param name="range">The range or ranges, typically obtained from the Range HTTP request header field.</param>
Expand All @@ -47,9 +47,9 @@ public ByteRangeStreamContent(Stream content, RangeHeaderValue range, string med

/// <summary>
/// <see cref="HttpContent"/> implementation which provides a byte range view over a stream used to generate HTTP
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// </summary>
/// <param name="content">The stream over which to generate a byte range view.</param>
/// <param name="range">The range or ranges, typically obtained from the Range HTTP request header field.</param>
Expand All @@ -62,9 +62,9 @@ public ByteRangeStreamContent(Stream content, RangeHeaderValue range, string med

/// <summary>
/// <see cref="HttpContent"/> implementation which provides a byte range view over a stream used to generate HTTP
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// </summary>
/// <param name="content">The stream over which to generate a byte range view.</param>
/// <param name="range">The range or ranges, typically obtained from the Range HTTP request header field.</param>
Expand All @@ -76,9 +76,9 @@ public ByteRangeStreamContent(Stream content, RangeHeaderValue range, MediaTypeH

/// <summary>
/// <see cref="HttpContent"/> implementation which provides a byte range view over a stream used to generate HTTP
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// 206 (Partial Content) byte range responses. If none of the requested ranges overlap with the current extend
/// of the selected resource represented by the <paramref name="content"/> parameter then an
/// <see cref="InvalidByteRangeException"/> is thrown indicating the valid Content-Range of the content.
/// </summary>
/// <param name="content">The stream over which to generate a byte range view.</param>
/// <param name="range">The range or ranges, typically obtained from the Range HTTP request header field.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace System.Net.Http.Formatting
{
/// <summary>
/// Base class for writing a synchronous formatter on top of the asynchronous formatter infrastructure.
/// Base class for writing a synchronous formatter on top of the asynchronous formatter infrastructure.
/// This does not guarantee non-blocking threads. The only way to guarantee that we don't block a thread on IO is
/// to use the asynchronous <see cref="MediaTypeFormatter"/>.
/// </summary>
Expand Down Expand Up @@ -219,13 +219,13 @@ private static Stream GetBufferStream(Stream innerStream, int bufferSize)
{
Contract.Assert(innerStream != null);

// We wrap the inner stream in a non-closing delegating stream so that we allow the user
// We wrap the inner stream in a non-closing delegating stream so that we allow the user
// to use the using (...) pattern yet not break the contract of formatters not closing
// the inner stream.
Stream nonClosingStream = new NonClosingDelegatingStream(innerStream);

// This uses a naive buffering. BufferedStream() will block the thread while it drains the buffer.
// We can explore a smarter implementation that async drains the buffer.
// This uses a naive buffering. BufferedStream() will block the thread while it drains the buffer.
// We can explore a smarter implementation that async drains the buffer.
return new BufferedStream(nonClosingStream, bufferSize);
}
}
Expand Down
Loading