mirror of
https://github.com/notohh/rustlings.git
synced 2024-10-30 08:49:12 -04:00
Fix tests
This commit is contained in:
parent
fe7d775818
commit
79ca821e26
14 changed files with 21 additions and 16 deletions
|
@ -354,7 +354,7 @@ mod test {
|
|||
File::create(temp_file()).unwrap();
|
||||
let exercise = Exercise {
|
||||
name: String::from("example"),
|
||||
path: PathBuf::from("tests/fixture/state/pending_exercise.rs"),
|
||||
path: PathBuf::from("tests/fixture/state/exercises/pending_exercise.rs"),
|
||||
mode: Mode::Compile,
|
||||
hint: String::from(""),
|
||||
};
|
||||
|
@ -372,7 +372,7 @@ mod test {
|
|||
let exercise = Exercise {
|
||||
name: String::from("example"),
|
||||
// We want a file that does actually compile
|
||||
path: PathBuf::from("tests/fixture/state/pending_exercise.rs"),
|
||||
path: PathBuf::from("tests/fixture/state/exercises/pending_exercise.rs"),
|
||||
mode: *mode,
|
||||
hint: String::from(""),
|
||||
};
|
||||
|
@ -385,7 +385,7 @@ mod test {
|
|||
fn test_pending_state() {
|
||||
let exercise = Exercise {
|
||||
name: "pending_exercise".into(),
|
||||
path: PathBuf::from("tests/fixture/state/pending_exercise.rs"),
|
||||
path: PathBuf::from("tests/fixture/state/exercises/pending_exercise.rs"),
|
||||
mode: Mode::Compile,
|
||||
hint: String::new(),
|
||||
};
|
||||
|
@ -426,7 +426,7 @@ mod test {
|
|||
fn test_finished_exercise() {
|
||||
let exercise = Exercise {
|
||||
name: "finished_exercise".into(),
|
||||
path: PathBuf::from("tests/fixture/state/finished_exercise.rs"),
|
||||
path: PathBuf::from("tests/fixture/state/exercises/finished_exercise.rs"),
|
||||
mode: Mode::Compile,
|
||||
hint: String::new(),
|
||||
};
|
||||
|
@ -438,7 +438,7 @@ mod test {
|
|||
fn test_exercise_with_output() {
|
||||
let exercise = Exercise {
|
||||
name: "exercise_with_output".into(),
|
||||
path: PathBuf::from("tests/fixture/success/testSuccess.rs"),
|
||||
path: PathBuf::from("tests/fixture/success/exercises/testSuccess.rs"),
|
||||
mode: Mode::Test,
|
||||
hint: String::new(),
|
||||
};
|
||||
|
|
12
src/main.rs
12
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")?;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
[[exercises]]
|
||||
name = "compFailure"
|
||||
path = "compFailure.rs"
|
||||
path = "exercises/compFailure.rs"
|
||||
mode = "compile"
|
||||
hint = ""
|
||||
|
||||
[[exercises]]
|
||||
name = "testFailure"
|
||||
path = "testFailure.rs"
|
||||
path = "exercises/testFailure.rs"
|
||||
mode = "test"
|
||||
hint = "Hello!"
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
[[exercises]]
|
||||
name = "pending_exercise"
|
||||
path = "pending_exercise.rs"
|
||||
path = "exercises/pending_exercise.rs"
|
||||
mode = "compile"
|
||||
hint = """"""
|
||||
|
||||
[[exercises]]
|
||||
name = "pending_test_exercise"
|
||||
path = "pending_test_exercise.rs"
|
||||
path = "exercises/pending_test_exercise.rs"
|
||||
mode = "test"
|
||||
hint = """"""
|
||||
|
||||
[[exercises]]
|
||||
name = "finished_exercise"
|
||||
path = "finished_exercise.rs"
|
||||
path = "exercises/finished_exercise.rs"
|
||||
mode = "compile"
|
||||
hint = """"""
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
[[exercises]]
|
||||
name = "compSuccess"
|
||||
path = "compSuccess.rs"
|
||||
path = "exercises/compSuccess.rs"
|
||||
mode = "compile"
|
||||
hint = """"""
|
||||
|
||||
[[exercises]]
|
||||
name = "testSuccess"
|
||||
path = "testSuccess.rs"
|
||||
path = "exercises/testSuccess.rs"
|
||||
mode = "test"
|
||||
hint = """"""
|
||||
|
|
Loading…
Reference in a new issue