un-hard-code the tests #14

Merged
able merged 2 commits from wildwestrom/ableos:master into master 2024-05-31 10:44:43 -05:00
Showing only changes of commit b0358efab8 - Show all commits

View file

@ -12,6 +12,7 @@ use {
path::Path, path::Path,
process::{exit, Command}, process::{exit, Command},
}, },
toml::Value,
}; };
fn main() -> Result<(), Error> { fn main() -> Result<(), Error> {
@ -124,6 +125,10 @@ fn assemble() -> Result<(), Error> {
Ok(()) Ok(())
} }
fn get_path_without_boot_prefix(val: &Value) -> Option<&str> {
val.as_str()?.split("boot:///").last()
}
fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> { fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
let filename = "sysdata/system_config.toml"; let filename = "sysdata/system_config.toml";
@ -192,12 +197,7 @@ TERM_BACKDROP={}
); );
// Copy the term_wallpaper to the image // Copy the term_wallpaper to the image
let term_wallpaper_path = term_wallpaper let term_wallpaper_path = get_path_without_boot_prefix(term_wallpaper).unwrap();
.as_str()
.unwrap()
.split("boot:///")
.last()
.unwrap();
copy_file_to_img(&format!("sysdata/{}", term_wallpaper_path), &fs); copy_file_to_img(&format!("sysdata/{}", term_wallpaper_path), &fs);
limine_str.push_str(&base); limine_str.push_str(&base);
@ -242,13 +242,9 @@ TERM_BACKDROP={}
modules.into_iter().for_each(|(key, value)| { modules.into_iter().for_each(|(key, value)| {
if value.is_table() && key == "tests" { if value.is_table() && key == "tests" {
let path = value let path = get_path_without_boot_prefix(
.get("path") value.get("path").expect("You must have `path` as a value"),
.expect("You must have `path` as a value") )
.as_str()
.unwrap()
.split("boot:///")
.last()
.unwrap() .unwrap()
.split(".") .split(".")
.next() .next()
@ -278,13 +274,11 @@ TERM_BACKDROP={}
// Copy modules into the test_programs directory // Copy modules into the test_programs directory
modules.into_iter().for_each(|(_key, value)| { modules.into_iter().for_each(|(_key, value)| {
if value.is_table() { if value.is_table() {
let path = value let path = get_path_without_boot_prefix(
value
.get("path") .get("path")
.expect("You must have a `path` as a value") .expect("You must have a `path` as a value"),
.as_str() )
.unwrap()
.split("boot:///")
.last()
.unwrap(); .unwrap();
let fpath = format!("target/test-programs/{}", path); let fpath = format!("target/test-programs/{}", path);
copy_file_to_img(&fpath, &fs); copy_file_to_img(&fpath, &fs);