use types::*;
use std::fs::read_to_string;
mod types;
fn get_build_config(filename: &str) -> BuildConfig {
let content =
read_to_string(filename).unwrap_or_else(|_| panic!("Failed to read file: {filename}"));
serde_yaml::from_str(&content).unwrap_or_else(|_| panic!("Failed to parse file: {filename}"))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_yaml_file_parsed_correctly() {
let config = get_build_config("examples/ex1.yaml");
assert_eq!(config.len(), 1);
assert_eq!(config[0].name, "main.c");
assert_eq!(config[0].out, "main");
assert_eq!(config[0].uses.len(), 1);
assert_eq!(config[0].uses[0], "aux.c");
assert_eq!(config[0].headers.len(), 1);
assert_eq!(config[0].headers[0], "include/aux.h");
assert_eq!(config[0].includes.len(), 1);
assert_eq!(config[0].includes[0], "include");
}
}