Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing for windows #77

Merged
merged 6 commits into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ class GradleDependencyGenerator {
mavenRepoDir.absolutePath
}

String getMavenRepoUrl() {
mavenRepoDir.toURI().toURL()
}

String getMavenRepositoryBlock() {
"""\
maven { url '${getMavenRepoDirPath()}' }
maven { url '${getMavenRepoUrl()}' }
""".stripIndent()
}

Expand All @@ -96,10 +100,14 @@ class GradleDependencyGenerator {
ivyRepoDir.absolutePath
}

String getIvyRepoUrl() {
ivyRepoDir.toURI().toURL()
}

String getIvyRepositoryBlock() {
"""\
ivy {
url '${getIvyRepoDirPath()}'
url '${getIvyRepoUrl()}'
layout('pattern') {
ivy '[organisation]/[module]/[revision]/[module]-[revision]-ivy.[ext]'
artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'
Expand Down
2 changes: 1 addition & 1 deletion src/main/groovy/nebula/test/functional/GradleRunner.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface GradleRunner {
@Override
boolean apply(URL url) {
File userDir = new File(StandardSystemProperty.USER_DIR.value())
return url.path.startsWith(userDir.path)
return url.path.startsWith(userDir.toURI().toURL().path)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/groovy/nebula/test/ChangingTestDirSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ChangingTestDirSpec extends IntegrationSpec {

def 'can change name of project dir'() {
expect:
projectDir.absolutePath.contains('build/test/build1')
projectDir.toURI().toString().contains('build/test/build1')
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,67 @@ package nebula.test

import org.gradle.api.logging.LogLevel
import spock.lang.Ignore
import spock.lang.IgnoreIf
import spock.lang.Unroll
import spock.util.environment.OperatingSystem

class SpecifiedGradleVersionIntegrationSpec extends IntegrationSpec {
def setup() {
fork = true
}

@Unroll("should use Gradle #requestedGradleVersion when requested")
def "should allow to run functional tests with different Gradle versions"() {

@IgnoreIf({ OperatingSystem.current.linux || OperatingSystem.current.macOs})
@Unroll("should use Gradle #requestedGradleVersion when requested ")
def "should allow to run functional tests with different Gradle versions Windows"() {
given:
writeHelloWorld('nebula.test.hello')
buildFile << '''
apply plugin: 'java'
'''.stripIndent()
and:
logLevel = LogLevel.DEBUG

and:
gradleVersion = requestedGradleVersion

when:
def result = runTasksSuccessfully('build')

then:
result.standardOutput.contains("gradle/$requestedGradleVersion/taskArtifacts")

result.standardOutput.contains("gradle\\$requestedGradleVersion\\taskArtifacts")

where:
requestedGradleVersion << ['2.8', '2.9']
}

@IgnoreIf({ OperatingSystem.current.windows })
@Unroll("should use Gradle #requestedGradleVersion when requested ")
def "should allow to run functional tests with different Gradle versions Linux - Mac"() {
given:
writeHelloWorld('nebula.test.hello')
buildFile << '''
apply plugin: 'java'
'''.stripIndent()
and:
logLevel = LogLevel.DEBUG

and:
gradleVersion = requestedGradleVersion

when:
def result = runTasksSuccessfully('build')

then:

result.standardOutput.contains("gradle/$requestedGradleVersion/taskArtifacts")


where:
requestedGradleVersion << ['2.8', '2.9']
}

static final String CUSTOM_DISTRIBUTION = 'http://dl.bintray.com/nebula/gradle-distributions/1.12-20140608201532+0000/gradle-1.12-20140608201532+0000-bin.zip'

@Ignore("Only works with a custom distribution that is compatible with our runtime, of which 1.12 is not compatible with our spock 2.0 dependency")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class GradleDependencyGeneratorSpec extends Specification {
def generator = new GradleDependencyGenerator(new DependencyGraph(['test.ivy:foo:1.0.0']), 'build/test')
String expectedBlock = """\
ivy {
url '${generator.ivyRepoDirPath}'
url '${generator.getIvyRepoUrl()}'
layout('pattern') {
ivy '[organisation]/[module]/[revision]/[module]-[revision]-ivy.[ext]'
artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'
Expand Down Expand Up @@ -230,7 +230,7 @@ class GradleDependencyGeneratorSpec extends Specification {
def 'integration spec maven repository block is available'() {
def generator = new GradleDependencyGenerator(new DependencyGraph(['test.maven:foo:1.0.0']), 'build/test')
String expectedBlock = """\
maven { url '${generator.mavenRepoDirPath}' }
maven { url '${generator.getMavenRepoUrl()}' }
""".stripIndent()

when:
Expand Down
44 changes: 22 additions & 22 deletions src/test/groovy/nebula/test/functional/GradleRunnerSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,31 @@ class GradleRunnerSpec extends Specification {
"file:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/zipfs.jar",

// The project that is being tested always appears as follows:
"file:$workDir/build/classes/test/",
"file:$workDir/build/classes/main/",
"file:$workDir/build/resources/test/",
"file:$workDir/build/resources/main/",
new File(workDir, 'build/classes/test/').toURI() as String,
new File(workDir, 'build/classes/main/').toURI() as String,
new File(workDir, 'build/resources/test/').toURI() as String,
new File(workDir, 'build/resources/main/').toURI() as String,

// when launched from IDE, project dependencies appear this way:
"file:$siblingDir/build/classes/test/",
"file:$siblingDir/build/classes/main/",
"file:$siblingDir/build/resources/test/",
"file:$siblingDir/build/resources/main/",
new File(siblingDir, 'build/classes/test/').toURI() as String,
new File(siblingDir, 'build/classes/main/').toURI() as String,
new File(siblingDir, 'build/resources/test/').toURI() as String,
new File(siblingDir, 'build/resources/main/').toURI() as String,

// when launched from Gradle, project dependencies appear as jars:
"file:$siblingDir/build/libs/repos-4.0.0.jar",
new File(siblingDir, 'build/libs/repos-4.0.0.jar').toURI() as String,

"file:/Users/dannyt/.gradle/caches/modules-2/files-2.1/org.spockframework/spock-core/1.0-groovy-2.3/762fbf6c5f24baabf9addcf9cf3647151791f7eb/spock-core-1.0-groovy-2.3.jar",
"file:/Users/dannyt/.gradle/caches/modules-2/files-2.1/cglib/cglib-nodep/2.2.2/d456bb230c70c0b95c76fb28e429d42f275941/cglib-nodep-2.2.2.jar",
"file:/Users/dannyt/.gradle/caches/modules-2/files-2.1/commons-lang/commons-lang/2.6/ce1edb914c94ebc388f086c6827e8bdeec71ac2/commons-lang-2.6.jar",
"file:/Users/dannyt/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar",
"file:/Users/dannyt/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar",
"file:/Users/dannyt/.gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/gradle-core-2.2.1.jar",
"file:/Users/dannyt/.gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/groovy-all-2.3.6.jar",
"file:/Users/dannyt/.gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/asm-all-5.0.3.jar",
"file:/Users/dannyt/.gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/ant-1.9.3.jar",
"file:/Users/dannyt/.gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/commons-collections-3.2.1.jar",
"file:/Users/dannyt/.gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/commons-io-1.4.jar"
new File(workDir, ".gradle/caches/modules-2/files-2.1/org.spockframework/spock-core/1.0-groovy-2.3/762fbf6c5f24baabf9addcf9cf3647151791f7eb/spock-core-1.0-groovy-2.3.jar").toURI() as String,
new File(workDir, ".gradle/caches/modules-2/files-2.1/cglib/cglib-nodep/2.2.2/d456bb230c70c0b95c76fb28e429d42f275941/cglib-nodep-2.2.2.jar").toURI() as String,
new File(workDir, ".gradle/caches/modules-2/files-2.1/commons-lang/commons-lang/2.6/ce1edb914c94ebc388f086c6827e8bdeec71ac2/commons-lang-2.6.jar").toURI() as String,
new File(workDir, ".gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar").toURI() as String,
new File(workDir, ".gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar").toURI() as String,
new File(workDir, ".gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/gradle-core-2.2.1.jar").toURI() as String,
new File(workDir, ".gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/groovy-all-2.3.6.jar").toURI() as String,
new File(workDir, ".gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/asm-all-5.0.3.jar").toURI() as String,
new File(workDir, ".gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/ant-1.9.3.jar").toURI() as String,
new File(workDir, ".gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/commons-collections-3.2.1.jar").toURI() as String,
new File(workDir, ".gradle/wrapper/dists/gradle-2.2.1-bin/3rn023ng4778ktj66tonmgpbv/gradle-2.2.1/lib/commons-io-1.4.jar").toURI() as String
]
classpath = classpathUris.collect { new URI(it).toURL() }
}
Expand All @@ -84,7 +84,7 @@ class GradleRunnerSpec extends Specification {
def 'jvm predicate includes expected files'() {
expect:
def filtered = FluentIterable.from(classpath).filter(GradleRunner.CLASSPATH_PROJECT_DIR).toList()
filtered.size() == 4
filtered.size() == 15
}

def 'classpath project deps predicate filters to projects'() {
Expand All @@ -96,6 +96,6 @@ class GradleRunnerSpec extends Specification {
def 'default classpath includes only application class paths and dependencies'() {
expect:
def filtered = FluentIterable.from(classpath).filter(GradleRunner.CLASSPATH_DEFAULT).toList()
filtered.size() == 14
filtered.size() == 20
}
}