chore: fix format

This commit is contained in:
Ben 2023-11-03 20:39:51 +00:00
parent 3f23d26600
commit 84b1cf8849
2 changed files with 32 additions and 27 deletions

View file

@ -170,20 +170,22 @@ path = "{}.rs""#,
.args(RUSTC_COLOR_ARGS) .args(RUSTC_COLOR_ARGS)
.args(["--", "-D", "warnings", "-D", "clippy::float_cmp"]) .args(["--", "-D", "warnings", "-D", "clippy::float_cmp"])
.output() .output()
}, }
Mode::CrateCompile => { Mode::CrateCompile => Command::new("cargo")
Command::new("cargo") .args([
.args(["build", "--manifest-path", self.path.to_str().unwrap(), "--target-dir", &temp_file()]) "build",
.output() "--manifest-path",
}, self.path.to_str().unwrap(),
Mode::CrateTest => { "--target-dir",
Command::new("cargo") &temp_file(),
])
.output(),
Mode::CrateTest => Command::new("cargo")
.args(["test", "--no-run"]) .args(["test", "--no-run"])
.args(["--manifest-path", self.path.to_str().unwrap()]) .args(["--manifest-path", self.path.to_str().unwrap()])
.args(["--target-dir", &temp_file()]) .args(["--target-dir", &temp_file()])
.args(["--message-format", "json-render-diagnostics"]) .args(["--message-format", "json-render-diagnostics"])
.output() .output(),
}
} }
.expect("Failed to run 'compile' command."); .expect("Failed to run 'compile' command.");
@ -221,18 +223,19 @@ path = "{}.rs""#,
let get_filename_result = self.get_crate_test_filename(&compilation_stdout); let get_filename_result = self.get_crate_test_filename(&compilation_stdout);
match get_filename_result { match get_filename_result {
Ok(filename) => filename, Ok(filename) => filename,
Err(()) => panic!("Failed to get crate test filename") Err(()) => panic!("Failed to get crate test filename"),
} }
}, }
_ => temp_file() _ => temp_file(),
} }
} }
fn cleanup_temporary_dirs_by_mode(&self) { fn cleanup_temporary_dirs_by_mode(&self) {
match self.mode { match self.mode {
Mode::CrateCompile | Mode::CrateTest => fs::remove_dir_all(temp_file()) Mode::CrateCompile | Mode::CrateTest => {
.expect("Failed to cleanup temp build dir"), fs::remove_dir_all(temp_file()).expect("Failed to cleanup temp build dir")
_ => () }
_ => (),
} }
} }
@ -244,9 +247,7 @@ path = "{}.rs""#,
let filename = self.get_compiled_filename_by_mode(compilation_stdout); let filename = self.get_compiled_filename_by_mode(compilation_stdout);
let command_output = Command::new(filename) let command_output = Command::new(filename).arg(arg).output();
.arg(arg)
.output();
let result = match command_output { let result = match command_output {
Ok(cmd) => { Ok(cmd) => {
let output = ExerciseOutput { let output = ExerciseOutput {
@ -261,7 +262,7 @@ path = "{}.rs""#,
} else { } else {
Err(output) Err(output)
} }
}, }
Err(msg) => { Err(msg) => {
self.cleanup_temporary_dirs_by_mode(); self.cleanup_temporary_dirs_by_mode();
println!("Error: {}", msg); println!("Error: {}", msg);

View file

@ -28,8 +28,12 @@ pub fn verify<'a>(
for exercise in exercises { for exercise in exercises {
let compile_result = match exercise.mode { let compile_result = match exercise.mode {
Mode::Test | Mode::CrateTest => compile_and_test(exercise, RunMode::Interactive, verbose, success_hints), Mode::Test | Mode::CrateTest => {
Mode::Compile | Mode::CrateCompile => compile_and_run_interactively(exercise, success_hints), compile_and_test(exercise, RunMode::Interactive, verbose, success_hints)
}
Mode::Compile | Mode::CrateCompile => {
compile_and_run_interactively(exercise, success_hints)
}
Mode::Clippy => compile_only(exercise, success_hints), Mode::Clippy => compile_only(exercise, success_hints),
}; };
if !compile_result.unwrap_or(false) { if !compile_result.unwrap_or(false) {