aboutsummaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-03-12 22:33:06 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-04 20:47:50 +0530
commitd8986351ed1b5ab7c5b1e28b0b429d8a42eb5e50 (patch)
treef80c45db9271653fc519d56416f8b27ca4e809e1 /src/server
parentwip: working on osapi message variants (diff)
downloadsl0ppij-d8986351ed1b5ab7c5b1e28b0b429d8a42eb5e50.tar.gz
sl0ppij-d8986351ed1b5ab7c5b1e28b0b429d8a42eb5e50.tar.xz
sl0ppij-d8986351ed1b5ab7c5b1e28b0b429d8a42eb5e50.zip
fix testing for pseudo client-server model
Diffstat (limited to 'src/server')
-rw-r--r--src/server/mod.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/server/mod.rs b/src/server/mod.rs
index fef66366..794066b0 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -14,7 +14,7 @@ use std::path::PathBuf;
use std::sync::mpsc::channel;
use std::thread;
-pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> thread::JoinHandle<()> {
+pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> (thread::JoinHandle<()>, String) {
let (send_pty_instructions, receive_pty_instructions): ChannelWithContext<PtyInstruction> =
channel();
let mut send_pty_instructions = SenderWithContext::new(
@@ -22,7 +22,13 @@ pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> thread::JoinHand
SenderType::Sender(send_pty_instructions),
);
- let server_buffer = SharedRingBuffer::create(ZELLIJ_IPC_PIPE, 8192).unwrap();
+ #[cfg(not(test))]
+ let (server_name, server_buffer) = (
+ String::from(ZELLIJ_IPC_PIPE),
+ SharedRingBuffer::create(ZELLIJ_IPC_PIPE, 8192).unwrap(),
+ );
+ #[cfg(test)]
+ let (server_name, server_buffer) = SharedRingBuffer::create_temp(8192).unwrap();
let (send_os_instructions, receive_os_instructions): ChannelWithContext<OsApiInstruction> = channel();
let mut send_os_instructions = SenderWithContext::new(
@@ -114,7 +120,7 @@ pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> thread::JoinHand
})
.unwrap();
- thread::Builder::new()
+ let join_handle = thread::Builder::new()
.name("ipc_server".to_string())
.spawn({
let recv_server_instructions = IpcReceiver::new(server_buffer);
@@ -188,5 +194,6 @@ pub fn start_server(os_input: Box<dyn OsApi>, opts: CliArgs) -> thread::JoinHand
}
}
})
- .unwrap()
+ .unwrap();
+ (join_handle, server_name)
}