-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Backports the following commits to 7.17: - Rework testing conventions gradle plugin (#87213)
- Loading branch information
Showing
85 changed files
with
899 additions
and
1,259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...est/groovy/org/elasticsearch/gradle/fixtures/AbstractGradlePrecommitPluginFuncTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.fixtures | ||
|
||
import org.elasticsearch.gradle.internal.conventions.precommit.PrecommitPlugin | ||
|
||
abstract class AbstractGradlePrecommitPluginFuncTest extends AbstractJavaGradleFuncTest { | ||
|
||
abstract <T extends PrecommitPlugin> Class<T> getPluginClassUnderTest(); | ||
|
||
def setup() { | ||
buildFile << """ | ||
import ${getPluginClassUnderTest().getName()} | ||
plugins { | ||
// bring in build-tools-internal onto the classpath | ||
id 'elasticsearch.global-build-info' | ||
} | ||
// internally used plugins do not have a plugin id as they are | ||
// not intended to be used directly from build scripts | ||
plugins.apply(${getPluginClassUnderTest().getSimpleName()}) | ||
""" | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...rnal/src/integTest/groovy/org/elasticsearch/gradle/fixtures/LocalRepositoryFixture.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.fixtures | ||
|
||
import net.bytebuddy.ByteBuddy | ||
import net.bytebuddy.dynamic.DynamicType | ||
import org.junit.rules.ExternalResource | ||
import org.junit.rules.TemporaryFolder | ||
|
||
class LocalRepositoryFixture extends ExternalResource{ | ||
|
||
private TemporaryFolder temporaryFolder | ||
|
||
LocalRepositoryFixture(TemporaryFolder temporaryFolder){ | ||
this.temporaryFolder = temporaryFolder | ||
} | ||
|
||
void generateJar(String group, String module, String version, String... clazzNames){ | ||
def baseGroupFolderPath = group.replace('.', '/') | ||
def targetFolder = new File(repoDir, "${baseGroupFolderPath}/$module/$version") | ||
targetFolder.mkdirs() | ||
|
||
def jarFile = new File(targetFolder, "${module}-${version}.jar") | ||
clazzNames.each {clazzName -> | ||
DynamicType.Unloaded<?> dynamicType = new ByteBuddy().subclass(Object.class) | ||
.name(clazzName) | ||
.make() | ||
if(jarFile.exists()) { | ||
dynamicType.inject(jarFile); | ||
}else { | ||
dynamicType.toJar(jarFile); | ||
} | ||
} | ||
} | ||
|
||
void configureBuild(File buildFile) { | ||
buildFile << """ | ||
repositories { | ||
maven { | ||
name = "local-test" | ||
url = "${getRepoDir()}" | ||
metadataSources { | ||
artifact() | ||
} | ||
} | ||
} | ||
""" | ||
} | ||
|
||
File getRepoDir() { | ||
new File(temporaryFolder.root, 'local-repo') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.