]>
git.proxmox.com Git - rustc.git/blob - vendor/env_logger-0.6.2/tests/regexp_filter.rs
1 #[macro_use] extern crate log;
2 extern crate env_logger
;
9 if env
::var("LOG_REGEXP_TEST").ok() == Some(String
::from("1")) {
21 fn run_child(rust_log
: String
) -> bool
{
22 let exe
= env
::current_exe().unwrap();
23 let out
= process
::Command
::new(exe
)
24 .env("LOG_REGEXP_TEST", "1")
25 .env("RUST_LOG", rust_log
)
27 .unwrap_or_else(|e
| panic
!("Unable to start child process: {}", e
));
28 str::from_utf8(out
.stderr
.as_ref()).unwrap().contains("XYZ Message")
31 fn assert_message_printed(rust_log
: &str) {
32 if !run_child(rust_log
.to_string()) {
33 panic
!("RUST_LOG={} should allow the test log message", rust_log
)
37 fn assert_message_not_printed(rust_log
: &str) {
38 if run_child(rust_log
.to_string()) {
39 panic
!("RUST_LOG={} should not allow the test log message", rust_log
)
44 // test normal log severity levels
45 assert_message_printed("info");
46 assert_message_not_printed("warn");
48 // test of regular expression filters
49 assert_message_printed("info/XYZ");
50 assert_message_not_printed("info/XXX");