[groovy] tweak tests
authorDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Mon, 20 Jun 2016 13:00:32 +0000 (16:00 +0300)
committerDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Mon, 20 Jun 2016 13:05:40 +0000 (16:05 +0300)
plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/CompilerMethods.groovy
plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/DebuggerMethods.groovy
plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.groovy
plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy

index 401b920a1b4e1e17a45890b9b9aef37031d493e5..31fa8803063615ae503b97b8d26dd645e9395cd7 100644 (file)
@@ -26,7 +26,6 @@ import com.intellij.execution.runners.ProgramRunner
 import com.intellij.execution.ui.RunContentDescriptor
 import com.intellij.openapi.Disposable
 import com.intellij.openapi.project.Project
-import com.intellij.openapi.util.Disposer
 import com.intellij.util.concurrency.Semaphore
 import groovy.transform.CompileStatic
 
@@ -37,29 +36,32 @@ trait CompilerMethods {
 
   abstract Project getProject()
 
-  abstract <T extends Disposable> T disposeOnTearDown(T disposable)
+  abstract Disposable disposeOnTearDown(Disposable disposable)
 
   ProcessHandler runConfiguration(Class<? extends Executor> executorClass,
                                   final ProcessListener listener,
-                                  ProgramRunner runner,
-                                  RunProfile configuration) throws ExecutionException {
+                                  RunProfile configuration,
+                                  ProgramRunner runner = null) throws ExecutionException {
     final Executor executor = Executor.EXECUTOR_EXTENSION_NAME.findExtension(executorClass);
-    final ExecutionEnvironment environment = new ExecutionEnvironmentBuilder(getProject(), executor).runProfile(configuration).build();
+    def builder = new ExecutionEnvironmentBuilder(getProject(), executor).runProfile(configuration)
+    if (runner) builder.runner(runner)
+
+    final ExecutionEnvironment environment = builder.build();
     final Semaphore semaphore = new Semaphore();
     semaphore.down();
 
     final AtomicReference<ProcessHandler> processHandler = new AtomicReference<ProcessHandler>();
-    runner.execute(environment, { RunContentDescriptor descriptor ->
+    environment.runner.execute(environment) { RunContentDescriptor descriptor ->
       if (descriptor == null) {
         throw new AssertionError((Object)"Null descriptor!");
       }
-      disposeOnTearDown({ Disposer.dispose(descriptor) } as Disposable);
+      disposeOnTearDown descriptor
       final ProcessHandler handler = descriptor.getProcessHandler();
       assert handler != null;
       handler.addProcessListener(listener);
       processHandler.set(handler);
       semaphore.up();
-    });
+    }
     if (!semaphore.waitFor(20000)) {
       throw new AssertionError((Object)"Process took too long")
     }
index 9854aa33928c49c1a17d7c0812d561356368d196..06dcb4d658347df9a5099750bb8e7b334e249cc3 100644 (file)
@@ -26,13 +26,15 @@ import com.intellij.debugger.engine.evaluation.EvaluateException
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
 import com.intellij.debugger.engine.evaluation.TextWithImportsImpl
 import com.intellij.debugger.engine.events.DebuggerContextCommandImpl
-import com.intellij.debugger.impl.*
+import com.intellij.debugger.impl.DebuggerContextImpl
+import com.intellij.debugger.impl.DebuggerContextUtil
+import com.intellij.debugger.impl.DebuggerManagerImpl
+import com.intellij.debugger.impl.DebuggerSession
 import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor
 import com.intellij.debugger.ui.tree.render.DescriptorLabelListener
 import com.intellij.execution.configurations.RunProfile
 import com.intellij.execution.executors.DefaultDebugExecutor
 import com.intellij.execution.process.*
-import com.intellij.execution.runners.ProgramRunner
 import com.intellij.openapi.application.ApplicationManager
 import com.intellij.openapi.diagnostic.Logger
 import com.intellij.openapi.fileEditor.FileDocumentManager
@@ -64,13 +66,12 @@ trait DebuggerMethods extends CompilerMethods {
 
   void runDebugger(RunProfile configuration, Closure cl) {
     edt {
-      ProgramRunner runner = ProgramRunner.PROGRAM_RUNNER_EP.extensions.find { it.class == GenericDebuggerRunner }
       def listener = [onTextAvailable: { ProcessEvent evt, type ->
         if (type == ProcessOutputTypes.STDERR) {
           println evt.text
         }
       }] as ProcessAdapter
-      runConfiguration(DefaultDebugExecutor, listener, runner, configuration);
+      runConfiguration(DefaultDebugExecutor, listener, configuration)
     }
     logger.debug("after start")
     try {
index 808a8c5ebbe2070238a65d0eb1fa47f162a1f186..47052f588b944c22ce0274c3120b667db8f440d3 100644 (file)
@@ -71,7 +71,7 @@ public abstract class GroovyCompilerTestCase extends JavaCodeInsightFixtureTestC
   }
 
   @Override
-  <T extends Disposable> T disposeOnTearDown(T disposable) {
+  Disposable disposeOnTearDown(Disposable disposable) {
     return super.disposeOnTearDown(disposable)
   }
 
@@ -230,9 +230,10 @@ public abstract class GroovyCompilerTestCase extends JavaCodeInsightFixtureTestC
   protected ProcessHandler runProcess(String className,
                                       Module module,
                                       final Class<? extends Executor> executorClass,
-                                      final ProcessListener listener, final ProgramRunner runner) throws ExecutionException {
+                                      final ProcessListener listener,
+                                      final ProgramRunner runner) throws ExecutionException {
     final ApplicationConfiguration configuration = createApplicationConfiguration(className, module);
-    return runConfiguration(executorClass, listener, runner, configuration);
+    return runConfiguration(executorClass, listener, configuration, runner);
   }
 
   protected ApplicationConfiguration createApplicationConfiguration(String className, Module module) {
index c5c0ef00bcfec130436436796b944024b2ef4f5c..f493a3eb57c6fbce1eff2eb39bcea5a7459bc92d 100644 (file)
@@ -77,11 +77,6 @@ class GroovyDebuggerTest extends GroovyCompilerTestCase implements DebuggerMetho
     }
   }
 
-  @Override
-  protected void tearDown() {
-    super.tearDown()
-  }
-
   @Override
   protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) {
     super.tuneFixture(moduleBuilder)