зеркало из https://github.com/microsoft/scalar.git
GitHelpers: ignore whitespace lines
Signed-off-by: Derrick Stolee <stolee@gmail.com>
This commit is contained in:
Родитель
eb321dc9ca
Коммит
cbf6f828e2
|
@ -980,7 +980,7 @@ namespace Scalar.FunctionalTests.Tests.GitCommands
|
|||
string command = "checkout -b tests/functional/OpenFileThenCheckout_2";
|
||||
ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command);
|
||||
ProcessResult actualResult = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command);
|
||||
GitHelpers.ErrorsShouldMatch(command, expectedResult, actualResult);
|
||||
GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors);
|
||||
actualResult.Errors.ShouldContain("Switched to a new branch");
|
||||
|
||||
this.ValidateGitCommand("status");
|
||||
|
|
|
@ -261,7 +261,7 @@ namespace Scalar.FunctionalTests.Tests.GitCommands
|
|||
|
||||
if (!ignoreErrors)
|
||||
{
|
||||
GitHelpers.ErrorsShouldMatch(command, expectedResult, actualResult);
|
||||
GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors);
|
||||
}
|
||||
|
||||
if (command != "status" && checkStatus)
|
||||
|
|
|
@ -87,9 +87,8 @@ namespace Scalar.FunctionalTests.Tools
|
|||
ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command, environmentVariables);
|
||||
ProcessResult actualResult = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command, environmentVariables);
|
||||
|
||||
ErrorsShouldMatch(command, expectedResult, actualResult);
|
||||
actualResult.Output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.ShouldMatchInOrder(expectedResult.Output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries), LinesAreEqual, command + " Output Lines");
|
||||
LinesShouldMatch(command + " Errors Lines", actualResult.Errors, expectedResult.Errors);
|
||||
LinesShouldMatch(command + " Output Lines", actualResult.Output, expectedResult.Output);
|
||||
|
||||
if (command != "status")
|
||||
{
|
||||
|
@ -97,10 +96,18 @@ namespace Scalar.FunctionalTests.Tools
|
|||
}
|
||||
}
|
||||
|
||||
public static void ErrorsShouldMatch(string command, ProcessResult expectedResult, ProcessResult actualResult)
|
||||
public static void LinesShouldMatch(string message, string expected, string actual)
|
||||
{
|
||||
actualResult.Errors.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.ShouldMatchInOrder(expectedResult.Errors.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries), LinesAreEqual, command + " Errors Lines");
|
||||
IEnumerable<string> actualLines = NonEmptyLines(actual);
|
||||
IEnumerable<string> expectedLines = NonEmptyLines(expected);
|
||||
actualLines.ShouldMatchInOrder(expectedLines, LinesAreEqual, message);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> NonEmptyLines(string data)
|
||||
{
|
||||
return data
|
||||
.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where(s => !string.IsNullOrWhiteSpace(s));
|
||||
}
|
||||
|
||||
private static bool LinesAreEqual(string actualLine, string expectedLine)
|
||||
|
|
|
@ -136,12 +136,12 @@ namespace Scalar.Tests.Should
|
|||
|
||||
foreach (T groupExtraItem in groupExtraItems)
|
||||
{
|
||||
errorMessage.AppendLine(string.Format("Extra: {0}", groupExtraItem));
|
||||
errorMessage.AppendLine(string.Format("Extra: '{0}'", groupExtraItem));
|
||||
}
|
||||
|
||||
foreach (T groupMissingItem in groupMissingItems)
|
||||
{
|
||||
errorMessage.AppendLine(string.Format("Missing: {0}", groupMissingItem));
|
||||
errorMessage.AppendLine(string.Format("Missing: '{0}'", groupMissingItem));
|
||||
}
|
||||
|
||||
if (shouldMatchInOrder)
|
||||
|
@ -150,7 +150,7 @@ namespace Scalar.Tests.Should
|
|||
{
|
||||
if (!equals(groupList[i], expectedValuesList[i]))
|
||||
{
|
||||
errorMessage.AppendLine($"Items ordered differently, found: {groupList[i]} expected: {expectedValuesList[i]}");
|
||||
errorMessage.AppendLine($"Items ordered differently, found: '{groupList[i]}' expected: '{expectedValuesList[i]}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче