Skip to content

Fix #157: Tests using OutputReader sometimes hang #158

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
Feb 15, 2016
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
16 changes: 3 additions & 13 deletions test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ await requestContext.SendResult(
ChosenItem = "a"
});

// Skip the initial script lines (6 script lines plus 3 blank lines)
await outputReader.ReadLines(9);
// Skip the initial script lines (6 script lines plus 2 blank lines)
string[] outputLines = await outputReader.ReadLines(8);

// Wait for the selection to appear as output
await evaluateTask;
Expand Down Expand Up @@ -541,18 +541,8 @@ await requestContext.SendResult(
// Skip the initial script lines (4 script lines plus 2 blank lines)
string[] scriptLines = await outputReader.ReadLines(6);

// In some cases an extra newline appears after the script lines.
// I have no idea why this happens, but it normally seems to occur
// on my local machine and not the CI server. For now, adjust for
// it here.
string outputLine = await outputReader.ReadLine();
if (string.IsNullOrEmpty(outputLine))
{
outputLine = await outputReader.ReadLine();
}

// Verify the first line
Assert.Equal("Name: John", outputLine);
Assert.Equal("Name: John", await outputReader.ReadLine());

// Verify the rest of the output
string[] outputLines = await outputReader.ReadLines(4);
Expand Down
6 changes: 4 additions & 2 deletions test/PowerShellEditorServices.Test.Host/OutputReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ public async Task<string> ReadLine(string expectedOutputCategory = "stdout")
outputLines[i],

// The line has a newline if it's not the last segment or
// if the current output string ends with a newline
// if the last segment is not an empty string and the
// complete output string ends with a newline
i < outputLines.Length - 1 ||
nextOutputEvent.Output.EndsWith("\n")));
(outputLines[outputLines.Length - 1].Length > 0 &&
nextOutputEvent.Output.EndsWith("\n"))));
}
}

Expand Down