blob: 0a09eccf348a991bc3823c88c91124d6f648289d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use anyhow::Result;
use std::io::{stdout, Write};
use crate::exercise::Exercise;
// 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) -> Result<()> {
let output = exercise.run()?;
{
let mut stdout = stdout().lock();
stdout.write_all(&output.stdout)?;
stdout.write_all(&output.stderr)?;
stdout.flush()?;
}
if output.status.success() {
success!("Successfully ran {}", exercise);
} else {
warn!("Ran {} with errors", exercise);
}
Ok(())
}
|