Skip to content

Commit

Permalink
Merge pull request #598 from zellij-org/rm-feat-test
Browse files Browse the repository at this point in the history
Remove test feature and hacks
  • Loading branch information
kunalmohan committed Jul 6, 2021
2 parents 79c30e9 + e294950 commit eb7f077
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 46 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ zellij-utils = { path = "zellij-utils/", version = "0.15.0" }
insta = { version = "1.6.0", features = ["backtrace"] }
ssh2 = "0.9.1"
rand = "0.8.0"
zellij-utils = { path = "zellij-utils/", version = "0.15.0", features = ["test"] }
zellij-client = { path = "zellij-client/", version = "0.15.0", features = ["test"] }
zellij-server = { path = "zellij-server/", version = "0.15.0", features = ["test"] }

[workspace]
members = [
Expand Down
2 changes: 0 additions & 2 deletions zellij-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ zellij-utils = { path = "../zellij-utils/", version = "0.15.0" }
[dev-dependencies]
insta = "1.6.0"

[features]
test = ["zellij-utils/test"]
12 changes: 0 additions & 12 deletions zellij-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pub fn start_client(
palette,
};

#[cfg(not(any(feature = "test", test)))]
let first_msg = match info {
ClientInfo::Attach(name, force, config_options) => {
SESSION_NAME.set(name).unwrap();
Expand All @@ -140,16 +139,6 @@ pub fn start_client(
)
}
};
#[cfg(any(feature = "test", test))]
let first_msg = {
let _ = SESSION_NAME.set("".into());
ClientToServerMsg::NewClient(
client_attributes,
Box::new(opts),
Box::new(config_options.clone()),
layout,
)
};

os_input.connect_to_server(&*ZELLIJ_IPC_PIPE);
os_input.send_to_server(first_msg);
Expand All @@ -167,7 +156,6 @@ pub fn start_client(
> = channels::bounded(50);
let send_client_instructions = SenderWithContext::new(send_client_instructions);

#[cfg(not(any(feature = "test", test)))]
std::panic::set_hook({
use zellij_utils::errors::handle_panic;
let send_client_instructions = send_client_instructions.clone();
Expand Down
2 changes: 0 additions & 2 deletions zellij-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ zellij-utils = { path = "../zellij-utils/", version = "0.15.0" }
[dev-dependencies]
insta = "1.6.0"

[features]
test = ["zellij-utils/test"]
18 changes: 0 additions & 18 deletions zellij-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub(crate) enum SessionState {
}

pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
#[cfg(not(any(feature = "test", test)))]
daemonize::Daemonize::new()
.working_directory(std::env::current_dir().unwrap())
.umask(0o077)
Expand All @@ -130,7 +129,6 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
let session_data: Arc<RwLock<Option<SessionMetaData>>> = Arc::new(RwLock::new(None));
let session_state = Arc::new(RwLock::new(SessionState::Uninitialized));

#[cfg(not(any(feature = "test", test)))]
std::panic::set_hook({
use zellij_utils::errors::handle_panic;
let to_server = to_server.clone();
Expand All @@ -141,21 +139,6 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {

let thread_handles = Arc::new(Mutex::new(Vec::new()));

#[cfg(any(feature = "test", test))]
thread_handles.lock().unwrap().push(
thread::Builder::new()
.name("server_router".to_string())
.spawn({
let session_data = session_data.clone();
let os_input = os_input.clone();
let to_server = to_server.clone();
let session_state = session_state.clone();

move || route_thread_main(session_data, session_state, os_input, to_server)
})
.unwrap(),
);
#[cfg(not(any(feature = "test", test)))]
let _ = thread::Builder::new()
.name("server_listener".to_string())
.spawn({
Expand Down Expand Up @@ -306,7 +289,6 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.unwrap()
.drain(..)
.for_each(|h| drop(h.join()));
#[cfg(not(any(feature = "test", test)))]
drop(std::fs::remove_file(&socket_path));
}

Expand Down
7 changes: 4 additions & 3 deletions zellij-server/src/panes/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1766,9 +1766,10 @@ impl Perform for Grid {
_ => {}
}
} else {
let result = debug_log_to_file(format!("Unhandled csi: {}->{:?}", c, params));
#[cfg(not(any(feature = "test", test)))]
result.unwrap();
drop(debug_log_to_file(format!(
"Unhandled csi: {}->{:?}",
c, params
)));
}
}

Expand Down
1 change: 0 additions & 1 deletion zellij-server/src/panes/terminal_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ impl TerminalPane {
pub fn read_buffer_as_lines(&self) -> Vec<Vec<TerminalCharacter>> {
self.grid.as_character_lines()
}
#[cfg(any(feature = "test", test))]
pub fn cursor_coordinates(&self) -> Option<(usize, usize)> {
// (x, y)
self.grid.cursor_coordinates()
Expand Down
1 change: 0 additions & 1 deletion zellij-server/src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ fn stream_terminal_bytes(
}
async_send_to_screen(senders.clone(), ScreenInstruction::Render).await;

#[cfg(not(any(feature = "test", test)))]
// this is a little hacky, and is because the tests end the file as soon as
// we read everything, rather than hanging until there is new data
// a better solution would be to fix the test fakes, but this will do for now
Expand Down
2 changes: 0 additions & 2 deletions zellij-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ features = ["unstable"]
[dev-dependencies]
tempfile = "3.2.0"

[features]
test = []
4 changes: 2 additions & 2 deletions zellij-utils/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const CONFIG_LOCATION: &str = ".config/zellij";
const CONFIG_NAME: &str = "config.yaml";
static ARROW_SEPARATOR: &str = "";

#[cfg(not(any(feature = "test", test)))]
#[cfg(not(test))]
/// Goes through a predefined list and checks for an already
/// existing config directory, returns the first match
pub fn find_default_config_dir() -> Option<PathBuf> {
Expand All @@ -23,7 +23,7 @@ pub fn find_default_config_dir() -> Option<PathBuf> {
.flatten()
}

#[cfg(any(feature = "test", test))]
#[cfg(test)]
pub fn find_default_config_dir() -> Option<PathBuf> {
None
}
Expand Down

0 comments on commit eb7f077

Please sign in to comment.