Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,18 @@ void FileRedirectionOutput::Append(const std::wstring& text)
{
if (m_file.is_open())
{
const auto multiByte = to_multi_byte_string(text, CP_UTF8);
auto multiByte = to_multi_byte_string(text, CP_UTF8);

// Writing \r\n to an ostream will cause two new lines to be written rather
Copy link
Member

Choose a reason for hiding this comment

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

Will \n will be written without \r in the final file output?

Also, I don't think ostream was the issue, iirc it was a Windows API we were calling the duplicated the newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, when I was testing it, I called ostream << "test\r\n" and I see two new lines in the file.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this ostream the fake file that is then redirected? I could be wrong, it has been a long time since I looked at this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe so, the m_file points directly to the stdout file.

// than one. Change all \r\n to \n.
std::string slashRslashN = "\r\n";
std::string slashN = "\n";
size_t start_pos = 0;
while ((start_pos = multiByte.find(slashRslashN, start_pos)) != std::string::npos) {
multiByte.replace(start_pos, slashRslashN.length(), slashN);
start_pos += slashN.length();
}

m_file << multiByte;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ private async Task CheckStdoutToFile(TestVariant variant, string path)
var contents = Helpers.ReadAllTextFromFile(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath), Logger);

Assert.Contains("TEST MESSAGE", contents);
Assert.DoesNotContain("\r\n\r\n", contents);
Assert.Contains("\r\n", contents);
Copy link
Member

Choose a reason for hiding this comment

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

Thanks

}

// Move to separate file
Expand Down