mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 23:04:17 -05:00
Fix tests
This commit is contained in:
parent
919ba88413
commit
5a233398eb
3 changed files with 7 additions and 18 deletions
10
src/run.rs
10
src/run.rs
|
@ -1,4 +1,4 @@
|
||||||
use anyhow::Result;
|
use anyhow::{bail, Result};
|
||||||
use std::io::{stdout, Write};
|
use std::io::{stdout, Write};
|
||||||
|
|
||||||
use crate::exercise::Exercise;
|
use crate::exercise::Exercise;
|
||||||
|
@ -17,11 +17,11 @@ pub fn run(exercise: &Exercise) -> Result<()> {
|
||||||
stdout.flush()?;
|
stdout.flush()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if output.status.success() {
|
if !output.status.success() {
|
||||||
success!("Successfully ran {}", exercise);
|
bail!("Ran {exercise} with errors");
|
||||||
} else {
|
|
||||||
warn!("Ran {} with errors", exercise);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
success!("Successfully ran {}", exercise);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ struct InfoToml {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dev_cargo_bins() {
|
fn dev_cargo_bins() {
|
||||||
let content = fs::read_to_string("exercises/Cargo.toml").unwrap();
|
let content = fs::read_to_string("dev/Cargo.toml").unwrap();
|
||||||
|
|
||||||
let exercises = toml_edit::de::from_str::<InfoToml>(&fs::read_to_string("info.toml").unwrap())
|
let exercises = toml_edit::de::from_str::<InfoToml>(&fs::read_to_string("info.toml").unwrap())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -194,24 +194,13 @@ fn run_test_exercise_does_not_prompt() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn run_single_test_success_with_output() {
|
fn run_single_test_success_with_output() {
|
||||||
Command::cargo_bin("rustlings")
|
|
||||||
.unwrap()
|
|
||||||
.args(["--nocapture", "run", "testSuccess"])
|
|
||||||
.current_dir("tests/fixture/success/")
|
|
||||||
.assert()
|
|
||||||
.code(0)
|
|
||||||
.stdout(predicates::str::contains("THIS TEST TOO SHALL PASS"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn run_single_test_success_without_output() {
|
|
||||||
Command::cargo_bin("rustlings")
|
Command::cargo_bin("rustlings")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.args(["run", "testSuccess"])
|
.args(["run", "testSuccess"])
|
||||||
.current_dir("tests/fixture/success/")
|
.current_dir("tests/fixture/success/")
|
||||||
.assert()
|
.assert()
|
||||||
.code(0)
|
.code(0)
|
||||||
.stdout(predicates::str::contains("THIS TEST TOO SHALL PASS").not());
|
.stdout(predicates::str::contains("THIS TEST TOO SHALL PASS"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue