mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
Fix tests
This commit is contained in:
parent
fe7d775818
commit
79ca821e26
|
@ -354,7 +354,7 @@ mod test {
|
||||||
File::create(temp_file()).unwrap();
|
File::create(temp_file()).unwrap();
|
||||||
let exercise = Exercise {
|
let exercise = Exercise {
|
||||||
name: String::from("example"),
|
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,
|
mode: Mode::Compile,
|
||||||
hint: String::from(""),
|
hint: String::from(""),
|
||||||
};
|
};
|
||||||
|
@ -372,7 +372,7 @@ mod test {
|
||||||
let exercise = Exercise {
|
let exercise = Exercise {
|
||||||
name: String::from("example"),
|
name: String::from("example"),
|
||||||
// We want a file that does actually compile
|
// 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,
|
mode: *mode,
|
||||||
hint: String::from(""),
|
hint: String::from(""),
|
||||||
};
|
};
|
||||||
|
@ -385,7 +385,7 @@ mod test {
|
||||||
fn test_pending_state() {
|
fn test_pending_state() {
|
||||||
let exercise = Exercise {
|
let exercise = Exercise {
|
||||||
name: "pending_exercise".into(),
|
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,
|
mode: Mode::Compile,
|
||||||
hint: String::new(),
|
hint: String::new(),
|
||||||
};
|
};
|
||||||
|
@ -426,7 +426,7 @@ mod test {
|
||||||
fn test_finished_exercise() {
|
fn test_finished_exercise() {
|
||||||
let exercise = Exercise {
|
let exercise = Exercise {
|
||||||
name: "finished_exercise".into(),
|
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,
|
mode: Mode::Compile,
|
||||||
hint: String::new(),
|
hint: String::new(),
|
||||||
};
|
};
|
||||||
|
@ -438,7 +438,7 @@ mod test {
|
||||||
fn test_exercise_with_output() {
|
fn test_exercise_with_output() {
|
||||||
let exercise = Exercise {
|
let exercise = Exercise {
|
||||||
name: "exercise_with_output".into(),
|
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,
|
mode: Mode::Test,
|
||||||
hint: String::new(),
|
hint: String::new(),
|
||||||
};
|
};
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -9,6 +9,7 @@ use notify_debouncer_mini::notify::{self, RecursiveMode};
|
||||||
use notify_debouncer_mini::{new_debouncer, DebouncedEventKind};
|
use notify_debouncer_mini::{new_debouncer, DebouncedEventKind};
|
||||||
use shlex::Shlex;
|
use shlex::Shlex;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::fs;
|
||||||
use std::io::{self, prelude::*};
|
use std::io::{self, prelude::*};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::{exit, Command};
|
use std::process::{exit, Command};
|
||||||
|
@ -100,8 +101,13 @@ fn main() -> Result<()> {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let exercises = toml_edit::de::from_str::<ExerciseList>(EMBEDDED_FILES.info_toml_content)
|
// Read a local `info.toml` if it exists. Mainly to let the tests work for now.
|
||||||
.unwrap()
|
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;
|
.exercises;
|
||||||
|
|
||||||
if matches!(args.command, Some(Subcommands::Init)) {
|
if matches!(args.command, Some(Subcommands::Init)) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "compFailure"
|
name = "compFailure"
|
||||||
path = "compFailure.rs"
|
path = "exercises/compFailure.rs"
|
||||||
mode = "compile"
|
mode = "compile"
|
||||||
hint = ""
|
hint = ""
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "testFailure"
|
name = "testFailure"
|
||||||
path = "testFailure.rs"
|
path = "exercises/testFailure.rs"
|
||||||
mode = "test"
|
mode = "test"
|
||||||
hint = "Hello!"
|
hint = "Hello!"
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "pending_exercise"
|
name = "pending_exercise"
|
||||||
path = "pending_exercise.rs"
|
path = "exercises/pending_exercise.rs"
|
||||||
mode = "compile"
|
mode = "compile"
|
||||||
hint = """"""
|
hint = """"""
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "pending_test_exercise"
|
name = "pending_test_exercise"
|
||||||
path = "pending_test_exercise.rs"
|
path = "exercises/pending_test_exercise.rs"
|
||||||
mode = "test"
|
mode = "test"
|
||||||
hint = """"""
|
hint = """"""
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "finished_exercise"
|
name = "finished_exercise"
|
||||||
path = "finished_exercise.rs"
|
path = "exercises/finished_exercise.rs"
|
||||||
mode = "compile"
|
mode = "compile"
|
||||||
hint = """"""
|
hint = """"""
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "compSuccess"
|
name = "compSuccess"
|
||||||
path = "compSuccess.rs"
|
path = "exercises/compSuccess.rs"
|
||||||
mode = "compile"
|
mode = "compile"
|
||||||
hint = """"""
|
hint = """"""
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "testSuccess"
|
name = "testSuccess"
|
||||||
path = "testSuccess.rs"
|
path = "exercises/testSuccess.rs"
|
||||||
mode = "test"
|
mode = "test"
|
||||||
hint = """"""
|
hint = """"""
|
||||||
|
|
Loading…
Reference in a new issue