Fix tests

This commit is contained in:
mo8it 2024-04-05 00:44:43 +02:00
parent 919ba88413
commit 5a233398eb
3 changed files with 7 additions and 18 deletions

View file

@ -1,4 +1,4 @@
use anyhow::Result;
use anyhow::{bail, Result};
use std::io::{stdout, Write};
use crate::exercise::Exercise;
@ -17,11 +17,11 @@ pub fn run(exercise: &Exercise) -> Result<()> {
stdout.flush()?;
}
if output.status.success() {
success!("Successfully ran {}", exercise);
} else {
warn!("Ran {} with errors", exercise);
if !output.status.success() {
bail!("Ran {exercise} with errors");
}
success!("Successfully ran {}", exercise);
Ok(())
}

View file

@ -17,7 +17,7 @@ struct InfoToml {
#[test]
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())
.unwrap()

View file

@ -194,24 +194,13 @@ fn run_test_exercise_does_not_prompt() {
#[test]
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")
.unwrap()
.args(["run", "testSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.code(0)
.stdout(predicates::str::contains("THIS TEST TOO SHALL PASS").not());
.stdout(predicates::str::contains("THIS TEST TOO SHALL PASS"));
}
#[test]