Skip to content

Commit

Permalink
[7.x] Ensure only plugin REST tests are run for plugins (#5318… (#53196)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jakelandis authored Mar 5, 2020
1 parent 5476a49 commit 6a5d919
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @see RestResourcesPlugin
*/
public class CopyRestApiTask extends DefaultTask {
private static final String COPY_TO = "rest-api-spec/api";
private static final String REST_API_PREFIX = "rest-api-spec/api";
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);

Expand Down Expand Up @@ -109,7 +109,7 @@ public FileTree getInputDir() {

@OutputDirectory
public File getOutputDir() {
return new File(getTestSourceSet().getOutput().getResourcesDir(), COPY_TO);
return new File(getTestSourceSet().getOutput().getResourcesDir(), REST_API_PREFIX);
}

@TaskAction
Expand All @@ -132,7 +132,13 @@ void copy() {
project.copy(c -> {
c.from(project.zipTree(coreConfig.getSingleFile()));
c.into(getTestSourceSet().getOutput().getResourcesDir()); // this ends up as the same dir as outputDir
c.include(includeCore.get().stream().map(prefix -> COPY_TO + "/" + prefix + "*/**").collect(Collectors.toList()));
if (includeCore.get().isEmpty()) {
c.include(REST_API_PREFIX + "/**");
} else {
c.include(
includeCore.get().stream().map(prefix -> REST_API_PREFIX + "/" + prefix + "*/**").collect(Collectors.toList())
);
}
});
}
// only copy x-pack specs if explicitly instructed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* @see RestResourcesPlugin
*/
public class CopyRestTestsTask extends DefaultTask {
private static final String COPY_TO = "rest-api-spec/test";
private static final String REST_TEST_PREFIX = "rest-api-spec/test";
final ListProperty<String> includeCore = getProject().getObjects().listProperty(String.class);
final ListProperty<String> includeXpack = getProject().getObjects().listProperty(String.class);

Expand Down Expand Up @@ -103,7 +103,7 @@ public FileTree getInputDir() {

@OutputDirectory
public File getOutputDir() {
return new File(getTestSourceSet().getOutput().getResourcesDir(), COPY_TO);
return new File(getTestSourceSet().getOutput().getResourcesDir(), REST_TEST_PREFIX);
}

@TaskAction
Expand All @@ -128,7 +128,9 @@ void copy() {
project.copy(c -> {
c.from(project.zipTree(coreConfig.getSingleFile()));
c.into(getTestSourceSet().getOutput().getResourcesDir()); // this ends up as the same dir as outputDir
c.include(includeCore.get().stream().map(prefix -> COPY_TO + "/" + prefix + "*/**").collect(Collectors.toList()));
c.include(
includeCore.get().stream().map(prefix -> REST_TEST_PREFIX + "/" + prefix + "*/**").collect(Collectors.toList())
);
});
}
}
Expand Down

0 comments on commit 6a5d919

Please sign in to comment.