This commit is contained in:
姜坤 2022-11-14 19:42:18 +08:00
parent 97e3c419aa
commit e848118c3c
2 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,7 @@
use std::process::Command;
use crate::exercise::{Exercise, Mode};
use crate::verify::test;
use crate::verify::{test, compile_only};
use indicatif::ProgressBar;
// 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 {
Mode::Test => test(exercise, verbose)?,
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(())
}

View File

@ -48,7 +48,7 @@ pub fn test(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
}
// 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();
progress_bar.set_message(format!("Compiling {exercise}..."));
progress_bar.enable_steady_tick(100);