Remove test feature and hacks

This commit is contained in:
Kunal Mohan 2021-07-04 15:20:47 +05:30
parent 79c30e9d59
commit 82288c6a3d
10 changed files with 4 additions and 50 deletions

View file

@ -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 = [

View file

@ -16,5 +16,3 @@ zellij-utils = { path = "../zellij-utils/", version = "0.15.0" }
[dev-dependencies]
insta = "1.6.0"
[features]
test = ["zellij-utils/test"]

View file

@ -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();
@ -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);
@ -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();

View file

@ -23,5 +23,3 @@ zellij-utils = { path = "../zellij-utils/", version = "0.15.0" }
[dev-dependencies]
insta = "1.6.0"
[features]
test = ["zellij-utils/test"]

View file

@ -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)
@ -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();
@ -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({
@ -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));
}

View file

@ -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
)));
}
}

View file

@ -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()

View file

@ -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

View file

@ -36,5 +36,3 @@ features = ["unstable"]
[dev-dependencies]
tempfile = "3.2.0"
[features]
test = []

View file

@ -12,7 +12,6 @@ const CONFIG_LOCATION: &str = ".config/zellij";
const CONFIG_NAME: &str = "config.yaml";
static ARROW_SEPARATOR: &str = "";
#[cfg(not(any(feature = "test", 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> {
@ -23,11 +22,6 @@ pub fn find_default_config_dir() -> Option<PathBuf> {
.flatten()
}
#[cfg(any(feature = "test", test))]
pub fn find_default_config_dir() -> Option<PathBuf> {
None
}
/// Order in which config directories are checked
fn default_config_dirs() -> Vec<Option<PathBuf>> {
vec![