tmux-workspace 0.1.0-alpha.12 · Source
This example builds a workspace on libtmux’s isolated test server, captures its structure, and shuts the server down. It follows the crate’s README examples, which are included in the crate’s documentation tests.
Build and freezeLink to section
Use tmux-workspace, a matching libtmux with its test-support feature,
and Tokio with macros and rt-multi-thread. The test-support feature exposes
TestServer; tmux must be available on the host.
use libtmux::test::TestServer;use tmux_workspace::{freeze, Workspace, WorkspaceBuilder};
#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> { let workspace = Workspace::from_yaml( "session_name: devwindows: - window_name: editor panes: [/bin/sh, /bin/sh]", )?; let guard = TestServer::new().await?; let session = WorkspaceBuilder::new(guard.server()) .build(&workspace) .await?; assert_eq!(session.windows().await?.len(), 1);
let captured = freeze(&session).await?; assert_eq!(Workspace::from_yaml(&captured.to_yaml())?, captured); guard.shutdown().await?; Ok(())}The round trip checks serialization of the captured workspace. It does not assert that freezing reproduced the commands in the original YAML.
VerificationLink to section
The crate includes its README with include_str!, so its Rust examples are
collected as documentation tests. In a prepared source checkout, run:
$ cargo test -p tmux-workspace --docThis page combines the README’s build and freeze calls. Run the page example when changing its sequence as well as the upstream documentation tests.