Fix the tests, by not requiring stderr for fake servers

This commit is contained in:
Kirill Bulatov 2023-08-31 11:07:37 +03:00
parent 0f619e0b67
commit 18efc0d5e5

View File

@ -162,7 +162,7 @@ impl LanguageServer {
server_id.clone(), server_id.clone(),
stdin, stdin,
stdout, stdout,
stderr, Some(stderr),
Some(server), Some(server),
root_path, root_path,
code_action_kinds, code_action_kinds,
@ -194,7 +194,7 @@ impl LanguageServer {
server_id: LanguageServerId, server_id: LanguageServerId,
stdin: Stdin, stdin: Stdin,
stdout: Stdout, stdout: Stdout,
stderr: Stderr, stderr: Option<Stderr>,
server: Option<Child>, server: Option<Child>,
root_path: &Path, root_path: &Path,
code_action_kinds: Option<Vec<CodeActionKind>>, code_action_kinds: Option<Vec<CodeActionKind>>,
@ -228,8 +228,9 @@ impl LanguageServer {
} }
.log_err() .log_err()
}); });
let stderr_input_task = let stderr_input_task = stderr
cx.spawn(|_| Self::handle_stderr(stderr, io_handlers.clone()).log_err()); .map(|stderr| cx.spawn(|_| Self::handle_stderr(stderr, io_handlers.clone()).log_err()))
.unwrap_or_else(|| Task::Ready(Some(None)));
let input_task = cx.spawn(|_| async move { let input_task = cx.spawn(|_| async move {
let (stdout, stderr) = futures::join!(stdout_input_task, stderr_input_task); let (stdout, stderr) = futures::join!(stdout_input_task, stderr_input_task);
stdout.or(stderr) stdout.or(stderr)
@ -889,16 +890,13 @@ impl LanguageServer {
) -> (Self, FakeLanguageServer) { ) -> (Self, FakeLanguageServer) {
let (stdin_writer, stdin_reader) = async_pipe::pipe(); let (stdin_writer, stdin_reader) = async_pipe::pipe();
let (stdout_writer, stdout_reader) = async_pipe::pipe(); let (stdout_writer, stdout_reader) = async_pipe::pipe();
// writers will be dropped after we exit, so readers will also be noop for the fake servers
let (_stderr_writer, stderr_reader) = async_pipe::pipe();
let (_stderr_writer_2, stderr_reader_2) = async_pipe::pipe();
let (notifications_tx, notifications_rx) = channel::unbounded(); let (notifications_tx, notifications_rx) = channel::unbounded();
let server = Self::new_internal( let server = Self::new_internal(
LanguageServerId(0), LanguageServerId(0),
stdin_writer, stdin_writer,
stdout_reader, stdout_reader,
stderr_reader, None::<async_pipe::PipeReader>,
None, None,
Path::new("/"), Path::new("/"),
None, None,
@ -910,7 +908,7 @@ impl LanguageServer {
LanguageServerId(0), LanguageServerId(0),
stdout_writer, stdout_writer,
stdin_reader, stdin_reader,
stderr_reader_2, None::<async_pipe::PipeReader>,
None, None,
Path::new("/"), Path::new("/"),
None, None,