Skip to content

Commit

Permalink
Merge branch 'release/23.04.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
alkoleft committed May 4, 2023
2 parents 6e158f0 + e99a673 commit eb9129d
Show file tree
Hide file tree
Showing 28 changed files with 418 additions and 346 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "ru.biatech.edt.xtest"
version = "23.4.0"
version = "23.4.1"
val vendor = "BIA-Technologies Limited Liability Company"
val createProjectYear = 2021
val licenseYear = if (Calendar.getInstance().get(Calendar.YEAR) == createProjectYear) "$createProjectYear"
Expand Down
4 changes: 2 additions & 2 deletions templates/eclipse_project/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>bom</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>BOM</name>
Expand Down Expand Up @@ -86,7 +86,7 @@
<artifact>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>default</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</artifact>
</target>
<dependency-resolution>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/bundles/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>parent</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>bundles</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/features/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<feature
id="ru.biatech.edt.xtest.feature"
label="Запуск модульных тестов"
version="23.4.0.qualifier"
version="23.4.1.qualifier"
provider-name="BIA-Technologies Limited Liability Company">

<description>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/features/feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>features</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>ru.biatech.edt.xtest.feature</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/features/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>parent</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>features</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>bom</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
<relativePath>bom/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/repositories/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>parent</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>repositories</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/repositories/repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>repositories</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>repository</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/targets/default/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>targets</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>default</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/targets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>parent</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>targets</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion templates/eclipse_project/update-site/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>parent</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>

<artifactId>update-site</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions viewer/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: ru.biatech.edt.junit;singleton:=true
Automatic-Module-Name: ru.biatech.edt.junit
Bundle-Version: 23.4.0.qualifier
Bundle-Version: 23.4.1.qualifier
Bundle-Activator: ru.biatech.edt.junit.TestViewerPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand All @@ -30,14 +30,14 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
org.apache.commons.lang3,
com._1c.g5.v8.dt.bsl.core;bundle-version="6.0.300",
org.eclipse.handly;bundle-version="1.5.0",
com._1c.g5.v8.dt.lcore;bundle-version="3.1.900"
com._1c.g5.v8.dt.lcore;bundle-version="3.1.900",
com.google.gson
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: com._1c.g5.v8.dt.bm.index.emf,
com._1c.g5.v8.dt.bsl.model,
com._1c.g5.v8.dt.stacktraces.model,
com._1c.g5.wiring,
com.google.common.base,
com.google.gson;version="2.8.2",
javax.xml.parsers,
lombok;resolution:=optional,
lombok.experimental;resolution:=optional,
Expand Down
2 changes: 1 addition & 1 deletion viewer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>ru.biatech.edt.xtest</groupId>
<artifactId>bundles</artifactId>
<version>23.4.0-SNAPSHOT</version>
<version>23.4.1-SNAPSHOT</version>
</parent>
<artifactId>ru.biatech.edt.junit</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2023 BIA-Technologies Limited Liability Company.
*
* 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 ru.biatech.edt.junit.launcher.lifecycle;

import lombok.Getter;
import lombok.Setter;
import org.eclipse.debug.core.ILaunch;

import java.time.Instant;

@Getter
public class LifecycleItem {
private final ILaunch testLaunch;
@Setter
private ILaunch mainLaunch;
private final String name;
private boolean active = true;
private Instant start;
private Instant end;

public LifecycleItem(ILaunch testLaunch, String name) {
this.testLaunch = testLaunch;
this.name = name;
}

public void onStop() {
active = true;
end = Instant.now();
}

public void onStart() {
active = true;
start = Instant.now();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
import org.eclipse.debug.core.ILaunch;

public interface LifecycleListener {
void handle(int eventType, ILaunch launch);
void handle(int eventType, LifecycleItem item);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package ru.biatech.edt.junit.launcher.lifecycle;

import com.google.common.base.Strings;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import org.eclipse.debug.core.DebugEvent;
Expand All @@ -32,7 +31,6 @@
import ru.biatech.edt.junit.launcher.v8.LaunchHelper;
import ru.biatech.edt.junit.ui.JUnitMessages;

import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -76,8 +74,8 @@ public void removeTerminated() {

for (var item : monitor.monitoringItems.values()) {
if (!item.isActive()) {
removed.add(item.mainLaunch);
removed.add(item.testLaunch);
removed.add(item.getMainLaunch());
removed.add(item.getTestLaunch());
}
}

Expand All @@ -93,34 +91,32 @@ private void debug(String message) {
TestViewerPlugin.log().debug(message);
}

private void riseEvent(int eventType, MonitoringItem item) {
TestViewerPlugin.log().debug("Launch event: {0} for {1}", LifecycleEvent.getPresent(eventType), item.name);
private void riseEvent(int eventType, LifecycleItem item) {
TestViewerPlugin.log().debug("Launch event: {0} for {1}", LifecycleEvent.getPresent(eventType), item.getName());
if (LifecycleEvent.isStop(eventType)) {
try {
item.testLaunch.terminate();
item.getTestLaunch().terminate();
} catch (DebugException e) {
TestViewerPlugin.log().logError("Terminate test launch", e);
}
}
listeners.forEach(l -> l.handle(eventType, item.mainLaunch));
listeners.forEach(l -> l.handle(eventType, item));
}

private void onItemStart(MonitoringItem item) {
item.active = true;
item.start = Instant.now();
private void onItemStart(LifecycleItem item) {
item.onStart();
riseEvent(LifecycleEvent.START, item);
removeTerminated();
}

private void onItemStop(MonitoringItem item, int eventType) {
item.active = false;
item.end = Instant.now();
private void onItemStop(LifecycleItem item, int eventType) {
item.onStop();
riseEvent(eventType, item);
}

private static class LaunchMonitor implements ILaunchListener, IDebugEventSetListener {
ReentrantLock lock = new ReentrantLock();
Map<ILaunch, MonitoringItem> monitoringItems = new HashMap<>();
Map<ILaunch, LifecycleItem> monitoringItems = new HashMap<>();

@Override
public void handleDebugEvents(DebugEvent[] events) {
Expand All @@ -136,9 +132,8 @@ public void handleDebugEvents(DebugEvent[] events) {
if (monitoringItems.containsKey(launch)) {
var item = monitoringItems.get(launch);
handleProcesses(item);
if (item.active) {
debug("Finish " + item.name);
item.active = false;
if (item.isActive()) {
debug("Finish " + item.getName());
onTerminate(item, process);
}
}
Expand All @@ -156,8 +151,8 @@ public void launchRemoved(ILaunch launch) {
if (monitoringItems.containsKey(launch)) {
var item = monitoringItems.get(launch);
handleProcesses(item);
if (item.active) {
debug("canceled " + item.name);
if (item.isActive()) {
debug("canceled " + item.getName());
onItemStop(item, LifecycleEvent.CANCELED);
}
}
Expand All @@ -172,16 +167,14 @@ public void launchAdded(ILaunch launch) {
var configuration = launch.getLaunchConfiguration();

if (LaunchHelper.isRunTestConfiguration(configuration)) {
var item = new MonitoringItem();
item.testLaunch = launch;
item.name = configuration.getName();
var item = new LifecycleItem(launch, configuration.getName());
monitoringItems.put(launch, item);
onItemStart(item);
} else if (LaunchHelper.isOnecConfiguration(configuration) && !Strings.isNullOrEmpty(LaunchConfigurationAttributes.getTestKind(configuration))) {
var name = configuration.getName();
for (var item : monitoringItems.values()) {
if (name.contains(item.name)) {
item.mainLaunch = launch;
if (name.contains(item.getName())) {
item.setMainLaunch(launch);
handleProcesses(item);
monitoringItems.put(launch, item);
break;
Expand All @@ -199,12 +192,15 @@ public void launchChanged(ILaunch launch) {
}
}

private void handleProcesses(MonitoringItem item) {
if (item.testLaunch.getProcesses().length < item.mainLaunch.getProcesses().length) {
var processes = new HashSet<>(List.of(item.testLaunch.getProcesses()));
for (var process : item.mainLaunch.getProcesses()) {
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()));
for (var process : item.getMainLaunch().getProcesses()) {
if (!processes.contains(process)) {
item.testLaunch.addProcess(process);
item.getTestLaunch().addProcess(process);
}
}
}
Expand All @@ -218,27 +214,18 @@ private void onLaunchEvent(String eventName, ILaunch launch) {
debug(message);
}

private void onTerminate(MonitoringItem item, IProcess process) {
private void onTerminate(LifecycleItem item, IProcess process) {
int exitCode = 0;
try {
exitCode = process.getExitValue();
} catch (DebugException e) { /* do nothing*/ }
if (exitCode != 0) {
TestViewerPlugin.log().warning(JUnitMessages.JUnitLaunchListener_ProcessError, item.name, process.getLabel(), exitCode);
TestViewerPlugin.log().warning(JUnitMessages.JUnitLaunchListener_ProcessError, item.getName(), process.getLabel(), exitCode);
onItemStop(item, LifecycleEvent.FINISHED_WITH_ERROR);
} else {
onItemStop(item, LifecycleEvent.FINISHED);
}
}
}

@Getter
private static class MonitoringItem {
private ILaunch testLaunch;
private ILaunch mainLaunch;
private String name;
private boolean active = true;
private Instant start;
private Instant end;
}
}
Loading

0 comments on commit eb9129d

Please sign in to comment.