blob: 38f4e0e22c9fcdbb951cd89bef74993b6f184918 (
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
28
|
use anyhow::{bail, 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() {
bail!("Ran {exercise} with errors");
}
// TODO: Color
println!("Successfully ran {exercise}");
Ok(())
}
|