From 8ce9f444c0cf633359956e2bac616eeaab120952 Mon Sep 17 00:00:00 2001 From: prushton2 Date: Sat, 30 Dec 2023 12:44:30 -0500 Subject: [PATCH 1/2] init branch --- src/commands.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/commands.rs b/src/commands.rs index 663f757..71381f9 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -63,6 +63,9 @@ scb init initializes the build tool by creating the file scb. Add this to your gitignore +remove + removes the scb file + file Manages files the build tool should keep track of Arguments From 183f3b2432e5f6108e212d51f3505238aeb1824b Mon Sep 17 00:00:00 2001 From: prushton2 Date: Sun, 31 Dec 2023 09:51:10 -0500 Subject: [PATCH 2/2] Added a test for build --- src/tests.rs | 49 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index 137aa3b..54aa95b 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -21,25 +21,40 @@ mod tests { } - //the only array config option is files, so no need for a loop here + //the only array config option is files //just append, check, remove, check #[test] #[serial] fn test_arr_config() { commands::init(); - let files: &[String; 2] = &[String::from("file1"), String::from("file2")]; + let test_keys: [&str; 1] = ["files"]; + let test_array: &[String; 3] = &[String::from("file1"), String::from("file2"), String::from("string!")]; - commands::arr_config("files", "-a", files); - let mut config: file::Config = file::load_config(commands::FILE_NAME).unwrap(); + for i in test_keys { - assert_eq!(config.files[0], files[0]); - assert_eq!(config.files[1], files[1]); - - commands::arr_config("files", "-r", files); - config = file::load_config(commands::FILE_NAME).unwrap(); + commands::arr_config(i, "-a", test_array); + let mut config: file::Config = file::load_config(commands::FILE_NAME).unwrap(); + + match i { + "files" => { + assert_eq!(config.files[0], test_array[0]); + assert_eq!(config.files[1], test_array[1]); + assert_eq!(config.files[2], test_array[2]); + }, + &_ => {} + } - assert_eq!(config.files.len(), 0); + commands::arr_config(i, "-r", test_array); + config = file::load_config(commands::FILE_NAME).unwrap(); + + match i { + "files" => { + assert_eq!(config.files.len(), 0); + }, + &_ => {} + } + } commands::remove(); } @@ -73,4 +88,18 @@ mod tests { commands::remove(); } + + #[test] + #[serial] + fn test_build() { + + commands::init(); + commands::arr_config("files", "-a", &[String::from("main.c")]); + + let result = commands::build(""); + assert!(result.is_ok()); + + commands::remove(); + + } } \ No newline at end of file