Add warning about multiple tests in one file am: 0c01919f91
Original change: https://android-review.googlesource.com/c/platform/system/logging/+/2939782
Change-Id: I751b1b3f8ebdcfd1d152abef8a974318a3f97bc5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/rust/tests/config_log_level.rs b/rust/tests/config_log_level.rs
index 111b86a..53970f9 100644
--- a/rust/tests/config_log_level.rs
+++ b/rust/tests/config_log_level.rs
@@ -1,3 +1,7 @@
+//! Do not put multiple tests in this file. Tests in the same file run in the
+//! same executable, so if there are several tests in one file, only one test
+//! will successfully be able to initialize the logger.
+
use std::env;
#[test]
diff --git a/rust/tests/config_log_level_deprecated.rs b/rust/tests/config_log_level_deprecated.rs
index 005aa11..8efd5c5 100644
--- a/rust/tests/config_log_level_deprecated.rs
+++ b/rust/tests/config_log_level_deprecated.rs
@@ -1,6 +1,10 @@
//! This is the old version of `config_log_level.rs` that uses the deprecated
//! `with_min_level` method. The test should be deleted when `with_min_level` is
//! fully removed.
+//!
+//! Do not put multiple tests in this file. Tests in the same file run in the
+//! same executable, so if there are several tests in one file, only one test
+//! will successfully be able to initialize the logger.
use std::env;
diff --git a/rust/tests/default_init.rs b/rust/tests/default_init.rs
index 837677c..d061b08 100644
--- a/rust/tests/default_init.rs
+++ b/rust/tests/default_init.rs
@@ -1,3 +1,7 @@
+//! Do not put multiple tests in this file. Tests in the same file run in the
+//! same executable, so if there are several tests in one file, only one test
+//! will successfully be able to initialize the logger.
+
#[test]
fn default_init() {
assert!(logger::init(Default::default()));
@@ -9,4 +13,4 @@
// env_logger has default log level "error"
assert_eq!(log::max_level(), log::LevelFilter::Error);
}
-}
\ No newline at end of file
+}
diff --git a/rust/tests/env_log_level.rs b/rust/tests/env_log_level.rs
index 0534be3..fcbfc4b 100644
--- a/rust/tests/env_log_level.rs
+++ b/rust/tests/env_log_level.rs
@@ -1,3 +1,7 @@
+//! Do not put multiple tests in this file. Tests in the same file run in the
+//! same executable, so if there are several tests in one file, only one test
+//! will successfully be able to initialize the logger.
+
use std::env;
#[test]
@@ -13,4 +17,4 @@
assert_eq!(log::max_level(), log::LevelFilter::Debug);
}
env::remove_var("RUST_LOG");
-}
\ No newline at end of file
+}
diff --git a/rust/tests/multiple_init.rs b/rust/tests/multiple_init.rs
index 7928dcf..d29593e 100644
--- a/rust/tests/multiple_init.rs
+++ b/rust/tests/multiple_init.rs
@@ -1,3 +1,7 @@
+//! Do not put multiple tests in this file. Tests in the same file run in the
+//! same executable, so if there are several tests in one file, only one test
+//! will successfully be able to initialize the logger.
+
#[test]
fn multiple_init() {
let first_init = logger::init(Default::default());
@@ -5,4 +9,4 @@
assert!(first_init);
assert!(!second_init);
-}
\ No newline at end of file
+}