log details to fight blinking test
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 6 May 2016 10:16:21 +0000 (13:16 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 6 May 2016 10:16:21 +0000 (13:16 +0300)
platform/lang-impl/testSources/com/intellij/execution/impl/ExecutionManagerTest.java

index 7557f77a13ed1e5f9f21dfa3d9290dfa0ce20cee..b6032ee4363148041912bd940e26a274b068c593 100644 (file)
@@ -24,7 +24,9 @@ import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
 import com.intellij.execution.ui.RunContentDescriptor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Conditions;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.testFramework.LightPlatformTestCase;
+import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
@@ -91,15 +93,32 @@ public class ExecutionManagerTest extends LightPlatformTestCase {
   @NotNull
   private static FakeProcessHandler getProcessHandler(@NotNull ExecutionManagerImpl executionManager) {
     List<RunContentDescriptor> descriptors = executionManager.getRunningDescriptors(Conditions.alwaysTrue());
-    assertEquals(1, descriptors.size());
+    String actualDescriptorsMsg = stringifyDescriptors(descriptors);
+    assertEquals(actualDescriptorsMsg, 1, descriptors.size());
     RunContentDescriptor descriptor = ContainerUtil.getFirstItem(descriptors);
-    assertNotNull(descriptor);
+    assertNotNull(actualDescriptorsMsg, descriptor);
     ProcessHandler processHandler = descriptor.getProcessHandler();
-    assertNotNull(processHandler);
+    assertNotNull(actualDescriptorsMsg, processHandler);
     return (FakeProcessHandler)processHandler;
   }
 
   @NotNull
+  private static String stringifyDescriptors(@NotNull List<RunContentDescriptor> descriptors) {
+    return "Actual descriptors: " + StringUtil.join(descriptors, new Function<RunContentDescriptor, String>() {
+      @Override
+      public String fun(RunContentDescriptor descriptor) {
+        if (descriptor == null) {
+          return "null";
+        }
+        ProcessHandler processHandler = descriptor.getProcessHandler();
+        return String.format("[%s, %s]",
+                             descriptor.getDisplayName(),
+                             processHandler != null ? processHandler.getClass().getName() : null);
+      }
+    }, ", ");
+  }
+
+  @NotNull
   private static ExecutionEnvironment createEnv(@NotNull Project project, @NotNull RunnerAndConfigurationSettings settings) {
     return new ExecutionEnvironmentBuilder(project, DefaultRunExecutor.getRunExecutorInstance())
       .runnerAndSettings(FakeProgramRunner.INSTANCE, settings)