mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-13 13:43:50 +00:00
test(cli): resolve executable from nextest environment
This commit is contained in:
1 parent
b8c19475d2
commit
1d584737b1
6 files changed
+15
-9
No files matched your search
@@ -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:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user