summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-03-12 22:33:06 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-04-14 01:41:29 +0530
commit2df0585430e551b422145621bc52936f8a5230bc (patch)
treec11db8b6850eb90f668de1d579d950586b590928
parentf0b38f0d0e12da5b7c26823e1cc99b5cb7160d79 (diff)
fix testing for pseudo client-server model
-rw-r--r--Cargo.lock17
-rw-r--r--build.rs26
-rw-r--r--src/common/mod.rs5
-rw-r--r--src/server/mod.rs15
-rw-r--r--src/tests/fakes.rs2
5 files changed, 52 insertions, 13 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 007a48459..e78a8fd1f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -355,12 +355,6 @@ dependencies = [
]
[[package]]
-name = "const_fn"
-version = "0.4.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
-
-[[package]]
name = "cpuid-bool"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1573,6 +1567,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
+name = "socket2"
+version = "0.3.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
+dependencies = [
+ "cfg-if 1.0.0",
+ "libc",
+ "winapi",
+]
+
+[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/build.rs b/build.rs
index 3240db67e..59b56e6f7 100644
--- a/build.rs
+++ b/build.rs
@@ -20,4 +20,30 @@ fn main() {
clap_app.gen_completions(BIN_NAME, Shell::Bash, &out_dir);
clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir);
clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir);
+
+ // Clear Default Plugins and Layouts
+ for entry in WalkDir::new("assets/plugins") {
+ let entry = entry.unwrap();
+ println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy());
+ }
+
+ // Rerun on plugin change
+ #[cfg(not(feature = "publish"))]
+ let plugin_dir = "target";
+ #[cfg(feature = "publish")]
+ let plugin_dir = "assets/plugins";
+ for entry in WalkDir::new(plugin_dir) {
+ let entry = entry.unwrap();
+ if entry.path().extension() == Some(OsStr::new("wasm")) {
+ println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy());
+ }
+ }
+
+ let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
+ let data_dir = project_dirs.data_dir();
+ drop(fs::remove_file(data_dir.join("plugins/status-bar.wasm")));
+ drop(fs::remove_file(data_dir.join("plugins/tab-bar.wasm")));
+ drop(fs::remove_file(data_dir.join("plugins/strider.wasm")));
+ drop(fs::remove_file(data_dir.join("layouts/default.yaml")));
+ drop(fs::remove_file(data_dir.join("layouts/strider.yaml")));
}
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 0d08aaa9d..cc7bf8164 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -228,10 +228,11 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let mut 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 mut send_server_instructions = IpcSenderWithContext::to_server();
+ let mut send_server_instructions =
+ IpcSenderWithContext::new(SharedRingBuffer::open(&server_name).unwrap());
send_server_instructions
.send(ServerInstruction::NewClient(client_buffer_path))
.unwrap();
diff --git a/src/server/mod.rs b/src/server/mod.rs
index fef663663..794066b05 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)
}
diff --git a/src/tests/fakes.rs b/src/tests/fakes.rs
index c9504a984..69928f73e 100644
--- a/src/tests/fakes.rs
+++ b/src/tests/fakes.rs
@@ -11,7 +11,7 @@ use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes};
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)]
pub enum IoEvent {