summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd.rs7
-rw-r--r--src/exercise.rs53
2 files changed, 25 insertions, 35 deletions
diff --git a/src/cmd.rs b/src/cmd.rs
index 1891a28..ba6ec89 100644
--- a/src/cmd.rs
+++ b/src/cmd.rs
@@ -129,13 +129,6 @@ impl<'out> CargoSubcommand<'out> {
self
}
- /// RUSTFLAGS="-A warnings"
- #[inline]
- pub fn hide_warnings(&mut self) -> &mut Self {
- self.cmd.env("RUSTFLAGS", "-A warnings");
- self
- }
-
/// The boolean in the returned `Result` is true if the command's exit status is success.
#[inline]
pub fn run(self, description: &str) -> Result<bool> {
diff --git a/src/exercise.rs b/src/exercise.rs
index 7a383bb..500d119 100644
--- a/src/exercise.rs
+++ b/src/exercise.rs
@@ -78,27 +78,40 @@ pub trait RunnableExercise {
mut output: Option<&mut Vec<u8>>,
cmd_runner: &CmdRunner,
) -> Result<bool> {
- let output_is_none = if let Some(output) = output.as_deref_mut() {
+ if let Some(output) = output.as_deref_mut() {
output.clear();
- false
- } else {
- true
- };
-
- let mut build_cmd = cmd_runner.cargo("build", bin_name, output.as_deref_mut());
- if output_is_none {
- build_cmd.hide_warnings();
}
- let build_success = build_cmd.run("cargo build …")?;
+
+ let build_success = cmd_runner
+ .cargo("build", bin_name, output.as_deref_mut())
+ .run("cargo build …")?;
if !build_success {
return Ok(false);
}
- // Discard the output of `cargo build` because it will be shown again by Clippy.
+ // Discard the compiler output because it will be shown again by `cargo test` or Clippy.
if let Some(output) = output.as_deref_mut() {
output.clear();
}
+ if self.test() {
+ let output_is_some = output.is_some();
+ let mut test_cmd = cmd_runner.cargo("test", bin_name, output.as_deref_mut());
+ if output_is_some {
+ test_cmd.args(["--", "--color", "always", "--show-output"]);
+ }
+ let test_success = test_cmd.run("cargo test …")?;
+ if !test_success {
+ run_bin(bin_name, output, cmd_runner)?;
+ return Ok(false);
+ }
+
+ // Discard the compiler output because it will be shown again by Clippy.
+ if let Some(output) = output.as_deref_mut() {
+ output.clear();
+ }
+ }
+
let mut clippy_cmd = cmd_runner.cargo("clippy", bin_name, output.as_deref_mut());
// `--profile test` is required to also check code with `[cfg(test)]`.
@@ -109,25 +122,9 @@ pub trait RunnableExercise {
}
let clippy_success = clippy_cmd.run("cargo clippy …")?;
- if !clippy_success {
- return Ok(false);
- }
-
- if !self.test() {
- return run_bin(bin_name, output.as_deref_mut(), cmd_runner);
- }
-
- let mut test_cmd = cmd_runner.cargo("test", bin_name, output.as_deref_mut());
- if !output_is_none {
- test_cmd.args(["--", "--color", "always", "--show-output"]);
- }
- // Hide warnings because they are shown by Clippy.
- test_cmd.hide_warnings();
- let test_success = test_cmd.run("cargo test …")?;
-
let run_success = run_bin(bin_name, output, cmd_runner)?;
- Ok(test_success && run_success)
+ Ok(clippy_success && run_success)
}
/// Compile, check and run the exercise.