Skip to content

Commit 9d5bc1e

Browse files
authored
Merge pull request #7979 from petrovic-d/action-for-running-tests-in-parallel
Action for running tests in parallel
2 parents 22172a9 + 40bae1a commit 9d5bc1e

File tree

65 files changed

+1679
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1679
-309
lines changed

enterprise/micronaut/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ javac.source=1.8
1919
javac.compilerargs=-Xlint -Xlint:-serial
2020
release.external/spring-boot-configuration-metadata-2.4.4.jar=modules/ext/spring-boot-configuration-metadata-2.4.4.jar
2121
release.external/android-json-0.0.20131108.vaadin1.jar=modules/ext/android-json-0.0.20131108.vaadin1.jar
22-
spec.version.base=1.16.0
22+
spec.version.base=1.17.0
2323
requires.nb.javac=true
2424
test-unit-sys-prop.test.netbeans.dest.dir=${netbeans.dest.dir}
2525
test.unit.cp.extra=${tools.jar}

enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/micronaut-actions-maven.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@
3535
<packaging>native-image</packaging>
3636
</properties>
3737
</action>
38+
<action>
39+
<actionName>test.single</actionName>
40+
<packagings>
41+
<packaging>*</packaging>
42+
</packagings>
43+
<goals>
44+
<goal>io.micronaut.maven:micronaut-maven-plugin:start-testresources-service</goal>
45+
<goal>process-test-classes</goal>
46+
<goal>surefire:test</goal>
47+
</goals>
48+
<properties>
49+
<test>${packageClassName}</test>
50+
</properties>
51+
</action>
3852

3953
<profiles>
4054
<profile>

extide/gradle/apichanges.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ is the proper place.
8383
<!-- ACTUAL CHANGES BEGIN HERE: -->
8484

8585
<changes>
86+
<change id="action-for-running-tests-in-parallel">
87+
<api name="general"/>
88+
<summary>Added action for running tests in parallel</summary>
89+
<version major="2" minor="45"/>
90+
<date day="18" month="12" year="2024"/>
91+
<author login="petrovic-d"/>
92+
<compatibility semantic="compatible" addition="yes" deprecation="yes"/>
93+
<description>
94+
Added action for running tests in parallel with ability to specify the projects on which
95+
the action will be applied.
96+
</description>
97+
</change>
8698
<change id="load-options-lookup">
8799
<api name="general"/>
88100
<summary>LoadOptions object replaces growing number of argumetns to project load APIs. Access to current Lookup added.</summary>

extide/gradle/nbproject/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ javadoc.apichanges=${basedir}/apichanges.xml
2525
nbm.module.author=Laszlo Kishalmi
2626
source.reference.netbeans-gradle-tooling.jar=netbeans-gradle-tooling/src/main/groovy
2727

28-
spec.version.base=2.44.0
28+
spec.version.base=2.45.0
2929
test-unit-sys-prop.test.netbeans.dest.dir=${netbeans.dest.dir}
3030
test-unit-sys-prop.java.awt.headless=true
3131

extide/gradle/src/org/netbeans/modules/gradle/ActionProviderImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.netbeans.modules.gradle.api.execute.RunUtils;
2727
import org.netbeans.modules.gradle.actions.ActionToTaskUtils;
2828
import org.netbeans.modules.gradle.execute.GradleExecutorOptionsPanel;
29-
import org.netbeans.modules.gradle.spi.actions.GradleActionsProvider;
3029
import java.util.HashSet;
3130
import java.util.List;
3231
import java.util.Set;
@@ -189,6 +188,7 @@ public boolean isActionEnabled(String command, Lookup context) throws IllegalArg
189188
"# {0} - artifactId", "TXT_ApplyCodeChanges=Apply Code Changes ({0})",
190189
"# {0} - artifactId", "TXT_Profile=Profile ({0})",
191190
"# {0} - artifactId", "TXT_Test=Test ({0})",
191+
"# {0} - artifactId", "TXT_Test_Parallel=Test In Parallel ({0})",
192192
"# {0} - artifactId", "TXT_Build=Build ({0})",
193193
"# {0} - artifactId", "TXT_Delete=Delete ({0})",
194194
})
@@ -215,6 +215,9 @@ static String taskName(Project project, String action, Lookup lkp) {
215215
case ActionProvider.COMMAND_TEST:
216216
title = TXT_Test(prjLabel);
217217
break;
218+
case ActionProvider.COMMAND_TEST_PARALLEL:
219+
title = TXT_Test_Parallel(prjLabel);
220+
break;
218221
case ActionProvider.COMMAND_RUN_SINGLE:
219222
title = TXT_Run(dobjName);
220223
break;

extide/gradle/test/unit/src/org/netbeans/modules/gradle/actions/declarative-actions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
</profiles>
5050
<!-- @end region="configuration-declaration-xml" -->
5151

52+
<action name="test.parallel">
53+
<args>--parallel --rerun-tasks ${taskWithProjects}</args>
54+
</action>
5255
<apply-for plugins="java">
5356
<action name="test.single">
5457
<args>cleanTest test --tests "${selectedClass}"</args>

ide/projectapi/apichanges.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ is the proper place.
8383
<!-- ACTUAL CHANGES BEGIN HERE: -->
8484

8585
<changes>
86+
<change id="run-test-in-parallel-action">
87+
<api name="general"/>
88+
<summary>Added action for running tests in parallel</summary>
89+
<version major="1" minor="99"/>
90+
<date day="2" month="12" year="2024"/>
91+
<author login="petrovic-d"/>
92+
<compatibility addition="yes"/>
93+
<description>
94+
<p>
95+
<code><a href="@TOP@/org/netbeans/spi/project/ActionProvider.html">ActionProvider.COMMAND_TEST_PARALLEL</a></code> was introduced in order to
96+
allow running tests in parallel.
97+
<code><a href="@TOP@/org/netbeans/api/project/ContainedProjectFilter.html">ContainedProjectFilter</a></code> was added and
98+
it can be used to pass list of projects the project action should apply to.
99+
<code><a href="@TOP@/org/netbeans/spi/project/NestedClass">NestedClass</a></code> was added in order to support
100+
nested classes.
101+
</p>
102+
</description>
103+
<class package="org.netbeans.api.project" name="ContainedProjectFilter"/>
104+
<class package="org.netbeans.spi.project" name="ActionProvider"/>
105+
<class package="org.netbeans.spi.project" name="NestedClass"/>
106+
</change>
86107
<change id="project-action-context">
87108
<api name="general"/>
88109
<summary>Added <code>ProjectActionContext</code> that can pass action-like environment to project queries</summary>

ide/projectapi/manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
OpenIDE-Module: org.netbeans.modules.projectapi/1
3-
OpenIDE-Module-Specification-Version: 1.98
3+
OpenIDE-Module-Specification-Version: 1.99
44
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
55
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
66
OpenIDE-Module-Needs: org.netbeans.spi.project.ProjectManagerImplementation
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.netbeans.api.project;
20+
21+
import java.util.Collections;
22+
import java.util.List;
23+
import java.util.Optional;
24+
25+
/**
26+
* Provides list of projects the project action should apply to
27+
*
28+
* <p>
29+
* An action that processes multiple projects might use <code>ContainedProjectFilter</code>
30+
* to operate only on a specific subset of projects.
31+
* The use of <code>ContainedProjectFilter</code> is optional and determined
32+
* by the requirements of individual actions.
33+
* Actions employing this class must document their specific filtering logic
34+
* and behavior.
35+
* </p>
36+
*
37+
* @author Dusan Petrovic
38+
*
39+
* @since 1.99
40+
*/
41+
public final class ContainedProjectFilter {
42+
43+
private final List<Project> projectsToProcess;
44+
45+
private ContainedProjectFilter(List<Project> projectsToProcess) {
46+
this.projectsToProcess = projectsToProcess;
47+
}
48+
49+
/**
50+
* Static factory method to create an instance of ContainedProjectFilter.
51+
*
52+
* @param projectsToProcess the list of projects to include in the filter
53+
* @return an Optional containing ContainedProjectFilter, or Optional.empty() if the list is null or empty
54+
*/
55+
public static Optional<ContainedProjectFilter> of(List<Project> projectsToProcess) {
56+
if (projectsToProcess == null || projectsToProcess.isEmpty()) {
57+
return Optional.empty();
58+
}
59+
return Optional.of(new ContainedProjectFilter(projectsToProcess));
60+
}
61+
62+
public List<Project> getProjectsToProcess() {
63+
return Collections.unmodifiableList(projectsToProcess);
64+
}
65+
}

ide/projectapi/src/org/netbeans/spi/project/ActionProvider.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ public interface ActionProvider {
8383
*/
8484
String COMMAND_TEST_SINGLE = "test.single"; // NOI18N
8585

86+
/**
87+
* Standard command for running tests in parallel on given projects sub-modules
88+
*
89+
* @since 1.99
90+
*/
91+
String COMMAND_TEST_PARALLEL = "test.parallel"; // NOI18N
92+
8693
/**
8794
* Standard command for running the project in debugger
8895
*/

0 commit comments

Comments
 (0)