Skip to content
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

Fix PrintThread: Read stderr as bytes instead of str #842

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3828,14 +3828,20 @@ impl PrintThread {
// location to another.
let print = thread::spawn(move || {
let mut stderr = BufReader::with_capacity(4096, pipe_reader);
let mut line = String::with_capacity(20);
let mut stdout = io::stdout();
let mut line = Vec::with_capacity(20);
let stdout = io::stdout();

// read_line returns 0 on Eof
while stderr.read_line(&mut line).unwrap() != 0 {
writeln!(&mut stdout, "cargo:warning={}", line).ok();
// read_until returns 0 on Eof
while stderr.read_until(b'\n', &mut line).unwrap() != 0 {
{
let mut stdout = stdout.lock();

stdout.write_all(b"cargo:warning=").unwrap();
stdout.write_all(&line).unwrap();
stdout.write_all(b"\n").unwrap();
}

// read_line does not clear the buffer
// read_until does not clear the buffer
line.clear();
}
});
Expand Down