use common::binary;
use core::sync::atomic::{AtomicU64, Ordering};
use std::fs;
use std::path::{Path, PathBuf};
use std::process::{self, Command, Output};
mod command_behavior;
mod fences;
mod links;
mod literal_safety;
mod tables;
#[path = "../common/mod.rs"]
mod common;
static TEST_COUNTER: AtomicU64 = AtomicU64::new(0);
fn fixture_dir() -> PathBuf {
manifest_dir().join("tests").join("fixtures").join("fix")
}
fn run_command(args: &[&str], path: &Path) -> Output {
let directory = tempfile::tempdir().unwrap();
let config = directory.path().join(".rust-llm-tidy.yml");
fs::write(&config, "{}\n").unwrap();
let mut cmd = Command::new(binary());
cmd.arg("--config").arg(config).args(args).arg(path);
cmd.output()
.unwrap_or_else(|e| panic!("failed to spawn rust-llm-tidy on {}: {e}", path.display()))
}
fn temp_dir() -> PathBuf {
let seq = TEST_COUNTER.fetch_add(1, Ordering::Relaxed);
let pid = process::id();
std::env::temp_dir().join(format!("rust-llm-tidy-fix-dir-{}-{}", pid, seq))
}
fn temp_file(ext: &str) -> PathBuf {
let seq = TEST_COUNTER.fetch_add(1, Ordering::Relaxed);
let pid = process::id();
std::env::temp_dir().join(format!("rust-llm-tidy-fix-{}-{}.{}", pid, seq, ext))
}
fn manifest_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
}