mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove old test protocols
This commit is contained in:
@@ -23,6 +23,7 @@ import com.intellij.execution.process.OSProcessHandler;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.testDiscovery.JavaAutoRunManager;
|
||||
import com.intellij.execution.testframework.*;
|
||||
import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction;
|
||||
@@ -48,7 +49,6 @@ import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
@@ -122,12 +122,9 @@ public abstract class JavaTestFrameworkRunnableState<T extends
|
||||
return module != null;
|
||||
}
|
||||
|
||||
protected ExecutionResult startSMRunner(Executor executor) throws ExecutionException {
|
||||
if (!isSmRunnerUsed()) {
|
||||
return null;
|
||||
}
|
||||
getJavaParameters().getVMParametersList().addProperty("idea." + getFrameworkId() + ".sm_runner");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
|
||||
final RunnerSettings runnerSettings = getRunnerSettings();
|
||||
|
||||
final SMTRunnerConsoleProperties testConsoleProperties = getConfiguration().createTestConsoleProperties(executor);
|
||||
@@ -138,7 +135,7 @@ public abstract class JavaTestFrameworkRunnableState<T extends
|
||||
Disposer.register(getConfiguration().getProject(), consoleView);
|
||||
|
||||
final OSProcessHandler handler = createHandler(executor);
|
||||
|
||||
|
||||
consoleView.attachToProcess(handler);
|
||||
final AbstractTestProxy root = viewer.getRoot();
|
||||
if (root instanceof TestProxyRoot) {
|
||||
@@ -180,10 +177,6 @@ public abstract class JavaTestFrameworkRunnableState<T extends
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean isSmRunnerUsed() {
|
||||
return Registry.is(getFrameworkId() + "_sm");
|
||||
}
|
||||
|
||||
protected abstract void configureRTClasspath(JavaParameters javaParameters);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
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.KillableColoredProcessHandler;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessTerminatedListener;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.util.io.BaseOutputReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
*/
|
||||
public class JUnitProcessHandler extends KillableColoredProcessHandler {
|
||||
private final Extractor myOut;
|
||||
private final Extractor myErr;
|
||||
|
||||
private JUnitProcessHandler(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
|
||||
super(commandLine);
|
||||
|
||||
myOut = new Extractor(getProcess().getInputStream(), commandLine.getCharset());
|
||||
myErr = new Extractor(getProcess().getErrorStream(), commandLine.getCharset());
|
||||
addProcessListener(new ProcessAdapter(){
|
||||
@Override
|
||||
public void processTerminated(ProcessEvent event) {
|
||||
Disposer.dispose(myOut);
|
||||
Disposer.dispose(myErr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Reader createProcessOutReader() {
|
||||
return myOut.createReader();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Reader createProcessErrReader() {
|
||||
return myErr.createReader();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Extractor getErr() {
|
||||
return myErr;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Extractor getOut() {
|
||||
return myOut;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JUnitProcessHandler runCommandLine(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
|
||||
final JUnitProcessHandler processHandler = new JUnitProcessHandler(commandLine);
|
||||
ProcessTerminatedListener.attach(processHandler);
|
||||
return processHandler;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected BaseOutputReader.Options readerOptions() {
|
||||
return BaseOutputReader.Options.NON_BLOCKING;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit;
|
||||
|
||||
import com.intellij.execution.junit2.SegmentedInputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Apr 25, 2007
|
||||
*/
|
||||
public class SegmentedInputStreamReader extends Reader {
|
||||
private final SegmentedInputStream myStream;
|
||||
|
||||
public SegmentedInputStreamReader(SegmentedInputStream stream) {
|
||||
myStream = stream;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
myStream.close();
|
||||
}
|
||||
|
||||
public boolean ready() throws IOException {
|
||||
return myStream.available() > 0;
|
||||
}
|
||||
|
||||
public int read(final char[] cbuf, final int off, final int len) throws IOException {
|
||||
int bytesRead = 0;
|
||||
while (ready() && bytesRead < len) {
|
||||
final int aChar = myStream.read();
|
||||
if (aChar == -1) {
|
||||
return bytesRead == 0 ? -1 : bytesRead;
|
||||
}
|
||||
cbuf[off + (bytesRead++)] = (char)aChar;
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2;
|
||||
|
||||
import gnu.trove.TIntArrayList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
*/
|
||||
public class PushReader {
|
||||
private final Reader mySource;
|
||||
private final TIntArrayList myReadAhead = new TIntArrayList();
|
||||
@NonNls
|
||||
protected static final String INTERNAL_ERROR_UNEXPECTED_END_OF_PIPE = "Unexpected end of pipe";
|
||||
|
||||
public PushReader(final Reader source) {
|
||||
mySource = source;
|
||||
}
|
||||
|
||||
public int next() throws IOException {
|
||||
return myReadAhead.isEmpty() ? mySource.read() : myReadAhead.remove(myReadAhead.size() - 1);
|
||||
}
|
||||
|
||||
public void pushBack(final char[] chars) {
|
||||
for (int i = chars.length - 1; i >= 0; i--) {
|
||||
final char aChar = chars[i];
|
||||
myReadAhead.add(aChar);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
mySource.close();
|
||||
}
|
||||
|
||||
public boolean ready() throws IOException {
|
||||
return !myReadAhead.isEmpty() || mySource.ready();
|
||||
}
|
||||
|
||||
public void pushBack(final int aChar) {
|
||||
myReadAhead.add(aChar);
|
||||
}
|
||||
|
||||
public char[] next(final int charCount) throws IOException {
|
||||
final char[] chars = new char[charCount];
|
||||
int offset = 0;
|
||||
for (; offset < chars.length && offset < myReadAhead.size(); offset++)
|
||||
chars[offset] = (char)myReadAhead.remove(myReadAhead.size() - 1);
|
||||
|
||||
while (offset < chars.length) {
|
||||
int bytesRead = mySource.read(chars, offset, chars.length - offset);
|
||||
if (bytesRead == -1)
|
||||
throw new IOException (INTERNAL_ERROR_UNEXPECTED_END_OF_PIPE);
|
||||
offset += bytesRead;
|
||||
}
|
||||
|
||||
return chars;
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.Packet;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
import com.intellij.rt.execution.junit.segments.SegmentedStream;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class SegmentedInputStream extends InputStream {
|
||||
private final PushReader mySourceStream;
|
||||
private PacketProcessor myEventsDispatcher;
|
||||
private int myStartupPassed = 0;
|
||||
|
||||
public SegmentedInputStream(@NotNull InputStream sourceStream, @NotNull Charset charset) {
|
||||
mySourceStream = new PushReader(new BufferedReader(new InputStreamReader(sourceStream, charset)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (myStartupPassed < SegmentedStream.STARTUP_MESSAGE.length()) {
|
||||
return rawRead();
|
||||
} else {
|
||||
return findNextSymbol();
|
||||
}
|
||||
}
|
||||
|
||||
private int rawRead() throws IOException {
|
||||
while(myStartupPassed < SegmentedStream.STARTUP_MESSAGE.length()) {
|
||||
final int aChar = readNext();
|
||||
if (aChar != SegmentedStream.STARTUP_MESSAGE.charAt(myStartupPassed)) {
|
||||
mySourceStream.pushBack(aChar);
|
||||
mySourceStream.pushBack(SegmentedStream.STARTUP_MESSAGE.substring(0, myStartupPassed).toCharArray());
|
||||
myStartupPassed = 0;
|
||||
return readNext();
|
||||
}
|
||||
myStartupPassed++;
|
||||
}
|
||||
return read();
|
||||
}
|
||||
|
||||
private int findNextSymbol() throws IOException {
|
||||
int nextByte;
|
||||
while (true) {
|
||||
nextByte = readNext();
|
||||
if (nextByte != SegmentedStream.SPECIAL_SYMBOL) break;
|
||||
final Integer packetRead = readControlSequence();
|
||||
if (packetRead != null) break;
|
||||
if (available() == 0) return -1;
|
||||
}
|
||||
return nextByte;
|
||||
}
|
||||
|
||||
private Integer readControlSequence() throws IOException {
|
||||
for (int idx = 1; idx < SegmentedStream.MARKER_PREFIX.length(); idx++) {
|
||||
final int readAhead = readNext();
|
||||
if (readAhead != SegmentedStream.MARKER_PREFIX.charAt(idx)) {
|
||||
return readAhead;
|
||||
}
|
||||
}
|
||||
final char[] marker = readMarker();
|
||||
if(myEventsDispatcher != null) myEventsDispatcher.processPacket(decode(marker));
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEventsDispatcher(final PacketProcessor eventsDispatcher) {
|
||||
myEventsDispatcher = eventsDispatcher;
|
||||
}
|
||||
|
||||
private char[] readMarker() throws IOException {
|
||||
final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
|
||||
try {
|
||||
int nextRead = '0';
|
||||
while (nextRead != ' ' && nextRead != SegmentedStream.SPECIAL_SYMBOL) {
|
||||
buffer.append((char)nextRead);
|
||||
nextRead = readNext();
|
||||
if (nextRead == -1) return new char[0];
|
||||
}
|
||||
return readNext(Integer.valueOf(buffer.toString()).intValue());
|
||||
}
|
||||
finally {
|
||||
StringBuilderSpinAllocator.dispose(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
private char[] readNext(final int charCount) throws IOException {
|
||||
return mySourceStream.next(charCount);
|
||||
}
|
||||
|
||||
private int readNext() throws IOException {
|
||||
return mySourceStream.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return mySourceStream.ready() ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
mySourceStream.close();
|
||||
}
|
||||
|
||||
public static String decode(final char[] chars) {
|
||||
final StringBuilder buffer = StringBuilderSpinAllocator.alloc();
|
||||
try {
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char chr = chars[i];
|
||||
final char decodedChar;
|
||||
if (chr == Packet.ourSpecialSymbol) {
|
||||
i++;
|
||||
chr = chars[i];
|
||||
if (chr != Packet.ourSpecialSymbol) {
|
||||
final StringBuilder codeBuffer = new StringBuilder(Packet.CODE_LENGTH);
|
||||
codeBuffer.append(chr);
|
||||
for (int j = 1; j < Packet.CODE_LENGTH; j++) {
|
||||
codeBuffer.append(chars[i + j]);
|
||||
}
|
||||
i += Packet.CODE_LENGTH - 1;
|
||||
decodedChar = (char)Integer.parseInt(codeBuffer.toString());
|
||||
}
|
||||
else decodedChar = chr;
|
||||
} else decodedChar = chr;
|
||||
buffer.append(decodedChar);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
finally {
|
||||
StringBuilderSpinAllocator.dispose(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
public interface DeferredActionsQueue {
|
||||
void addLast(Runnable runnable);
|
||||
|
||||
void setDispactchListener(DispatchListener listener);
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class DeferredActionsQueueImpl implements DeferredActionsQueue {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.segments.DeferedActionsQueueImpl");
|
||||
private DispatchListener myListener = DispatchListener.DEAF;
|
||||
private int myCounter = 0;
|
||||
|
||||
public void addLast(final Runnable runnable) {
|
||||
checkIsDispatchThread();
|
||||
myListener.onStarted();
|
||||
try {
|
||||
runnable.run();
|
||||
} finally{
|
||||
myListener.onFinished();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIsDispatchThread() {
|
||||
myCounter++;
|
||||
if (myCounter > 127) {
|
||||
myCounter = 0;
|
||||
LOG.assertTrue(EventQueue.isDispatchThread());
|
||||
}
|
||||
}
|
||||
|
||||
public void setDispactchListener(final DispatchListener listener) {
|
||||
myListener = listener;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
public interface DispatchListener {
|
||||
void onStarted();
|
||||
void onFinished();
|
||||
|
||||
DispatchListener DEAF = new DispatchListener() {
|
||||
public void onStarted() {
|
||||
}
|
||||
|
||||
public void onFinished() {
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
import com.intellij.execution.junit.SegmentedInputStreamReader;
|
||||
import com.intellij.execution.junit2.SegmentedInputStream;
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.EmptyRunnable;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
import com.intellij.util.concurrency.SequentialTaskExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
*/
|
||||
public class Extractor implements Disposable {
|
||||
private static final int MAX_TASKS_TO_PROCESS_AT_ONCE = 100;
|
||||
|
||||
private DeferredActionsQueue myFulfilledWorkGate = null;
|
||||
private final SegmentedInputStream myStream;
|
||||
private OutputPacketProcessor myEventsDispatcher;
|
||||
private static final Logger LOG = Logger.getInstance("#" + Extractor.class.getName());
|
||||
private final ExecutorService myExecutor = SequentialTaskExecutor.createSequentialApplicationPoolExecutor();
|
||||
private final BlockingQueue<Runnable> myTaskQueue = new LinkedBlockingQueue<Runnable>();
|
||||
|
||||
public Extractor(@NotNull InputStream stream, @NotNull Charset charset) {
|
||||
myStream = new SegmentedInputStream(stream, charset);
|
||||
}
|
||||
|
||||
public void setDispatchListener(final DispatchListener listener) {
|
||||
myFulfilledWorkGate.setDispactchListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// wait until all our submitted tasks are executed
|
||||
try {
|
||||
myExecutor.submit(EmptyRunnable.getInstance()).get();
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public void setPacketDispatcher(@NotNull final PacketProcessor packetProcessor, final DeferredActionsQueue queue) {
|
||||
myFulfilledWorkGate = new DeferredActionsQueue() { //todo make it all later
|
||||
@Override
|
||||
public void addLast(final Runnable runnable) {
|
||||
scheduleTask(queue, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDispactchListener(final DispatchListener listener) {
|
||||
queue.setDispactchListener(listener);
|
||||
}
|
||||
};
|
||||
myEventsDispatcher = new OutputPacketProcessor() {
|
||||
@Override
|
||||
public void processPacket(final String packet) {
|
||||
myFulfilledWorkGate.addLast(() -> packetProcessor.processPacket(packet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOutput(final Printable printable) {
|
||||
LOG.assertTrue(packetProcessor instanceof OutputPacketProcessor);
|
||||
myFulfilledWorkGate.addLast(() -> ((OutputPacketProcessor)packetProcessor).processOutput(printable));
|
||||
}
|
||||
};
|
||||
myStream.setEventsDispatcher(myEventsDispatcher);
|
||||
}
|
||||
|
||||
private void scheduleTask(final DeferredActionsQueue queue, final Runnable task) {
|
||||
myTaskQueue.add(task);
|
||||
myExecutor.execute(() -> {
|
||||
final List<Runnable> currentTasks = new ArrayList<Runnable>(MAX_TASKS_TO_PROCESS_AT_ONCE);
|
||||
if (myTaskQueue.drainTo(currentTasks, MAX_TASKS_TO_PROCESS_AT_ONCE) > 0) {
|
||||
// there is a requirement that these activities must be run from the swing thread
|
||||
// will be blocking one of pooled threads here, which is ok
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
for (Runnable task1 : currentTasks) {
|
||||
try {
|
||||
queue.addLast(task1);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.info("Task rejected: " + currentTasks, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public OutputPacketProcessor getEventsDispatcher() {
|
||||
return myEventsDispatcher;
|
||||
}
|
||||
|
||||
public Reader createReader() {
|
||||
return new SegmentedInputStreamReader(myStream);
|
||||
}
|
||||
|
||||
public void addRequest(final Runnable runnable, final DeferredActionsQueue queue) {
|
||||
scheduleTask(queue, runnable);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
|
||||
public interface InputConsumer {
|
||||
InputConsumer DEAF = new InputConsumer() {
|
||||
public void onOutput(String text, ConsoleViewContentType contentType) {}
|
||||
};
|
||||
void onOutput(String text, ConsoleViewContentType contentType);
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 12/6/10
|
||||
*/
|
||||
public interface OutputPacketProcessor extends PacketProcessor{
|
||||
void processOutput(Printable printable);
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.junit2.segments;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.PoolOfDelimiters;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SegmentReader {
|
||||
private final String myString;
|
||||
private final char[] myChars;
|
||||
private int myPosition = 0;
|
||||
|
||||
public SegmentReader(final String packet) {
|
||||
myString = packet;
|
||||
myChars = packet.toCharArray();
|
||||
}
|
||||
|
||||
public String upTo(final char symbol) {
|
||||
int position = myPosition;
|
||||
while (position < myChars.length && myChars[position] != symbol) position++;
|
||||
final String result = advanceTo(position);
|
||||
skip(1);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void skip(final int count) {
|
||||
myPosition = Math.min(myChars.length, myPosition + count);
|
||||
}
|
||||
|
||||
public String upToEnd() {
|
||||
return advanceTo(myChars.length);
|
||||
}
|
||||
|
||||
private String advanceTo(final int position) {
|
||||
final String result = myString.substring(myPosition, position);
|
||||
myPosition = position;
|
||||
return result;
|
||||
}
|
||||
|
||||
public String readLimitedString() {
|
||||
final int symbolCount = readInt();
|
||||
return advanceTo(myPosition + symbolCount);
|
||||
}
|
||||
|
||||
public int readInt() {
|
||||
final String intString = upTo(PoolOfDelimiters.INTEGER_DELIMITER);
|
||||
return Integer.parseInt(intString);
|
||||
}
|
||||
|
||||
public long readLong() {
|
||||
final String longString = upTo(PoolOfDelimiters.INTEGER_DELIMITER);
|
||||
return Long.parseLong(longString);
|
||||
}
|
||||
|
||||
public char readChar() {
|
||||
myPosition++;
|
||||
return myChars[myPosition - 1];
|
||||
}
|
||||
|
||||
public boolean isAtEnd() {
|
||||
return myPosition == myChars.length;
|
||||
}
|
||||
|
||||
public String[] readStringArray() {
|
||||
final int count = readInt();
|
||||
if (count == 0) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
final ArrayList<String> strings = new ArrayList<String>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
strings.add(readLimitedString());
|
||||
}
|
||||
return strings.toArray(new String[count]);
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -22,11 +22,13 @@ import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -131,7 +133,6 @@ public abstract class SearchForTestsTask extends Task.Backgroundable {
|
||||
DumbService.getInstance(getProject()).runWhenSmart(() -> {
|
||||
onFound();
|
||||
finish();
|
||||
startListening();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -163,6 +164,4 @@ public abstract class SearchForTestsTask extends Task.Backgroundable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void startListening() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user