Core Library0.xAPI reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

MoreLess about this notice

function libtmux-rs

install_executable

Write script to path as an executable, and return once it can run.

Source and package
Qualified name
libtmux::test::install_executable
Module
test
Package
libtmux
Source
crates/libtmux/src/test.rs
pub fn install_executable( path: &Path, script: &str ) -> std::io::Result<()>
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.doc comment · test.rs:1086

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.

Parameters

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");

Recorded calls

source calls
No call edges in the Rust model.

The Rust reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls test.install_executable.

Esc
Search in

Type to search.

Reference previewOpen reference