]> git.lizzy.rs Git - rust.git/commitdiff
rustc_tools_util: add test
authorMatthias Krüger <matthias.krueger@famsik.de>
Fri, 7 Sep 2018 17:06:02 +0000 (19:06 +0200)
committerMatthias Krüger <matthias.krueger@famsik.de>
Fri, 7 Sep 2018 17:18:45 +0000 (19:18 +0200)
ci/base-tests.sh
rustc_tools_util/src/lib.rs

index 94a810e4ef4f19c605ef68843d80ec20763678bf..0d0a370feefa97434938e304deca08961b919f59 100755 (executable)
@@ -8,6 +8,7 @@ remark -f *.md > /dev/null
 cargo build --features debugging
 cargo test --features debugging
 cd clippy_lints && cargo test && cd ..
+cd rustc_tools_util && cargo test && cd ..
 mkdir -p ~/rust/cargo/bin
 cp target/debug/cargo-clippy ~/rust/cargo/bin/cargo-clippy
 cp target/debug/clippy-driver ~/rust/cargo/bin/clippy-driver
index b2ec96122908fc3c566f1d58fb4b7522a891ffd3..aad9ee88fc78de6fc7be0d1e2187804deac4f82c 100644 (file)
@@ -1,3 +1,4 @@
+#![feature(test)]
 #![feature(tool_lints)]
 
 use std::env;
@@ -84,3 +85,28 @@ pub fn get_commit_date() -> Option<String> {
         .ok()
         .and_then(|r| String::from_utf8(r.stdout).ok())
 }
+
+#[cfg(test)]
+mod test {
+    use super::*;
+
+    #[test]
+    fn test_struct_local() {
+        let vi = get_version_info!();
+        assert_eq!(vi.major, 0);
+        assert_eq!(vi.minor, 1);
+        assert_eq!(vi.patch, 0);
+        assert_eq!(vi.crate_name, "rustc_tools_util");
+        // hard to make positive tests for these since they will always change
+        assert!(vi.commit_hash.is_none());
+        assert!(vi.commit_date.is_none());
+    }
+
+    #[test]
+    fn test_display_local() {
+        let vi = get_version_info!();
+        let fmt = format!("{}", vi);
+        assert_eq!(fmt, "rustc_tools_util 0.1.0");
+    }
+
+}