Skip to content

Commit 60570d7

Browse files
committed
Add failing test to highlight paths issue
Fails with: ``` ERROR: IO problem while reading files with API signatures: java.io.FileNotFoundException: /home/alpar/work/elastic/elasticsearch/buildSrc/src/testKit/forbidden-apis/buildSrc/src/main/resources/forbidden/jdk-signatures.txt (No such file or directory) ``` because signature definitiions are accessed on the FS directly.
1 parent 4f30963 commit 60570d7

File tree

5 files changed

+86
-10
lines changed

5 files changed

+86
-10
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* 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.elasticsearch.gradle.precommit;
20+
21+
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
22+
import org.gradle.testkit.runner.BuildResult;
23+
24+
public class ForbiddenApisCLITaskIT extends GradleIntegrationTestCase {
25+
26+
private static final String SAMPLE_PROJECT = "forbidden-apis";
27+
28+
public void testRunCliTask() {
29+
BuildResult result = getGradleRunner(SAMPLE_PROJECT)
30+
.withArguments("forbiddenApisCli", "-s")
31+
.build();
32+
}
33+
34+
}

buildSrc/src/test/java/org/elasticsearch/gradle/precommit/NamingConventionsTaskIT.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
import org.elasticsearch.gradle.test.GradleIntegrationTestCase;
44
import org.gradle.testkit.runner.BuildResult;
5-
import org.gradle.testkit.runner.GradleRunner;
65
import org.gradle.testkit.runner.TaskOutcome;
76

87
import java.util.Arrays;
98

109
public class NamingConventionsTaskIT extends GradleIntegrationTestCase {
1110

11+
public static final String SAMPLE_PROJECT = "namingConventionsSelfTest";
12+
1213
public void testPluginCanBeApplied() {
13-
BuildResult result = GradleRunner.create()
14-
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
14+
BuildResult result = getGradleRunner(SAMPLE_PROJECT)
1515
.withArguments("hello", "-s", "-PcheckForTestsInMain=false")
16-
.withPluginClasspath()
1716
.build();
1817

1918
assertEquals(TaskOutcome.SUCCESS, result.task(":hello").getOutcome());
@@ -22,10 +21,8 @@ public void testPluginCanBeApplied() {
2221
}
2322

2423
public void testNameCheckFailsAsItShould() {
25-
BuildResult result = GradleRunner.create()
26-
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
24+
BuildResult result = getGradleRunner(SAMPLE_PROJECT)
2725
.withArguments("namingConventions", "-s", "-PcheckForTestsInMain=false")
28-
.withPluginClasspath()
2926
.buildAndFail();
3027

3128
assertNotNull("task did not run", result.task(":namingConventions"));
@@ -47,10 +44,8 @@ public void testNameCheckFailsAsItShould() {
4744
}
4845

4946
public void testNameCheckFailsAsItShouldWithMain() {
50-
BuildResult result = GradleRunner.create()
51-
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
47+
BuildResult result = getGradleRunner(SAMPLE_PROJECT)
5248
.withArguments("namingConventions", "-s", "-PcheckForTestsInMain=true")
53-
.withPluginClasspath()
5449
.buildAndFail();
5550

5651
assertNotNull("task did not run", result.task(":namingConventions"));

buildSrc/src/test/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.elasticsearch.gradle.test;
22

3+
import org.gradle.testkit.runner.GradleRunner;
4+
35
import java.io.File;
46

57
public abstract class GradleIntegrationTestCase extends GradleUnitTestCase {
@@ -13,4 +15,14 @@ protected File getProjectDir(String name) {
1315
return new File(root, name);
1416
}
1517

18+
protected GradleRunner getGradleRunner(String sampleProject) {
19+
return GradleRunner.create()
20+
.withProjectDir(getProjectDir(sampleProject))
21+
.withPluginClasspath(
22+
//Collections.singleton(
23+
// new File("/home/alpar/work/elastic/elasticsearch/buildSrc/build/pluginUnderTestMetaDataWithJar/")
24+
//)
25+
);
26+
}
27+
1628
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id 'java'
3+
id 'elasticsearch.build'
4+
}
5+
6+
ext.licenseFile = file("$buildDir/dummy/license")
7+
ext.noticeFile = file("$buildDir/dummy/notice")
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* 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+
20+
package org.elasticsearch.test;
21+
22+
23+
public class UnsafeImplementationClass {
24+
25+
public UnsafeImplementationClass() {
26+
27+
}
28+
}

0 commit comments

Comments
 (0)