diff options
| author | Chris Pearce <christopher.james.pearce@gmail.com> | 2019-04-07 17:12:03 +0100 |
|---|---|---|
| committer | Chris Pearce <christopher.james.pearce@gmail.com> | 2019-04-07 17:26:01 +0100 |
| commit | 4fa79ee02ff0c07c4670166e17b879d809569539 (patch) | |
| tree | 4a14f5ae998c714c338a120e9c11b7505b876742 /src/util.rs | |
| parent | fbd0ccbd5b7c86846e2488bf4d8dce0b1b90b04e (diff) | |
Extract command builders into util
Diffstat (limited to 'src/util.rs')
| -rw-r--r-- | src/util.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs index 4a96ee9..8fcf693 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,29 @@ use std::fs::remove_file; +use std::process::{Command, Output}; + +const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"]; + +pub fn compile_test_cmd(filename: &str) -> Output { + Command::new("rustc") + .args(&["--test", filename, "-o", "temp"]) + .args(RUSTC_COLOR_ARGS) + .output() + .expect("failed to compile exercise") +} + +pub fn compile_cmd(filename: &str) -> Output { + Command::new("rustc") + .args(&[filename, "-o", "temp"]) + .args(RUSTC_COLOR_ARGS) + .output() + .expect("failed to compile exercise") +} + +pub fn run_cmd() -> Output { + Command::new("./temp") + .output() + .expect("failed to run exercise") +} pub fn clean() { let _ignored = remove_file("temp"); |
