install_executable
Write script to path as an executable, and return once it can run.
Source and package
- Qualified name
-
test.install _executable - Module
- test
- Package
- libtmux
- Source
- crates/libtmux/src/test.rs
-
Description#
A test that points
TestServerBuilder::tmux_executableat a wrapper script races every other test in its binary. A process forked while the script is open for writing keeps that descriptor until it callsexec, and until then running the script fails withETXTBSY: intermittently, and only under parallel tests. This stages the script besidepath, moves it into place, and runs it until anexecsucceeds.scriptmust start with a#!line. The line inserted after it exits 0 whenLIBTMUX_EXECUTABLE_READYis set, so the readiness run does none of the script's work.Errors
Returns
std::io::ErrorKind::InvalidInputfor a script without a#!line,std::io::ErrorKind::TimedOutwhen it still cannot run after ascaledfive seconds, and any error writing it or running it.Examples#
use libtmux::test::{install_executable, unique_name};let directory = std::env::temp_dir().join(unique_name("install"));std::fs::create_dir(&directory)?;let greet = directory.join("greet");install_executable(&greet, "#!/bin/sh\nprintf 'hello %s' \"$1\"\n")?;let output = std::process::Command::new(&greet).arg("tmux").output()?;assert_eq!(output.stdout, b"hello tmux");