tidy: Unconfigure tests during normal build

This commit is contained in:
Vadim Petrochenkov 2019-08-01 02:07:24 +03:00
parent 435236b887
commit b990c6d813
5 changed files with 53 additions and 51 deletions

View File

@ -16,6 +16,9 @@ use std::path::Path;
use regex::Regex;
#[cfg(test)]
mod tests;
mod version;
use version::Version;
@ -203,14 +206,6 @@ fn find_attr_val<'a>(line: &'a str, attr: &str) -> Option<&'a str> {
.map(|m| m.as_str())
}
#[test]
fn test_find_attr_val() {
let s = r#"#[unstable(feature = "checked_duration_since", issue = "58402")]"#;
assert_eq!(find_attr_val(s, "feature"), Some("checked_duration_since"));
assert_eq!(find_attr_val(s, "issue"), Some("58402"));
assert_eq!(find_attr_val(s, "since"), None);
}
fn test_filen_gate(filen_underscore: &str, features: &mut Features) -> bool {
let prefix = "feature_gate_";
if filen_underscore.starts_with(prefix) {

View File

@ -0,0 +1,9 @@
use super::*;
#[test]
fn test_find_attr_val() {
let s = r#"#[unstable(feature = "checked_duration_since", issue = "58402")]"#;
assert_eq!(find_attr_val(s, "feature"), Some("checked_duration_since"));
assert_eq!(find_attr_val(s, "issue"), Some("58402"));
assert_eq!(find_attr_val(s, "since"), None);
}

View File

@ -2,6 +2,9 @@ use std::str::FromStr;
use std::num::ParseIntError;
use std::fmt;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Version {
parts: [u32; 3],
@ -46,45 +49,3 @@ impl FromStr for Version {
Ok(Self { parts })
}
}
#[cfg(test)]
mod test {
use super::Version;
#[test]
fn test_try_from_invalid_version() {
assert!("".parse::<Version>().is_err());
assert!("hello".parse::<Version>().is_err());
assert!("1.32.hi".parse::<Version>().is_err());
assert!("1.32..1".parse::<Version>().is_err());
assert!("1.32".parse::<Version>().is_err());
assert!("1.32.0.1".parse::<Version>().is_err());
}
#[test]
fn test_try_from_single() {
assert_eq!("1.32.0".parse(), Ok(Version { parts: [1, 32, 0] }));
assert_eq!("1.0.0".parse(), Ok(Version { parts: [1, 0, 0] }));
}
#[test]
fn test_compare() {
let v_1_0_0 = "1.0.0".parse::<Version>().unwrap();
let v_1_32_0 = "1.32.0".parse::<Version>().unwrap();
let v_1_32_1 = "1.32.1".parse::<Version>().unwrap();
assert!(v_1_0_0 < v_1_32_1);
assert!(v_1_0_0 < v_1_32_0);
assert!(v_1_32_0 < v_1_32_1);
}
#[test]
fn test_to_string() {
let v_1_0_0 = "1.0.0".parse::<Version>().unwrap();
let v_1_32_1 = "1.32.1".parse::<Version>().unwrap();
assert_eq!(v_1_0_0.to_string(), "1.0.0");
assert_eq!(v_1_32_1.to_string(), "1.32.1");
assert_eq!(format!("{:<8}", v_1_32_1), "1.32.1 ");
assert_eq!(format!("{:>8}", v_1_32_1), " 1.32.1");
}
}

View File

@ -0,0 +1,38 @@
use super::*;
#[test]
fn test_try_from_invalid_version() {
assert!("".parse::<Version>().is_err());
assert!("hello".parse::<Version>().is_err());
assert!("1.32.hi".parse::<Version>().is_err());
assert!("1.32..1".parse::<Version>().is_err());
assert!("1.32".parse::<Version>().is_err());
assert!("1.32.0.1".parse::<Version>().is_err());
}
#[test]
fn test_try_from_single() {
assert_eq!("1.32.0".parse(), Ok(Version { parts: [1, 32, 0] }));
assert_eq!("1.0.0".parse(), Ok(Version { parts: [1, 0, 0] }));
}
#[test]
fn test_compare() {
let v_1_0_0 = "1.0.0".parse::<Version>().unwrap();
let v_1_32_0 = "1.32.0".parse::<Version>().unwrap();
let v_1_32_1 = "1.32.1".parse::<Version>().unwrap();
assert!(v_1_0_0 < v_1_32_1);
assert!(v_1_0_0 < v_1_32_0);
assert!(v_1_32_0 < v_1_32_1);
}
#[test]
fn test_to_string() {
let v_1_0_0 = "1.0.0".parse::<Version>().unwrap();
let v_1_32_1 = "1.32.1".parse::<Version>().unwrap();
assert_eq!(v_1_0_0.to_string(), "1.0.0");
assert_eq!(v_1_32_1.to_string(), "1.32.1");
assert_eq!(format!("{:<8}", v_1_32_1), "1.32.1 ");
assert_eq!(format!("{:>8}", v_1_32_1), " 1.32.1");
}

View File

@ -41,7 +41,6 @@ pub fn check(root_path: &Path, bad: &mut bool) {
"libterm/terminfo",
"libtest",
"tools/compiletest/src",
"tools/tidy/src",
];
let mut skip = |path: &Path| {