Compile the given Exercise as a test harness and display the output if verbose is set to true
(exercise: &Exercise, run_mode: RunMode, verbose: bool)
| 85 | // Compile the given Exercise as a test harness and display |
| 86 | // the output if verbose is set to true |
| 87 | fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Result<bool, ()> { |
| 88 | let progress_bar = ProgressBar::new_spinner(); |
| 89 | progress_bar.set_message(format!("Testing {}...", exercise).as_str()); |
| 90 | progress_bar.enable_steady_tick(100); |
| 91 | |
| 92 | let compilation = compile(exercise, &progress_bar)?; |
| 93 | let result = compilation.run(); |
| 94 | progress_bar.finish_and_clear(); |
| 95 | |
| 96 | match result { |
| 97 | Ok(output) => { |
| 98 | if verbose { |
| 99 | println!("{}", output.stdout); |
| 100 | } |
| 101 | success!("Successfully tested {}", &exercise); |
| 102 | if let RunMode::Interactive = run_mode { |
| 103 | Ok(prompt_for_completion(exercise, None)) |
| 104 | } else { |
| 105 | Ok(true) |
| 106 | } |
| 107 | } |
| 108 | Err(output) => { |
| 109 | warn!( |
| 110 | "Testing of {} failed! Please try again. Here's the output:", |
| 111 | exercise |
| 112 | ); |
| 113 | println!("{}", output.stdout); |
| 114 | Err(()) |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // Compile the given Exercise and return an object with information |
| 120 | // about the state of the compilation |
no test coverage detected