From 4bd8e2a25e5c1d64d9e8cd292fb8f3dfc4df4b73 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 06:08:50 +0000 Subject: [PATCH] test(cli): resolve executable from nextest environment --- apps/deckcraft-cli/tests/it/cli.rs | 4 ++-- apps/deckcraft-cli/tests/it/closed_stdout.rs | 4 ++-- apps/deckcraft-cli/tests/it/convert.rs | 6 +++--- apps/deckcraft-cli/tests/it/damaged.rs | 2 +- apps/deckcraft-cli/tests/it/main.rs | 6 ++++++ apps/deckcraft-cli/tests/it/mcp_roots.rs | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/deckcraft-cli/tests/it/cli.rs b/apps/deckcraft-cli/tests/it/cli.rs index a6ec02485..fd9c27ed7 100644 --- a/apps/deckcraft-cli/tests/it/cli.rs +++ b/apps/deckcraft-cli/tests/it/cli.rs @@ -1,7 +1,7 @@ use std::process::{Command, Output}; fn cli(args: &[&str]) -> Output { - Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).args(args).output().unwrap() + Command::new(crate::deckcraft_cli()).args(args).output().unwrap() } fn stdout(o: &Output) -> String { @@ -197,7 +197,7 @@ fn every_subcommand_answers_help_and_does_nothing_else() { std::fs::create_dir_all(&dir).unwrap(); for sub in SUBCOMMANDS { for args in [vec![sub, "--help"], vec![sub, "-h", "out.png"], vec!["help", sub]] { - let o = Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).current_dir(&dir).args(&args).output().unwrap(); + let o = Command::new(crate::deckcraft_cli()).current_dir(&dir).args(&args).output().unwrap(); assert!(stdout(&o).starts_with(&format!("usage: deckcraft-cli {sub}")), "{args:?}"); } } diff --git a/apps/deckcraft-cli/tests/it/closed_stdout.rs b/apps/deckcraft-cli/tests/it/closed_stdout.rs index aeb20dba6..c24fc91d3 100644 --- a/apps/deckcraft-cli/tests/it/closed_stdout.rs +++ b/apps/deckcraft-cli/tests/it/closed_stdout.rs @@ -29,7 +29,7 @@ fn closed_stdout() -> Stdio { } fn run(dir: &Path, args: &[&str], stdout: Stdio) -> Output { - Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).current_dir(dir).args(args).stdout(stdout).stderr(Stdio::piped()).output().unwrap() + Command::new(crate::deckcraft_cli()).current_dir(dir).args(args).stdout(stdout).stderr(Stdio::piped()).output().unwrap() } #[test] @@ -52,7 +52,7 @@ fn broken_pipe_does_not_skip_later_commands_or_save() { assert!(out.status.success(), "exit {:?}: {}", out.status, String::from_utf8_lossy(&out.stderr)); let saved = dir.0.join("out.deckcraft"); assert!(saved.is_file(), "requested save was skipped"); - let info = Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).arg("info").arg(saved).output().unwrap(); + let info = Command::new(crate::deckcraft_cli()).arg("info").arg(saved).output().unwrap(); assert!(info.status.success(), "{}", String::from_utf8_lossy(&info.stderr)); let data: serde_json::Value = serde_json::from_slice(&info.stdout).unwrap(); let slides = data["slides"].as_array().unwrap(); diff --git a/apps/deckcraft-cli/tests/it/convert.rs b/apps/deckcraft-cli/tests/it/convert.rs index 4f1629946..33058f603 100644 --- a/apps/deckcraft-cli/tests/it/convert.rs +++ b/apps/deckcraft-cli/tests/it/convert.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Output}; fn cli(args: &[&Path]) -> Output { - Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).args(args).output().unwrap() + Command::new(crate::deckcraft_cli()).args(args).output().unwrap() } fn temp_dir(name: &str) -> PathBuf { @@ -18,7 +18,7 @@ fn temp_dir(name: &str) -> PathBuf { fn convert_rejects_output_formats_it_cannot_write() { let dir = temp_dir("convert-unsupported"); let input = dir.join("in.pptx"); - let out = Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).args(["run", "--sample", "--export"]).arg(&input).output().unwrap(); + let out = Command::new(crate::deckcraft_cli()).args(["run", "--sample", "--export"]).arg(&input).output().unwrap(); assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr)); for name in ["out.odp", "out.bmp", "out.svg", "out.outline", "out"] { @@ -48,7 +48,7 @@ fn run_rejects_unsupported_save_and_export_paths_before_running() { let dir = temp_dir("run-unsupported"); for flag in ["--save", "--export"] { let target = dir.join("deck.odp"); - let out = Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).args(["run", "--sample", flag]).arg(&target).output().unwrap(); + let out = Command::new(crate::deckcraft_cli()).args(["run", "--sample", flag]).arg(&target).output().unwrap(); assert!(!out.status.success(), "{flag}: run should fail"); assert!(String::from_utf8_lossy(&out.stderr).contains("unsupported output format .odp"), "{flag}"); assert!(!target.exists(), "{flag}: nothing is written"); diff --git a/apps/deckcraft-cli/tests/it/damaged.rs b/apps/deckcraft-cli/tests/it/damaged.rs index de85a66bf..1a4e3c383 100644 --- a/apps/deckcraft-cli/tests/it/damaged.rs +++ b/apps/deckcraft-cli/tests/it/damaged.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use std::process::{Command, Output}; fn cli(args: &[&str]) -> Output { - Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")).args(args).output().unwrap() + Command::new(crate::deckcraft_cli()).args(args).output().unwrap() } fn temp_dir(name: &str) -> PathBuf { diff --git a/apps/deckcraft-cli/tests/it/main.rs b/apps/deckcraft-cli/tests/it/main.rs index f1e1c0893..68aaf8900 100644 --- a/apps/deckcraft-cli/tests/it/main.rs +++ b/apps/deckcraft-cli/tests/it/main.rs @@ -1,3 +1,5 @@ +use std::ffi::OsString; + mod cli; #[cfg(unix)] mod closed_stdout; @@ -6,3 +8,7 @@ mod damaged; // Integration tests: unwrapping and panicking on failure is fine here, unlike in shipped code (AGENTS.md). #[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] mod mcp_roots; + +fn deckcraft_cli() -> OsString { + std::env::var_os("NEXTEST_BIN_EXE_deckcraft_cli").unwrap_or_else(|| env!("CARGO_BIN_EXE_deckcraft-cli").into()) +} diff --git a/apps/deckcraft-cli/tests/it/mcp_roots.rs b/apps/deckcraft-cli/tests/it/mcp_roots.rs index c80f8fe3f..938b06d67 100644 --- a/apps/deckcraft-cli/tests/it/mcp_roots.rs +++ b/apps/deckcraft-cli/tests/it/mcp_roots.rs @@ -7,7 +7,7 @@ use std::process::{Command, Output, Stdio}; use serde_json::Value; fn bin() -> Command { - Command::new(env!("CARGO_BIN_EXE_deckcraft-cli")) + Command::new(crate::deckcraft_cli()) } fn run(args: &[&str]) -> Output {