Merge pull request #3013 from eerhardt/StreamForwarder
Console.Write() doesn't show output until a newline
This commit is contained in:
commit
eb7054c90d
7 changed files with 173 additions and 20 deletions
53
test/dotnet-run.UnitTests/GivenARunCommand.cs
Normal file
53
test/dotnet-run.UnitTests/GivenARunCommand.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Moq;
|
||||
using NuGet.Frameworks;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Run.Tests
|
||||
{
|
||||
public class GivenARunCommand : TestBase
|
||||
{
|
||||
private const int RunExitCode = 29;
|
||||
|
||||
[Fact]
|
||||
public void ItDoesntRedirectStandardOutAndError()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppSimple")
|
||||
.WithLockFiles();
|
||||
|
||||
new BuildCommand(instance.TestRoot)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
// use MockBehavior.Strict to ensure the RunCommand doesn't call CaptureStdOut, ForwardStdOut, etc.
|
||||
Mock<ICommand> failOnRedirectOutputCommand = new Mock<ICommand>(MockBehavior.Strict);
|
||||
failOnRedirectOutputCommand
|
||||
.Setup(c => c.Execute())
|
||||
.Returns(new CommandResult(null, RunExitCode, null, null));
|
||||
|
||||
Mock<ICommandFactory> commandFactoryMock = new Mock<ICommandFactory>();
|
||||
commandFactoryMock
|
||||
.Setup(c => c.Create(
|
||||
It.IsAny<string>(),
|
||||
It.IsAny<IEnumerable<string>>(),
|
||||
It.IsAny<NuGetFramework>(),
|
||||
It.IsAny<string>()))
|
||||
.Returns(failOnRedirectOutputCommand.Object);
|
||||
|
||||
RunCommand runCommand = new RunCommand(commandFactoryMock.Object);
|
||||
runCommand.Project = instance.TestRoot;
|
||||
|
||||
runCommand.Start()
|
||||
.Should()
|
||||
.Be(RunExitCode);
|
||||
}
|
||||
}
|
||||
}
|
18
test/dotnet-run.UnitTests/dotnet-run.UnitTests.xproj
Normal file
18
test/dotnet-run.UnitTests/dotnet-run.UnitTests.xproj
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0.24720" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24720</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>2a5eec38-3030-44ef-9e58-6771e7bab01d</ProjectGuid>
|
||||
<RootNamespace>Microsoft.DotNet.Tools.Run.UnitTests</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
28
test/dotnet-run.UnitTests/project.json
Normal file
28
test/dotnet-run.UnitTests/project.json
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.0-rc3-*"
|
||||
},
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
|
||||
"dotnet": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
||||
"target": "project"
|
||||
},
|
||||
"xunit": "2.1.0",
|
||||
"moq.netcore": "4.4.0-beta8",
|
||||
"dotnet-test-xunit": "1.0.0-rc2-173361-36"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": [
|
||||
"dotnet5.4",
|
||||
"portable-net451+win8"
|
||||
]
|
||||
}
|
||||
},
|
||||
"testRunner": "xunit"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue