From a51ae9fb2c9bbfa6abb5eafb66d393afd00933e7 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 25 May 2022 18:24:55 +0000 Subject: [PATCH] Use unit tests to keep private things private --- ui_test/src/comments.rs | 3 +++ .../{tests/comment_parser.rs => src/comments/tests.rs} | 2 +- ui_test/src/lib.rs | 8 +++++--- ui_test/{tests/check_annotations.rs => src/tests.rs} | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) rename ui_test/{tests/comment_parser.rs => src/comments/tests.rs} (96%) rename ui_test/{tests/check_annotations.rs => src/tests.rs} (95%) diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index 64f999f54101..e83e84b22a14 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -2,6 +2,9 @@ use std::path::Path; use regex::Regex; +#[cfg(test)] +mod tests; + /// This crate supports various magic comments that get parsed as file-specific /// configuration values. This struct parses them all in one go and then they /// get processed by their respective use sites. diff --git a/ui_test/tests/comment_parser.rs b/ui_test/src/comments/tests.rs similarity index 96% rename from ui_test/tests/comment_parser.rs rename to ui_test/src/comments/tests.rs index a9e19cbb9c5a..2bcaaa70a429 100644 --- a/ui_test/tests/comment_parser.rs +++ b/ui_test/src/comments/tests.rs @@ -1,6 +1,6 @@ use std::path::Path; -use ui_test::Comments; +use super::Comments; #[test] fn parse_simple_comment() { diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index ba1f874413d8..4a3014713b2a 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -12,6 +12,8 @@ use regex::Regex; pub use crate::comments::Comments; mod comments; +#[cfg(test)] +mod tests; #[derive(Debug)] pub struct Config { @@ -171,7 +173,7 @@ pub fn run_tests(config: Config) { } #[derive(Debug)] -pub enum Error { +enum Error { /// Got an invalid exit status for the given mode. ExitStatus(Mode, ExitStatus), PatternNotFound { @@ -191,7 +193,7 @@ pub enum Error { }, } -pub type Errors = Vec; +type Errors = Vec; fn run_test( path: &Path, @@ -249,7 +251,7 @@ fn run_test( (miri, errors) } -pub fn check_annotations( +fn check_annotations( unnormalized_stderr: &[u8], errors: &mut Errors, config: &Config, diff --git a/ui_test/tests/check_annotations.rs b/ui_test/src/tests.rs similarity index 95% rename from ui_test/tests/check_annotations.rs rename to ui_test/src/tests.rs index 4735fe1fa049..841f790b95b5 100644 --- a/ui_test/tests/check_annotations.rs +++ b/ui_test/src/tests.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use ui_test::{check_annotations, Comments, Config, Error, Mode, OutputConflictHandling}; +use super::{check_annotations, Comments, Config, Error, Mode, OutputConflictHandling}; fn config() -> Config { Config {