Skip to content

Commit a141550

Browse files
committed
rustc_tools_util: add test
1 parent 202db3e commit a141550

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ci/base-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ remark -f *.md > /dev/null
88
cargo build --features debugging
99
cargo test --features debugging
1010
cd clippy_lints && cargo test && cd ..
11+
cd rustc_tools_util && cargo test && cd ..
1112
mkdir -p ~/rust/cargo/bin
1213
cp target/debug/cargo-clippy ~/rust/cargo/bin/cargo-clippy
1314
cp target/debug/clippy-driver ~/rust/cargo/bin/clippy-driver

rustc_tools_util/src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(test)]
12
#![feature(tool_lints)]
23

34
use std::env;
@@ -84,3 +85,28 @@ pub fn get_commit_date() -> Option<String> {
8485
.ok()
8586
.and_then(|r| String::from_utf8(r.stdout).ok())
8687
}
88+
89+
#[cfg(test)]
90+
mod test {
91+
use super::*;
92+
93+
#[test]
94+
fn test_struct_local() {
95+
let vi = get_version_info!();
96+
assert_eq!(vi.major, 0);
97+
assert_eq!(vi.minor, 1);
98+
assert_eq!(vi.patch, 0);
99+
assert_eq!(vi.crate_name, "rustc_tools_util");
100+
// hard to make positive tests for these since they will always change
101+
assert!(vi.commit_hash.is_none());
102+
assert!(vi.commit_date.is_none());
103+
}
104+
105+
#[test]
106+
fn test_display_local() {
107+
let vi = get_version_info!();
108+
let fmt = format!("{}", vi);
109+
assert_eq!(fmt, "rustc_tools_util 0.1.0");
110+
}
111+
112+
}

0 commit comments

Comments
 (0)