mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-04-03 04:59:19 +00:00
fix #1267
This commit is contained in:
parent
97e3c419aa
commit
e848118c3c
@ -1,7 +1,7 @@
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use crate::exercise::{Exercise, Mode};
|
use crate::exercise::{Exercise, Mode};
|
||||||
use crate::verify::test;
|
use crate::verify::{test, compile_only};
|
||||||
use indicatif::ProgressBar;
|
use indicatif::ProgressBar;
|
||||||
|
|
||||||
// Invoke the rust compiler on the path of the given exercise,
|
// Invoke the rust compiler on the path of the given exercise,
|
||||||
@ -12,7 +12,10 @@ pub fn run(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
|
|||||||
match exercise.mode {
|
match exercise.mode {
|
||||||
Mode::Test => test(exercise, verbose)?,
|
Mode::Test => test(exercise, verbose)?,
|
||||||
Mode::Compile => compile_and_run(exercise)?,
|
Mode::Compile => compile_and_run(exercise)?,
|
||||||
Mode::Clippy => compile_and_run(exercise)?,
|
Mode::Clippy => match compile_only(exercise).unwrap() {
|
||||||
|
true => return Err(()),
|
||||||
|
false => return Ok(()),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ pub fn test(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Invoke the rust compiler without running the resulting binary
|
// Invoke the rust compiler without running the resulting binary
|
||||||
fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
|
pub fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
|
||||||
let progress_bar = ProgressBar::new_spinner();
|
let progress_bar = ProgressBar::new_spinner();
|
||||||
progress_bar.set_message(format!("Compiling {exercise}..."));
|
progress_bar.set_message(format!("Compiling {exercise}..."));
|
||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user