mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
chore: fix format
This commit is contained in:
parent
3f23d26600
commit
84b1cf8849
|
@ -170,20 +170,22 @@ path = "{}.rs""#,
|
|||
.args(RUSTC_COLOR_ARGS)
|
||||
.args(["--", "-D", "warnings", "-D", "clippy::float_cmp"])
|
||||
.output()
|
||||
},
|
||||
Mode::CrateCompile => {
|
||||
Command::new("cargo")
|
||||
.args(["build", "--manifest-path", self.path.to_str().unwrap(), "--target-dir", &temp_file()])
|
||||
.output()
|
||||
},
|
||||
Mode::CrateTest => {
|
||||
Command::new("cargo")
|
||||
.args(["test", "--no-run"])
|
||||
.args(["--manifest-path", self.path.to_str().unwrap()])
|
||||
.args(["--target-dir", &temp_file()])
|
||||
.args(["--message-format", "json-render-diagnostics"])
|
||||
.output()
|
||||
}
|
||||
Mode::CrateCompile => Command::new("cargo")
|
||||
.args([
|
||||
"build",
|
||||
"--manifest-path",
|
||||
self.path.to_str().unwrap(),
|
||||
"--target-dir",
|
||||
&temp_file(),
|
||||
])
|
||||
.output(),
|
||||
Mode::CrateTest => Command::new("cargo")
|
||||
.args(["test", "--no-run"])
|
||||
.args(["--manifest-path", self.path.to_str().unwrap()])
|
||||
.args(["--target-dir", &temp_file()])
|
||||
.args(["--message-format", "json-render-diagnostics"])
|
||||
.output(),
|
||||
}
|
||||
.expect("Failed to run 'compile' command.");
|
||||
|
||||
|
@ -221,18 +223,19 @@ path = "{}.rs""#,
|
|||
let get_filename_result = self.get_crate_test_filename(&compilation_stdout);
|
||||
match get_filename_result {
|
||||
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) {
|
||||
match self.mode {
|
||||
Mode::CrateCompile | Mode::CrateTest => fs::remove_dir_all(temp_file())
|
||||
.expect("Failed to cleanup temp build dir"),
|
||||
_ => ()
|
||||
Mode::CrateCompile | Mode::CrateTest => {
|
||||
fs::remove_dir_all(temp_file()).expect("Failed to cleanup temp build dir")
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,24 +247,22 @@ path = "{}.rs""#,
|
|||
|
||||
let filename = self.get_compiled_filename_by_mode(compilation_stdout);
|
||||
|
||||
let command_output = Command::new(filename)
|
||||
.arg(arg)
|
||||
.output();
|
||||
let command_output = Command::new(filename).arg(arg).output();
|
||||
let result = match command_output {
|
||||
Ok(cmd) => {
|
||||
let output = ExerciseOutput {
|
||||
stdout: String::from_utf8_lossy(&cmd.stdout).to_string(),
|
||||
stderr: String::from_utf8_lossy(&cmd.stderr).to_string(),
|
||||
};
|
||||
|
||||
|
||||
self.cleanup_temporary_dirs_by_mode();
|
||||
|
||||
|
||||
if cmd.status.success() {
|
||||
Ok(output)
|
||||
} else {
|
||||
Err(output)
|
||||
}
|
||||
},
|
||||
}
|
||||
Err(msg) => {
|
||||
self.cleanup_temporary_dirs_by_mode();
|
||||
println!("Error: {}", msg);
|
||||
|
|
|
@ -28,8 +28,12 @@ pub fn verify<'a>(
|
|||
|
||||
for exercise in exercises {
|
||||
let compile_result = match exercise.mode {
|
||||
Mode::Test | Mode::CrateTest => compile_and_test(exercise, RunMode::Interactive, verbose, success_hints),
|
||||
Mode::Compile | Mode::CrateCompile => compile_and_run_interactively(exercise, success_hints),
|
||||
Mode::Test | Mode::CrateTest => {
|
||||
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),
|
||||
};
|
||||
if !compile_result.unwrap_or(false) {
|
||||
|
|
Loading…
Reference in a new issue