-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7a6ce5
commit eba7090
Showing
13 changed files
with
294 additions
and
51 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
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
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
24 changes: 24 additions & 0 deletions
24
src/functionalTest/groovy/com/autonomousapps/jvm/Kotlin2MigrationSpec.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,24 @@ | ||
package com.autonomousapps.jvm | ||
|
||
import com.autonomousapps.jvm.projects.Kotlin2Migration | ||
|
||
import static com.autonomousapps.utils.Runner.build | ||
import static com.google.common.truth.Truth.assertThat | ||
|
||
final class Kotlin2MigrationSpec extends AbstractJvmSpec { | ||
|
||
def "suggests declaring testFixtures dependencies (#gradleVersion)"() { | ||
given: | ||
def project = new Kotlin2Migration.DeclaresTestFixturesDependencies() | ||
gradleProject = project.gradleProject | ||
when: | ||
build(gradleVersion, gradleProject.rootDir, 'buildHealth') | ||
then: | ||
assertThat(project.actualBuildHealth()).containsExactlyElementsIn(project.expectedBuildHealth) | ||
where: | ||
gradleVersion << gradleVersions() | ||
} | ||
} |
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
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
113 changes: 113 additions & 0 deletions
113
src/functionalTest/groovy/com/autonomousapps/jvm/projects/Kotlin2Migration.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,113 @@ | ||
package com.autonomousapps.jvm.projects | ||
|
||
import com.autonomousapps.AbstractProject | ||
import com.autonomousapps.kit.GradleProject | ||
import com.autonomousapps.kit.Source | ||
import com.autonomousapps.model.ProjectAdvice | ||
|
||
import static com.autonomousapps.AdviceHelper.actualProjectAdvice | ||
import static com.autonomousapps.AdviceHelper.emptyProjectAdviceFor | ||
import static com.autonomousapps.kit.gradle.Dependency.implementation | ||
import static com.autonomousapps.kit.gradle.Dependency.testFixturesImplementation | ||
|
||
abstract class Kotlin2Migration extends AbstractProject { | ||
|
||
Kotlin2Migration() { | ||
super() | ||
} | ||
|
||
static final class DeclaresTestFixturesDependencies extends Kotlin2Migration { | ||
|
||
final GradleProject gradleProject | ||
|
||
DeclaresTestFixturesDependencies() { | ||
super() | ||
this.gradleProject = build() | ||
} | ||
|
||
private GradleProject build() { | ||
return newGradleProjectBuilder() | ||
.withSubproject('consumer') { s -> | ||
s.sources = sourcesConsumer | ||
s.withBuildScript { bs -> | ||
bs.plugins = kotlin + pluginProvider.javaTestFixtures | ||
bs.dependencies( | ||
implementation(':producer'), | ||
implementation(':producer').testFixtures(), | ||
// testFixturesImplementation(':producer'), | ||
) | ||
} | ||
} | ||
.withSubproject('producer') { s -> | ||
s.sources = sourcesProducer | ||
s.withBuildScript { bs -> | ||
bs.plugins = kotlin + pluginProvider.javaTestFixtures | ||
} | ||
} | ||
.write() | ||
} | ||
|
||
private List<Source> sourcesConsumer = [ | ||
Source.kotlin( | ||
'''\ | ||
package com.example.consumer | ||
import com.example.producer.Simpsons.HOMER | ||
class Consumer { | ||
private val homer = HOMER | ||
} | ||
''' | ||
) | ||
.withPath('com.example.consumer', 'Consumer') | ||
.build(), | ||
Source.kotlin( | ||
'''\ | ||
package com.example.consumer | ||
import com.example.producer.Person | ||
class TestFixture { | ||
val testPerson = Person("Emma", "Goldman") | ||
} | ||
''' | ||
) | ||
.withPath('com.example.consumer', 'TestFixture') | ||
.withSourceSet('testFixtures') | ||
.build(), | ||
] | ||
|
||
private List<Source> sourcesProducer = [ | ||
Source.kotlin( | ||
'''\ | ||
package com.example.producer | ||
data class Person(val firstName: String, val lastName: String) | ||
''' | ||
) | ||
.withPath('com.example.producer', 'Person') | ||
.build(), | ||
Source.kotlin( | ||
'''\ | ||
package com.example.producer | ||
object Simpsons { | ||
val HOMER = Person("Homer", "Simpson") | ||
} | ||
''' | ||
) | ||
.withPath('com.example.producer', 'Simpsons') | ||
.withSourceSet('testFixtures') | ||
.build(), | ||
] | ||
|
||
Set<ProjectAdvice> actualBuildHealth() { | ||
return actualProjectAdvice(gradleProject) | ||
} | ||
|
||
final Set<ProjectAdvice> expectedBuildHealth = [ | ||
emptyProjectAdviceFor(':consumer'), | ||
emptyProjectAdviceFor(':producer'), | ||
] | ||
} | ||
} |
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
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.