Use URI for flat directory so tests work on Windows (#350)

This commit is contained in:
Schalk Cronje 2019-05-05 21:05:54 +02:00
parent 910a8f8a10
commit 4c6678eb8a
5 changed files with 35 additions and 12 deletions

View File

@ -20,7 +20,7 @@ class JRubyPrepareGemsIntegrationSpec extends IntegrationSpecification {
setup:
withDependencies "gems ${slimGem}"
withPreamble """
jruby.gemInstallDir = '${projectDir.absolutePath}'
jruby.gemInstallDir = '${pathAsUriStr(projectDir)}'.toURI()
"""
when:
@ -35,7 +35,7 @@ class JRubyPrepareGemsIntegrationSpec extends IntegrationSpecification {
setup:
withDefaultRepositories()
withPreamble """
jruby.gemInstallDir = '${projectDir.absolutePath}'
jruby.gemInstallDir = '${pathAsUriStr(projectDir)}'.toURI()
"""
withDependencies """
gems "rubygems:sinatra:1.4.5"
@ -57,7 +57,7 @@ class JRubyPrepareGemsIntegrationSpec extends IntegrationSpecification {
setup:
withDefaultRepositories()
withPreamble """
jruby.gemInstallDir = '${projectDir.absolutePath}'
jruby.gemInstallDir = '${pathAsUriStr(projectDir)}'.toURI()
"""
withDependencies 'gems "rubygems:jar-dependencies:0.1.16.pre"'
@ -74,7 +74,7 @@ class JRubyPrepareGemsIntegrationSpec extends IntegrationSpecification {
setup:
withDefaultRepositories()
withPreamble """
jruby.gemInstallDir = '${projectDir.absolutePath}'
jruby.gemInstallDir = '${pathAsUriStr(projectDir)}'.toURI()
"""
withDependencies 'gems "rubygems:childprocess:1.0.1"'

View File

@ -12,7 +12,7 @@ class JRubyPrepareJarsIntegrationSpec extends IntegrationSpecification {
given:
buildFile.text = """
${projectWithLocalRepo}
jruby.gemInstallDir = '${projectDir.absolutePath}'
jruby.gemInstallDir = '${pathAsUriStr(projectDir)}'.toURI()
dependencies {
gems 'io.dropwizard.metrics:metrics-core:3.1.0'

View File

@ -54,6 +54,10 @@ class IntegrationSpecification extends Specification {
"'${VersionFinder.findDependency(flatRepoLocation, organisation, artifact, extension)}'"
}
String pathAsUriStr(final File path) {
path.absoluteFile.toURI().toString()
}
String getProjectWithLocalRepo() {
"""
plugins {
@ -61,7 +65,11 @@ class IntegrationSpecification extends Specification {
}
jruby.defaultRepositories = false
repositories.flatDir dirs: '${flatRepoLocation.absolutePath}'
repositories {
flatDir {
dirs '${pathAsUriStr(flatRepoLocation)}'.toURI()
}
}
"""
}
@ -72,8 +80,15 @@ class IntegrationSpecification extends Specification {
}
jruby.defaultRepositories = false
repositories.maven { url 'file://${mavenRepoLocation.absolutePath}' }
repositories.flatDir dirs: '${flatRepoLocation.absolutePath}'
repositories {
flatDir {
dirs '${pathAsUriStr(flatRepoLocation)}'.toURI()
}
maven {
url '${pathAsUriStr(mavenRepoLocation)}'.toURI()
}
}
"""
}
@ -84,7 +99,7 @@ class IntegrationSpecification extends Specification {
}
jruby.defaultRepositories = true
repositories.maven { url 'file://${mavenRepoLocation.absolutePath}' }
repositories.maven { url '${pathAsUriStr(mavenRepoLocation)}'.toURI() }
"""
}

View File

@ -169,9 +169,13 @@ class JRubyJarTestKitSpec extends IntegrationSpecification {
private void withLocalRepositories() {
this.repoSetup = """
repositories {
repositories.flatDir dirs: '${flatRepoLocation.absolutePath}'
repositories.maven { url 'file://${mavenRepoLocation.absolutePath}' }
repositories {
flatDir {
dirs '${pathAsUriStr(flatRepoLocation)}'
}
maven {
url '${pathAsUriStr(mavenRepoLocation)}'
}
}
"""
}

View File

@ -46,6 +46,10 @@ class IntegrationSpecification extends Specification {
.forwardOutput()
}
String pathAsUriStr(final File path) {
path.absoluteFile.toURI().toString()
}
private Map<String, String> loadTestProperties() {
this.class.getResource('/jruby-gradle-testconfig.properties').withInputStream { strm ->
Properties props = new Properties()