diff options
| author | mo8it <mo8it@proton.me> | 2024-03-30 20:48:30 +0100 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-03-30 20:48:30 +0100 |
| commit | 79ca821e26711123c959e919eed2a630fa102cd5 (patch) | |
| tree | bc23b0dbf2e333ac8b2d2b6e8df262d0125c9a70 /src/main.rs | |
| parent | fe7d775818021acee7d5ae40c5cf9fdac69b2122 (diff) | |
Fix tests
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 76b6373..2ac44d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use notify_debouncer_mini::notify::{self, RecursiveMode}; use notify_debouncer_mini::{new_debouncer, DebouncedEventKind}; use shlex::Shlex; use std::ffi::OsStr; +use std::fs; use std::io::{self, prelude::*}; use std::path::Path; use std::process::{exit, Command}; @@ -100,9 +101,14 @@ fn main() -> Result<()> { std::process::exit(1); } - let exercises = toml_edit::de::from_str::<ExerciseList>(EMBEDDED_FILES.info_toml_content) - .unwrap() - .exercises; + // Read a local `info.toml` if it exists. Mainly to let the tests work for now. + let exercises = if let Ok(file_content) = fs::read_to_string("info.toml") { + toml_edit::de::from_str::<ExerciseList>(&file_content) + } else { + toml_edit::de::from_str::<ExerciseList>(EMBEDDED_FILES.info_toml_content) + } + .context("Failed to parse `info.toml`")? + .exercises; if matches!(args.command, Some(Subcommands::Init)) { init::init_rustlings(&exercises).context("Initialization failed")?; |
