#![allow(dead_code)]
use assert_cmd::Command;
use std::env;
use std::path::{Path, PathBuf};
use std::sync::OnceLock;
static PERFGATE_BIN: OnceLock<std::path::PathBuf> = OnceLock::new();
pub fn perfgate_cmd() -> Command {
let bin_path =
PERFGATE_BIN.get_or_init(|| assert_cmd::cargo::cargo_bin!("perfgate").to_path_buf());
let mut cmd = Command::new(bin_path);
if let Ok(profile) = env::var("LLVM_PROFILE_FILE") {
cmd.env("LLVM_PROFILE_FILE", profile);
}
cmd
}
pub fn fixtures_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("fixtures")
}
pub fn generate_compare_receipt(
baseline: &Path,
current: &Path,
output_path: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = perfgate_cmd();
cmd.arg("compare")
.arg("--baseline")
.arg(baseline)
.arg("--current")
.arg(current)
.arg("--out")
.arg(output_path);
let _ = cmd.output();
Ok(())
}