1use types::*;
2
3use std::fs::read_to_string;
4
5mod types;
6
7fn get_build_config(filename: &str) -> BuildConfig {
25 let content =
26 read_to_string(filename).unwrap_or_else(|_| panic!("Failed to read file: {filename}"));
27
28 serde_yaml::from_str(&content).unwrap_or_else(|_| panic!("Failed to parse file: {filename}"))
29}
30
31#[cfg(test)]
32mod tests {
33 use super::*;
34
35 #[test]
36 fn test_yaml_file_parsed_correctly() {
37 let config = get_build_config("examples/ex1.yaml");
38
39 assert_eq!(config.len(), 1);
40 assert_eq!(config[0].name, "main.c");
41 assert_eq!(config[0].out, "main");
42 assert_eq!(config[0].uses.len(), 1);
43 assert_eq!(config[0].uses[0], "aux.c");
44 assert_eq!(config[0].headers.len(), 1);
45 assert_eq!(config[0].headers[0], "include/aux.h");
46 assert_eq!(config[0].includes.len(), 1);
47 assert_eq!(config[0].includes[0], "include");
48 }
49}