#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct File {
pub name: &'static str,
pub contents: &'static str,
}
include!(concat!(env!("OUT_DIR"), "/bundled.rs"));
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn everything_in_the_repo_is_embedded_byte_for_byte() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
for kind in ALL {
let mut on_disk: Vec<String> = std::fs::read_dir(root.join(kind.dir()))
.unwrap()
.map(|e| e.unwrap().path())
.filter(|p| p.extension().is_some_and(|x| x == "toml"))
.map(|p| p.file_name().unwrap().to_string_lossy().into_owned())
.collect();
on_disk.sort();
let names: Vec<String> = kind.files().iter().map(|f| f.name.to_string()).collect();
assert_eq!(
names,
on_disk,
"{}: the binary and the repo disagree about what omh ships",
kind.dir()
);
for file in kind.files() {
let disk = std::fs::read_to_string(root.join(kind.dir()).join(file.name)).unwrap();
assert_eq!(
file.contents,
disk,
"{}/{} was embedded stale",
kind.dir(),
file.name
);
}
}
}
#[test]
fn no_shipped_directory_is_empty() {
for kind in ALL {
assert!(!kind.files().is_empty(), "{} embedded as empty", kind.dir());
}
}
#[test]
fn the_adapters_omh_launches_are_among_them() {
let names: Vec<&str> = Shipped::Adapters.files().iter().map(|f| f.name).collect();
assert!(names.contains(&"claude.toml"), "got: {names:?}");
assert!(names.contains(&"opencode.toml"), "got: {names:?}");
}
#[test]
fn every_shipped_file_is_a_toml() {
for kind in ALL {
for file in kind.files() {
assert!(file.name.ends_with(".toml"), "{}/{}", kind.dir(), file.name);
}
}
}
}