Skip to content

Commit

Permalink
Исправление по зависшим сеансам YAxUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
alkoleft committed Mar 27, 2024
1 parent 6e58d0b commit 1a7feb2
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public void stop() {
DebugPlugin.getDefault().removeDebugEventListener(monitor);
}

public void removeTerminated() {
public void removeTerminated(LifecycleItem reserved) {
var removed = new HashSet<ILaunch>();
var manager = DebugPlugin.getDefault().getLaunchManager();
var elements = manager.getLaunches();

for (var launch : elements) {
if (launch.isTerminated() && LaunchHelper.isRunTestConfiguration(launch.getLaunchConfiguration())) {
removed.add(launch);
Expand All @@ -76,6 +77,8 @@ public void removeTerminated() {
if (!item.isActive()) {
removed.add(item.getMainLaunch());
removed.add(item.getTestLaunch());
} else if (item != reserved && item.getMainLaunch() == null) {
removed.add(item.getTestLaunch());
}
}

Expand All @@ -87,8 +90,8 @@ public void removeTerminated() {
}
}

private void debug(String message) {
TestViewerPlugin.log().debug(message);
private void debug(String template, Object... objects) {
TestViewerPlugin.log().debug(template, objects);
}

private void riseEvent(int eventType, LifecycleItem item) {
Expand All @@ -106,7 +109,7 @@ private void riseEvent(int eventType, LifecycleItem item) {
private void onItemStart(LifecycleItem item) {
item.onStart();
riseEvent(LifecycleEvent.START, item);
removeTerminated();
removeTerminated(item);
}

private void onItemStop(LifecycleItem item, int eventType) {
Expand All @@ -121,19 +124,23 @@ private static class LaunchMonitor implements ILaunchListener, IDebugEventSetLis
@Override
public void handleDebugEvents(DebugEvent[] events) {
for (var event : events) {
debug("handleDebugEvents " + event.toString());
if (event.getKind() != DebugEvent.TERMINATE || !(event.getSource() instanceof IProcess)) {
if (event.getSource() == null) {
TestViewerPlugin.log().warning("Event source is empty {0}", event);
continue;
} else if (event.getKind() != DebugEvent.TERMINATE || !(event.getSource() instanceof IProcess)) {
continue;
}
var process = (IProcess) event.getSource();
var launch = process.getLaunch();
debug("handleDebugEvents {0}", event);

lock.lock();
try {
if (monitoringItems.containsKey(launch)) {
var item = monitoringItems.get(launch);
handleProcesses(item);
if (item.isActive()) {
debug("Finish " + item.getName());
debug("Finish {0}", item.getName());
onTerminate(item, process);
}
}
Expand All @@ -152,7 +159,7 @@ public void launchRemoved(ILaunch launch) {
var item = monitoringItems.get(launch);
handleProcesses(item);
if (item.isActive()) {
debug("canceled " + item.getName());
debug("canceled {0}", item.getName());
onItemStop(item, LifecycleEvent.CANCELED);
}
}
Expand All @@ -173,7 +180,8 @@ public void launchAdded(ILaunch launch) {
} else if (LaunchHelper.isOnecConfiguration(configuration) && !Strings.isNullOrEmpty(LaunchConfigurationAttributes.getTestKind(configuration))) {
var name = configuration.getName();
for (var item : monitoringItems.values()) {
if (name.contains(item.getName())) {
if (name.contains(item.getName()) && item.getMainLaunch() == null) {
debug("Attach 1C launch for {0}", item.getTestLaunch());
item.setMainLaunch(launch);
handleProcesses(item);
monitoringItems.put(launch, item);
Expand All @@ -196,13 +204,12 @@ private void handleProcesses(LifecycleItem item) {
if (item.getMainLaunch() == null) {
return;
}
if (item.getTestLaunch().getProcesses().length < item.getMainLaunch().getProcesses().length) {
var processes = new HashSet<>(List.of(item.getTestLaunch().getProcesses()));

var processes = new HashSet<>(List.of(item.getTestLaunch().getProcesses()));
for (var process : item.getMainLaunch().getProcesses()) {
if (!processes.contains(process)) {
item.getTestLaunch().addProcess(process);
}
}
}
}

Expand Down

0 comments on commit 1a7feb2

Please sign in to comment.