From 8a3fa27d8f9369418820899f8fb1f0ee52d1dc88 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 16 May 2019 17:31:47 -0700 Subject: [PATCH] Fix ListenerWithFilter test (dotnet/corefx#37731) It's searching the output to ensure the id doesn't get written out, so it can't match other IDs that are written out. Commit migrated from https://github.com/dotnet/corefx/commit/05233fd0c0200f1fda258bab148bbae28592892d --- .../tests/XmlWriterTraceListenerTests.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs index e00f083..b883568 100644 --- a/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs +++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/tests/XmlWriterTraceListenerTests.cs @@ -103,15 +103,16 @@ namespace System.Diagnostics.TextWriterTraceListenerTests [Fact] public void ListenerWithFilter() { - int processId; + // Ensure we use an arbitrary ID that doesn't match the process ID or thread ID. + int traceTransferId = 1; using (Process p = Process.GetCurrentProcess()) { - processId = p.Id; + while (traceTransferId == p.Id || traceTransferId == Environment.CurrentManagedThreadId) + { + traceTransferId++; + } } - // Ensure we use an arbitrary ID that doesn't match the process ID. - int traceTransferId = processId + 1; - string file = GetTestFilePath(); Guid guid = Guid.NewGuid(); using (var listener = new XmlWriterTraceListener(file)) -- 2.7.4