gradle-plugin: Fix tests according to plugin changes

This commit is contained in:
Ilya Matveev
2017-08-31 13:10:33 +07:00
committed by ilmat192
parent 7ec167b5ca
commit d0b3f46a77
3 changed files with 55 additions and 29 deletions
@@ -109,7 +109,7 @@ class KonanProject {
}
""".stripIndent()
)
compilationTasks = [":compileKonan${DEFAULT_ARTIFACT_NAME.capitalize()}".toString(), ":compileKonan", ":build"]
compilationTasks = [defaultCompilationTask(), ":compileKonan", ":build"]
return result
}
@@ -183,6 +183,16 @@ class KonanProject {
addSetting("konanArtifacts", artifactName, parameter, value)
}
/** Returns the path of compileKonan... task for the default artifact. */
String defaultCompilationTask() {
return compilationTask(DEFAULT_ARTIFACT_NAME)
}
/** Returns the path of compileKonan... task for the artifact specified. */
String compilationTask(String artifactName) {
return ":compileKonan${artifactName.capitalize()}"
}
/** Creates a project with default build and source files. */
static KonanProject create(File projectDir) {
return createEmpty(projectDir) {
@@ -263,9 +273,8 @@ class KonanInteropProject extends KonanProject {
}
""".stripIndent()
)
interopTasks = [":gen${DEFAULT_INTEROP_NAME.capitalize()}InteropStubs".toString(),
":compile${DEFAULT_INTEROP_NAME.capitalize()}InteropStubs".toString()]
compilationTasks = [":compileKonan${DEFAULT_ARTIFACT_NAME.capitalize()}".toString(), ":compileKonan", ":build"]
interopTasks = [defaultStubGenerationTask(), defaultStubCompilationTask()]
compilationTasks = [defaultCompilationTask(), ":compileKonan", ":build"]
return result
}
@@ -299,6 +308,22 @@ class KonanInteropProject extends KonanProject {
addSetting("konanInterop", interopName, parameter, value)
}
String defaultStubGenerationTask() {
return stubGenerationTask(DEFAULT_INTEROP_NAME)
}
String defaultStubCompilationTask() {
return stubCompilationTask(DEFAULT_INTEROP_NAME)
}
String stubGenerationTask(String interopName) {
return ":gen${interopName.capitalize()}InteropStubs"
}
String stubCompilationTask(String interopName) {
return ":compile${interopName.capitalize()}InteropStubs"
}
/** Creates a project with default build, source and def files. */
static KonanInteropProject create(File projectDir) {
return createEmpty(projectDir) {
@@ -35,7 +35,7 @@ class PathSpecification extends BaseKonanSpecification {
def result = project.createRunner().withArguments('build').buildAndFail()
then:
result.task(project.downloadTask).outcome == TaskOutcome.FAILED
result.task(project.defaultCompilationTask()).outcome == TaskOutcome.FAILED
}
def 'Plugin should stop building if the stub generator classpath is empty'() {
@@ -45,7 +45,7 @@ class PathSpecification extends BaseKonanSpecification {
def result = project.createRunner().withArguments('build').buildAndFail()
then:
result.task(project.downloadTask).outcome == TaskOutcome.FAILED
result.task(project.defaultStubGenerationTask()).outcome == TaskOutcome.FAILED
}
}
@@ -6,33 +6,34 @@ class RegressionSpecification extends BaseKonanSpecification {
def 'KT-19916'() {
when:
def project = KonanProject.createEmpty(getProjectDirectory()) { KonanProject prj ->
prj.generateSettingsFile("include ':subproject'")
def subprojectDir = prj.projectPath.resolve("subproject").toFile()
subprojectDir.mkdirs()
subprojectDir.toPath().resolve("build.gradle").write("""
dependencies {
libs gradleApi()
}
""".stripIndent())
def project = KonanProject.createEmpty(getProjectDirectory()) { KonanProject prj ->
prj.generateSettingsFile("include ':subproject'")
def subprojectDir = prj.projectPath.resolve("subproject").toFile()
subprojectDir.mkdirs()
subprojectDir.toPath().resolve("build.gradle").write("""
dependencies {
libs gradleApi()
}
""".stripIndent())
prj.buildFile.append("""
subprojects {
apply plugin: 'konan'
apply plugin: Foo
prj.buildFile.append("""
subprojects {
apply plugin: 'konan'
apply plugin: Foo
}
class Foo implements Plugin<Project> {
void apply(Project project) {
project.configurations.maybeCreate("libs")
}
class Foo implements Plugin<Project> {
void apply(Project project) {
project.configurations.maybeCreate("libs")
}
}
""".stripIndent())
}
}
""".stripIndent())
}
def result = project.createRunner().withArguments('tasks').build()
def result = project.createRunner().withArguments('tasks').build()
then:
result.task(':tasks').outcome == TaskOutcome.SUCCESS
result.task(':tasks').outcome == TaskOutcome.SUCCESS
}
}