fix testing for pseudo client-server model
This commit is contained in:
parent
627e6b3672
commit
d8986351ed
4 changed files with 25 additions and 22 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
|
@ -332,12 +332,6 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "colors-transform"
|
|
||||||
version = "0.2.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9226dbc05df4fb986f48d730b001532580883c4c06c5d1c213f4b34c1c157178"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "concurrent-queue"
|
name = "concurrent-queue"
|
||||||
version = "1.2.2"
|
version = "1.2.2"
|
||||||
|
|
@ -360,12 +354,6 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "const_fn"
|
|
||||||
version = "0.4.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpuid-bool"
|
name = "cpuid-bool"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
|
|
@ -1568,6 +1556,16 @@ version = "1.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "socket2"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stable_deref_trait"
|
name = "stable_deref_trait"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
|
|
@ -2331,7 +2329,6 @@ dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bincode",
|
"bincode",
|
||||||
"colors-transform",
|
|
||||||
"directories-next",
|
"directories-next",
|
||||||
"futures",
|
"futures",
|
||||||
"insta",
|
"insta",
|
||||||
|
|
@ -2355,8 +2352,6 @@ dependencies = [
|
||||||
"vte 0.8.0",
|
"vte 0.8.0",
|
||||||
"wasmer",
|
"wasmer",
|
||||||
"wasmer-wasi",
|
"wasmer-wasi",
|
||||||
"zellij-tile",
|
|
||||||
"zellij-tile-extra",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -228,10 +228,11 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs, config: Config) {
|
||||||
let mut send_app_instructions =
|
let mut send_app_instructions =
|
||||||
SenderWithContext::new(err_ctx, SenderType::SyncSender(send_app_instructions));
|
SenderWithContext::new(err_ctx, SenderType::SyncSender(send_app_instructions));
|
||||||
|
|
||||||
let ipc_thread = start_server(os_input.clone(), opts.clone());
|
let (ipc_thread, server_name) = start_server(os_input.clone(), opts.clone());
|
||||||
|
|
||||||
let (client_buffer_path, client_buffer) = SharedRingBuffer::create_temp(8192).unwrap();
|
let (client_buffer_path, client_buffer) = SharedRingBuffer::create_temp(8192).unwrap();
|
||||||
let mut send_server_instructions = IpcSenderWithContext::to_server();
|
let mut send_server_instructions =
|
||||||
|
IpcSenderWithContext::new(SharedRingBuffer::open(&server_name).unwrap());
|
||||||
send_server_instructions
|
send_server_instructions
|
||||||
.send(ServerInstruction::NewClient(client_buffer_path))
|
.send(ServerInstruction::NewClient(client_buffer_path))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use std::path::PathBuf;
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::thread;
|
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> =
|
let (send_pty_instructions, receive_pty_instructions): ChannelWithContext<PtyInstruction> =
|
||||||
channel();
|
channel();
|
||||||
let mut send_pty_instructions = SenderWithContext::new(
|
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),
|
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 (send_os_instructions, receive_os_instructions): ChannelWithContext<OsApiInstruction> = channel();
|
||||||
let mut send_os_instructions = SenderWithContext::new(
|
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();
|
.unwrap();
|
||||||
|
|
||||||
thread::Builder::new()
|
let join_handle = thread::Builder::new()
|
||||||
.name("ipc_server".to_string())
|
.name("ipc_server".to_string())
|
||||||
.spawn({
|
.spawn({
|
||||||
let recv_server_instructions = IpcReceiver::new(server_buffer);
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ use zellij_tile::data::Palette;
|
||||||
|
|
||||||
use crate::tests::utils::commands::{QUIT, SLEEP};
|
use crate::tests::utils::commands::{QUIT, SLEEP};
|
||||||
|
|
||||||
const MIN_TIME_BETWEEN_SNAPSHOTS: Duration = Duration::from_millis(50);
|
const MIN_TIME_BETWEEN_SNAPSHOTS: Duration = Duration::from_millis(300);
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum IoEvent {
|
pub enum IoEvent {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue