Improve test logging: add process name to log (dotnet/corefx#35996)
authorMarco Rossignoli <marco.rossignoli@gmail.com>
Thu, 14 Mar 2019 21:19:27 +0000 (22:19 +0100)
committerStephen Toub <stoub@microsoft.com>
Thu, 14 Mar 2019 21:19:27 +0000 (17:19 -0400)
* add process name to log

* updates

* update

Commit migrated from https://github.com/dotnet/corefx/commit/88548f58fbd9a5c421395b0f6a4a1eed4be4f155

src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs

index b46b8bfc59f4260529da95a0d7c845f37a763133..d7994ed876790d85e97126d9142e3d2989c55a31 100644 (file)
@@ -1080,14 +1080,14 @@ namespace System.Diagnostics.Tests
             }
             catch (NotEmptyException)
             {
-                throw new TrueException(PrintProcesses(), false);
+                throw new TrueException(PrintProcesses(currentProcess), false);
             }
 
             Assert.All(processes, process => Assert.Equal(".", process.MachineName));
             return;
 
             // Outputs a list of active processes in case of failure: https://github.com/dotnet/corefx/issues/35783
-            string PrintProcesses()
+            string PrintProcesses(Process currentProcess)
             {
                 StringBuilder builder = new StringBuilder();
                 foreach (Process process in Process.GetProcesses())
@@ -1104,7 +1104,7 @@ namespace System.Diagnostics.Tests
                     builder.AppendLine();
                 }
                 
-                builder.AppendFormat("Current process id: {0}", Process.GetCurrentProcess().Id);
+                builder.AppendFormat("Current process id: {0} Process name: '{1}'", currentProcess.Id, currentProcess.ProcessName);
                 return builder.ToString();
             }
         }