summaryrefslogtreecommitdiff
path: root/src/run.rs
diff options
context:
space:
mode:
authorAbdou Seck <djily02016@gmail.com>2020-06-04 10:31:17 -0400
committerAbdou Seck <djily02016@gmail.com>2020-06-04 11:18:26 -0400
commit8ad5f9bf531a4848b1104b7b389a20171624c82f (patch)
tree331c5d3725140b07d836ed8be6df30c8ddfd63fb /src/run.rs
parent02a2fe48714a4546b28d38fb611e6bfce9f43cf6 (diff)
feat: Add a --nocapture option to display test harnesses' outputs
This new feature can be accessed by invoking rustlings with --nocapture. Both unit and integration tests added. closes #262 BREAKING CHANGES: The following function take a new boolean argument: * `run` * `verify` * `test` * `compile_and_test`
Diffstat (limited to 'src/run.rs')
-rw-r--r--src/run.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/run.rs b/src/run.rs
index ebb0ae6..fdabb3e 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -2,15 +2,22 @@ use crate::exercise::{Exercise, Mode};
use crate::verify::test;
use indicatif::ProgressBar;
-pub fn run(exercise: &Exercise) -> Result<(), ()> {
+// Invoke the rust compiler on the path of the given exercise,
+// and run the ensuing binary.
+// The verbose argument helps determine whether or not to show
+// the output from the test harnesses (if the mode of the exercise is test)
+pub fn run(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
match exercise.mode {
- Mode::Test => test(exercise)?,
+ Mode::Test => test(exercise, verbose)?,
Mode::Compile => compile_and_run(exercise)?,
Mode::Clippy => compile_and_run(exercise)?,
}
Ok(())
}
+// Invoke the rust compiler on the path of the given exercise
+// and run the ensuing binary.
+// This is strictly for non-test binaries, so output is displayed
fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());