summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Pearce <christopher.james.pearce@gmail.com>2019-04-12 22:48:57 +0100
committerChris Pearce <christopher.james.pearce@gmail.com>2019-04-12 23:14:15 +0100
commit77de6e5d6a1d7b2ed1aaacc0680ddef86dc80d51 (patch)
treec2931b05ebfea9233d97b69d247b1885d62e265b /src
parent8c867a001a0d588b2aa367f89ae71f6fa548daa8 (diff)
Clean up test includes for File and Path
Diffstat (limited to 'src')
-rw-r--r--src/exercise.rs27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/exercise.rs b/src/exercise.rs
index 577d428..e0c6ce7c8 100644
--- a/src/exercise.rs
+++ b/src/exercise.rs
@@ -1,8 +1,8 @@
+use serde::Deserialize;
use std::fmt::{self, Display, Formatter};
use std::fs::{remove_file};
use std::path::{PathBuf};
use std::process::{self, Command, Output};
-use serde::Deserialize;
const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];
@@ -60,13 +60,20 @@ impl Display for Exercise {
}
}
-#[test]
-fn test_clean() {
- std::fs::File::create(&temp_file()).unwrap();
- let exercise = Exercise {
- path: PathBuf::from("example.rs"),
- mode: Mode::Test,
- };
- exercise.clean();
- assert!(!std::path::Path::new(&temp_file()).exists());
+#[cfg(test)]
+mod test {
+ use super::*;
+ use std::path::Path;
+ use std::fs::File;
+
+ #[test]
+ fn test_clean() {
+ File::create(&temp_file()).unwrap();
+ let exercise = Exercise {
+ path: PathBuf::from("example.rs"),
+ mode: Mode::Test,
+ };
+ exercise.clean();
+ assert!(!Path::new(&temp_file()).exists());
+ }
}