From 9170bed9a4c8690fb0b95ae0a9f8608605e42073 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 6 Feb 2015 15:41:30 +0100 Subject: [PATCH] =?UTF-8?q?soft=20kill=20junit=20process=20(only=20*nix=20?= =?UTF-8?q?=E2=80=94=20win=20solution=20is=20not=20suitable=20for=20all=20?= =?UTF-8?q?users)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../execution/junit/JUnitProcessHandler.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java b/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java index fecd61436d39..ef77c1f54f1c 100644 --- a/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java +++ b/java/execution/impl/src/com/intellij/execution/junit/JUnitProcessHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,26 +18,24 @@ package com.intellij.execution.junit; import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.junit2.segments.Extractor; -import com.intellij.execution.process.OSProcessHandler; +import com.intellij.execution.process.KillableColoredProcessHandler; import com.intellij.execution.process.ProcessTerminatedListener; import org.jetbrains.annotations.NotNull; import java.io.Reader; -import java.nio.charset.Charset; /** * @author dyoma */ -public class JUnitProcessHandler extends OSProcessHandler { +public class JUnitProcessHandler extends KillableColoredProcessHandler { private final Extractor myOut; private final Extractor myErr; - private final Charset myCharset; - public JUnitProcessHandler(@NotNull Process process, final String commandLine, @NotNull Charset charset) { - super(process, commandLine); - myOut = new Extractor(getProcess().getInputStream(), charset); - myErr = new Extractor(getProcess().getErrorStream(), charset); - myCharset = charset; + public JUnitProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException { + super(commandLine); + + myOut = new Extractor(getProcess().getInputStream(), commandLine.getCharset()); + myErr = new Extractor(getProcess().getErrorStream(), commandLine.getCharset()); } @Override @@ -50,24 +48,20 @@ public class JUnitProcessHandler extends OSProcessHandler { return myErr.createReader(); } + @NotNull public Extractor getErr() { return myErr; } + @NotNull public Extractor getOut() { return myOut; } - @Override - public Charset getCharset() { - return myCharset; - } - - public static JUnitProcessHandler runCommandLine(final GeneralCommandLine commandLine) throws ExecutionException { - final JUnitProcessHandler processHandler = new JUnitProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), - commandLine.getCharset()); + @NotNull + public static JUnitProcessHandler runCommandLine(@NotNull GeneralCommandLine commandLine) throws ExecutionException { + final JUnitProcessHandler processHandler = new JUnitProcessHandler(commandLine); ProcessTerminatedListener.attach(processHandler); return processHandler; } - -} +} \ No newline at end of file