log_handler test: Ignore unknown categories

Tests run parallel in multiple threads. This makes the log_handler test
flaky because it may see log messages triggered by other threads. Make
the handler ignore all messages not in the category we care about.
This commit is contained in:
Jan Alexander Steffens (heftig) 2019-09-04 14:02:55 +02:00
parent 6488c42890
commit 8db9926107
No known key found for this signature in database
GPG key ID: DE5E0C5F25941CA5

View file

@ -457,7 +457,13 @@ mod tests {
_object: Option<&glib::Object>, _object: Option<&glib::Object>,
message: &DebugMessage| { message: &DebugMessage| {
let cat = DebugCategory::get("test-cat-log").unwrap(); let cat = DebugCategory::get("test-cat-log").unwrap();
assert_eq!(category, cat);
if category != cat {
// This test can run in parallel with other tests, including new_and_log above.
// We cannot be certain we only see our own messages.
return;
}
assert_eq!(level, DebugLevel::Info); assert_eq!(level, DebugLevel::Info);
assert_eq!(message.get(), Some("meh")); assert_eq!(message.get(), Some("meh"));
let _ = sender.lock().unwrap().send(()); let _ = sender.lock().unwrap().send(());