Skip to content

Commit 23d599d

Browse files
authored
[7.6] Ensure only plugin REST tests are run for plugins (#5318… (#53197)
This commit fixes ensures that for external builds (e.g. plugin development) that the REST tests that are copied are properly filtered to only include the API by default. The code prior to this change resulted in including both the API and tests since the copy.include resulted as an empty list by default since the stream is empty unless explicitly configured. related #52114 fixes #53183
1 parent f665373 commit 23d599d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestApiTask.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* @see RestResourcesPlugin
5252
*/
5353
public class CopyRestApiTask extends DefaultTask {
54-
private static final String COPY_TO = "rest-api-spec/api";
54+
private static final String REST_API_PREFIX = "rest-api-spec/api";
5555
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
5656
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);
5757

@@ -109,7 +109,7 @@ public FileTree getInputDir() {
109109

110110
@OutputDirectory
111111
public File getOutputDir() {
112-
return new File(getTestSourceSet().getOutput().getResourcesDir(), COPY_TO);
112+
return new File(getTestSourceSet().getOutput().getResourcesDir(), REST_API_PREFIX);
113113
}
114114

115115
@TaskAction
@@ -132,7 +132,13 @@ void copy() {
132132
project.copy(c -> {
133133
c.from(project.zipTree(coreConfig.getSingleFile()));
134134
c.into(getTestSourceSet().getOutput().getResourcesDir()); // this ends up as the same dir as outputDir
135-
c.include(includeCore.get().stream().map(prefix -> COPY_TO + "/" + prefix + "*/**").collect(Collectors.toList()));
135+
if (includeCore.get().isEmpty()) {
136+
c.include(REST_API_PREFIX + "/**");
137+
} else {
138+
c.include(
139+
includeCore.get().stream().map(prefix -> REST_API_PREFIX + "/" + prefix + "*/**").collect(Collectors.toList())
140+
);
141+
}
136142
});
137143
}
138144
// only copy x-pack specs if explicitly instructed

buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/CopyRestTestsTask.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* @see RestResourcesPlugin
4949
*/
5050
public class CopyRestTestsTask extends DefaultTask {
51-
private static final String COPY_TO = "rest-api-spec/test";
51+
private static final String REST_TEST_PREFIX = "rest-api-spec/test";
5252
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
5353
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);
5454

@@ -103,7 +103,7 @@ public FileTree getInputDir() {
103103

104104
@OutputDirectory
105105
public File getOutputDir() {
106-
return new File(getTestSourceSet().getOutput().getResourcesDir(), COPY_TO);
106+
return new File(getTestSourceSet().getOutput().getResourcesDir(), REST_TEST_PREFIX);
107107
}
108108

109109
@TaskAction
@@ -128,7 +128,9 @@ void copy() {
128128
project.copy(c -> {
129129
c.from(project.zipTree(coreConfig.getSingleFile()));
130130
c.into(getTestSourceSet().getOutput().getResourcesDir()); // this ends up as the same dir as outputDir
131-
c.include(includeCore.get().stream().map(prefix -> COPY_TO + "/" + prefix + "*/**").collect(Collectors.toList()));
131+
c.include(
132+
includeCore.get().stream().map(prefix -> REST_TEST_PREFIX + "/" + prefix + "*/**").collect(Collectors.toList())
133+
);
132134
});
133135
}
134136
}

0 commit comments

Comments
 (0)