fix local build and ci build failures

This commit is contained in:
Krzysztof Wicher 2016-12-28 14:50:34 -08:00
parent e9dc08eafa
commit efe1b7b143
10 changed files with 51 additions and 36 deletions

View file

@ -24,5 +24,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<StringAssertions>(assertions);
}
public static AndConstraint<StringAssertions> ContainVisuallySameFragment(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
{
Execute.Assertion
.ForCondition(NormalizeLineEndings(assertions.Subject).Contains(NormalizeLineEndings(expected)))
.BecauseOf(because, becauseArgs)
.FailWith($"String \"{assertions.Subject}\" does not contain visually same fragment string \"{expected}\".");
return new AndConstraint<StringAssertions>(assertions);
}
}
}

View file

@ -17,9 +17,8 @@
<ProjectReference Include="..\..\src\Microsoft.DotNet.TestFramework\Microsoft.DotNet.TestFramework.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
<ProjectReference Include="..\..\src\Microsoft.DotNet.ProjectJsonMigration\Microsoft.DotNet.ProjectJsonMigration.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
<ProjectReference Include="..\..\src\Microsoft.DotNet.ProjectJsonMigration\Microsoft.DotNet.ProjectJsonMigration.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Sln.Internal\Microsoft.DotNet.Cli.Sln.Internal.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>

View file

@ -20,6 +20,8 @@
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Sln.Internal\Microsoft.DotNet.Cli.Sln.Internal.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.ProjectJsonMigration\Microsoft.DotNet.ProjectJsonMigration.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.InternalAbstractions\Microsoft.DotNet.InternalAbstractions.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>

View file

@ -36,7 +36,7 @@ Additional Arguments:
var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"add project {helpArg}");
cmd.Should().Pass();
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Theory]
@ -72,7 +72,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"add {solutionName} project p.csproj");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -91,7 +91,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"add InvalidSolution.sln project {projectToAdd}");
cmd.Should().Fail();
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -111,7 +111,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"add project {projectToAdd}");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Invalid solution `{solutionPath}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -129,7 +129,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput(@"add App.sln project");
cmd.Should().Fail();
cmd.StdErr.Should().Be("You must specify at least one project to add.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -148,7 +148,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput(@"add project App.csproj");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Specified solution file {solutionPath + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -167,7 +167,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"add project {projectToAdd}");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Theory]

View file

@ -59,7 +59,8 @@ Advanced Commands:
{
var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"{helpArg}");
cmd.Should().Pass().And.HaveStdOutContaining(HelpText);
cmd.Should().Pass();
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
}
}
}

View file

@ -35,7 +35,7 @@ Options:
{
var cmd = new ListP2PsCommand().Execute(helpArg);
cmd.Should().Pass();
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Theory]
@ -72,7 +72,7 @@ Options:
.Execute($"\"{setup.ValidRefCsprojPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Be($"Could not find project or directory `{projName}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -87,7 +87,7 @@ Options:
.Execute($"\"{setup.ValidRefCsprojPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Be("Project `Broken/Broken.csproj` is invalid.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -101,7 +101,7 @@ Options:
.Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Be($"Found more than one project in `{workingDir + Path.DirectorySeparatorChar}`. Please specify which one to use.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -114,7 +114,7 @@ Options:
.Execute($"\"{setup.ValidRefCsprojPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Be($"Could not find any project in `{setup.TestRoot + Path.DirectorySeparatorChar}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -144,7 +144,7 @@ Options:
.WithProject(lib.CsProjPath)
.Execute();
cmd.Should().Pass();
cmd.StdOut.Should().Be(OutputText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText);
}
[Fact]
@ -169,7 +169,7 @@ Options:
.WithProject(lib.CsProjPath)
.Execute();
cmd.Should().Pass();
cmd.StdOut.Should().Be(OutputText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText);
}
private TestSetup Setup([System.Runtime.CompilerServices.CallerMemberName] string callingMethod = nameof(Setup), string identifier = "")

View file

@ -6,7 +6,6 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>dotnet-list-p2ps.Tests</AssemblyName>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
<DefineConstants>$(DefineConstants);DISABLE_TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
@ -24,6 +23,8 @@
<ProjectReference Include="..\..\src\Microsoft.DotNet.InternalAbstractions\Microsoft.DotNet.InternalAbstractions.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Sln.Internal\Microsoft.DotNet.Cli.Sln.Internal.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.ProjectJsonMigration\Microsoft.DotNet.ProjectJsonMigration.csproj" />
<ProjectReference Include="..\Msbuild.Tests.Utilities\Msbuild.Tests.Utilities.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">

View file

@ -31,7 +31,7 @@ Options:
var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"list projects {helpArg}");
cmd.Should().Pass();
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Theory]
@ -66,7 +66,7 @@ Options:
.ExecuteWithCapturedOutput($"list {solutionName} projects");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -84,7 +84,7 @@ Options:
.ExecuteWithCapturedOutput("list InvalidSolution.sln projects");
cmd.Should().Fail();
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -103,7 +103,7 @@ Options:
.ExecuteWithCapturedOutput("list projects");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Invalid solution `{solutionFullPath}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -122,7 +122,7 @@ Options:
.ExecuteWithCapturedOutput("list projects");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Specified solution file {solutionDir + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -140,7 +140,7 @@ Options:
.ExecuteWithCapturedOutput("list projects");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -179,7 +179,7 @@ Options:
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("list projects");
cmd.Should().Pass();
cmd.StdOut.Should().Be(OutputText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText);
}
}
}

View file

@ -23,6 +23,8 @@
<ProjectReference Include="..\..\src\Microsoft.DotNet.InternalAbstractions\Microsoft.DotNet.InternalAbstractions.csproj">
<FromP2P>true</FromP2P>
</ProjectReference>
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Sln.Internal\Microsoft.DotNet.Cli.Sln.Internal.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.ProjectJsonMigration\Microsoft.DotNet.ProjectJsonMigration.csproj" />
<ProjectReference Include="..\Msbuild.Tests.Utilities\Msbuild.Tests.Utilities.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">

View file

@ -8,7 +8,7 @@ using System;
using System.IO;
using Xunit;
namespace Microsoft.DotNet.Cli.Remove.P2P.Tests
namespace Microsoft.DotNet.Cli.Remove.Project.Tests
{
public class GivenDotnetRemoveProj : TestBase
{
@ -34,7 +34,7 @@ Additional Arguments:
var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"remove project {helpArg}");
cmd.Should().Pass();
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -70,7 +70,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"remove {solutionName} project p.csproj");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -89,7 +89,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"remove InvalidSolution.sln project {projectToRemove}");
cmd.Should().Fail();
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -109,7 +109,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Invalid solution `{solutionPath}`.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -127,7 +127,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput(@"remove App.sln project");
cmd.Should().Fail();
cmd.StdErr.Should().Be("You must specify at least one project to remove.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -146,7 +146,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput(@"remove project App.csproj");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Specified solution file {solutionPath + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -165,7 +165,7 @@ Additional Arguments:
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
cmd.Should().Fail();
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use.");
cmd.StdOut.Should().Be(HelpText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
}
[Fact]
@ -237,7 +237,7 @@ Additional Arguments:
string outputText = $@"Project reference `{projectToRemove}` removed.
Project reference `{projectToRemove}` removed.";
cmd.StdOut.Should().Be(outputText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText);
slnFile = SlnFile.Read(solutionPath);
slnFile.Projects.Count.Should().Be(1);
@ -267,7 +267,7 @@ Project reference `{projectToRemove}` removed.";
string outputText = $@"Project reference `idontexist.csproj` could not be found.
Project reference `{projectToRemove}` removed.
Project reference `idontexisteither.csproj` could not be found.";
cmd.StdOut.Should().Be(outputText);
cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText);
slnFile = SlnFile.Read(solutionPath);
slnFile.Projects.Count.Should().Be(1);