Skip to content

spock data-table formatted incorrectly #822

@AnEmortalKid

Description

@AnEmortalKid

Might be related to the way data-tables are dealt with #812

Given this test:

import spock.lang.*

class TestSpec extends Specification {

	@Unroll
	def "Test downstream build"() {

		given:
		println 'nothing'

		when:
		println 'something'

		then:
		println 'nothing #DOWNSTREAM_STEP'

		where:

		DOWNSTREAM                                                                      |DOWNSTREAM_STEP
		[[job: "../some-job/some-branch",parameters: []]] | true
		[
			[job: "../some-job/master", parameters: [[stuff: "blah"]], wait: false ]] | true
		[
			[job: "../some-job/dev"]] | true
		[
			[job: "../some-job/master"],
			[job: "../another-one/master"]] | true
		[
			[job: "     ", parameters: "param", wait: true]] | false
		[
			[job: "", wait: true]] | false
		null                                                                            | false
	}
}

The formatter will mangle the second part of the data-table into a new line:

import spock.lang.*

class TestSpec extends Specification {

	@Unroll
	def "Test downstream build"() {

		given:
		println 'nothing'

		when:
		println 'something'

		then:
		println 'nothing #DOWNSTREAM_STEP'

		where:

		DOWNSTREAM                                                                      |DOWNSTREAM_STEP
		[
			[job: "../some-job/some-branch",parameters: []]]
		| true
		[
			[job: "../some-job/master", parameters: [[stuff: "blah"]], wait: false ]]
		| true
		[
			[job: "../some-job/dev"]]
		| true
		[
			[job: "../some-job/master"],
			[job: "../another-one/master"]]
		| true
		[
			[job: "     ", parameters: "param", wait: true]]
		| false
		[[job: "", wait: true]]| false
		null                                                                            | false
	}
}

This causes things to not compile. I landed here from a bug I raised with spotless: diffplug/spotless#357

I've gotten around this by writing a custom formatter for spotless that basically re-stitches the lines back together (if a line starts with "|" after seeing a where clause)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions