summaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authorChris Pearce <christopher.james.pearce@gmail.com>2019-04-11 21:41:24 +0100
committerChris Pearce <christopher.james.pearce@gmail.com>2019-04-12 08:58:25 +0100
commitd01a71f7de15f34922dc2a14a00436f466b84e87 (patch)
treef36483bfca95c7355bf46321a05050c8e7fdb988 /src/util.rs
parent04d1d4c00ee9c74d64734ef9880607599830286d (diff)
Extract exercise struct to encapsulate path logic
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/util.rs b/src/util.rs
deleted file mode 100644
index 6bac972..0000000
--- a/src/util.rs
+++ /dev/null
@@ -1,41 +0,0 @@
-use std::fs::remove_file;
-use std::process::{self, Command, Output};
-
-const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];
-
-fn temp_file() -> String {
- format!("./temp_{}", process::id())
-}
-
-pub fn compile_test_cmd(filename: &str) -> Output {
- Command::new("rustc")
- .args(&["--test", filename, "-o", &temp_file()])
- .args(RUSTC_COLOR_ARGS)
- .output()
- .expect("failed to compile exercise")
-}
-
-pub fn compile_cmd(filename: &str) -> Output {
- Command::new("rustc")
- .args(&[filename, "-o", &temp_file()])
- .args(RUSTC_COLOR_ARGS)
- .output()
- .expect("failed to compile exercise")
-}
-
-pub fn run_cmd() -> Output {
- Command::new(&temp_file())
- .output()
- .expect("failed to run exercise")
-}
-
-pub fn clean() {
- let _ignored = remove_file(&temp_file());
-}
-
-#[test]
-fn test_clean() {
- std::fs::File::create(&temp_file()).unwrap();
- clean();
- assert!(!std::path::Path::new(&temp_file()).exists());
-}