pub fn python_cmd() -> &'static str {
par_term::scripting::manager::python_interpreter()
.expect("these tests require a Python interpreter (python3/python/py) on PATH")
}
pub const SCRIPT_OUTPUT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
const POLL_INTERVAL: std::time::Duration = std::time::Duration::from_millis(25);
pub fn drain_until<T>(mut read: impl FnMut() -> Vec<T>, enough: impl Fn(&[T]) -> bool) -> Vec<T> {
let deadline = std::time::Instant::now() + SCRIPT_OUTPUT_TIMEOUT;
let mut collected = Vec::new();
loop {
collected.extend(read());
if enough(&collected) || std::time::Instant::now() >= deadline {
return collected;
}
std::thread::sleep(POLL_INTERVAL);
}
}
pub fn wait_until(mut cond: impl FnMut() -> bool) -> bool {
let deadline = std::time::Instant::now() + SCRIPT_OUTPUT_TIMEOUT;
loop {
if cond() {
return true;
}
if std::time::Instant::now() >= deadline {
return false;
}
std::thread::sleep(POLL_INTERVAL);
}
}
mod script_auto_start_tests;
mod script_command_dispatch_tests;
mod script_integration_tests;
mod script_manager_tests;
mod script_observer_tests;
mod script_process_tests;
mod script_protocol_tests;
mod scripting_config_tests;