Core LibraryalphaAPI Reference

Choose documentation 3

latest

Current version

latest
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

function libtmux-rs latest

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
pub fn install_executable( path: &Path, script: &str ) -> std::io::Result<()>

Description#

A test that points TestServerBuilder::tmux_executable at 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 calls exec, and until then running the script fails with ETXTBSY: intermittently, and only under parallel tests. This stages the script beside path , moves it into place, and runs it until an exec succeeds.

script must start with a #! line. The line inserted after it exits 0 when LIBTMUX_EXECUTABLE_READY is set, so the readiness run does none of the script's work.

Errors

Returns std::io::ErrorKind::InvalidInput for a script without a #! line, std::io::ErrorKind::TimedOut when it still cannot run after a scaled five 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");
Parameters
Esc

Type to search.

Reference preview Open reference