Skip to content

Commit

Permalink
Check that zero-length arrays are isolated properly too
Browse files Browse the repository at this point in the history
  • Loading branch information
big-guy committed Jul 10, 2019
1 parent 8bf1647 commit 204f0f8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Expand Up @@ -122,7 +122,7 @@ class WorkerExecutorParametersIntegrationTest extends AbstractIntegrationSpec {
buildFile << """
ext.testObject = ["foo", "bar"] as String[]
${parameterRunnableWithType('String[]', 'println param.join(",")') }
${parameterRunnableWithType('String[]', 'println "param = " + Arrays.asList(param)') }
task runWork(type: ParameterTask) {
isolationMode = ${isolationMode}
Expand All @@ -134,7 +134,29 @@ class WorkerExecutorParametersIntegrationTest extends AbstractIntegrationSpec {
succeeds("runWork")

then:
outputContains("foo,bar")
outputContains("param = [foo, bar]")

where:
isolationMode << ISOLATION_MODES
}

def "can provide zero-length array parameters with isolation mode #isolationMode"() {
buildFile << """
ext.testObject = [] as String[]
${parameterRunnableWithType('String[]', 'println "param = " + Arrays.asList(param)') }
task runWork(type: ParameterTask) {
isolationMode = ${isolationMode}
params = [testObject]
}
"""

when:
succeeds("runWork")

then:
outputContains("param = []")

where:
isolationMode << ISOLATION_MODES
Expand Down
Expand Up @@ -283,6 +283,22 @@ class IsolatableSerializerRegistryTest extends Specification {
newIsolatables[0].isolate().class == String[].class
}

def "can serialize/deserialize isolated zero-length Array"() {
String[] array = []

when:
serialize(isolatableFactory.isolate(array))

and:
Isolatable<?>[] newIsolatables = deserialize()

then:
newIsolatables[0].isolate() == array

and:
newIsolatables[0].isolate().class == String[].class
}

def "can serialize/deserialize isolated List"() {
List<String> list = ["foo", "bar"]

Expand Down

0 comments on commit 204f0f8

Please sign in to comment.