MCPcopy Create free account
hub / github.com/ExtropyIO/SolanaBootcamp / compile_and_test

Function compile_and_test

homeworks_rust/src/verify.rs:87–117  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

85// Compile the given Exercise as a test harness and display
86// the output if verbose is set to true
87fn 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

Callers 2

verifyFunction · 0.85
testFunction · 0.85

Calls 3

compileFunction · 0.85
prompt_for_completionFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected