Skip to content

testing: multiline example output comparison doesn't strip per-line whitespace #6416

@josharian

Description

@josharian
What steps will reproduce the problem?

1. Write a testing example that generates multiline output and in which interior lines
have trailing whitespace. For example, http://play.golang.org/p/3t5VyhWw7Z or
http://play.golang.org/p/nwSaMHGKU3.
2. go test


What is the expected output?

Interior lines' leading and trailing whitespace is stripped. The examples I provided
should pass.


What do you see instead?

Whitespace is stripped from the beginning of the first and the end of the last line
only. The examples I provided fail.


Which version are you using?  (run 'go version')

Reproduced with 1.1 and devel +5981425e55ce Tue Sep 17 16:54:22 2013 -0400 darwin/amd64


Please provide any additional information below.

The documentation doesn't strictly imply this behavior -- it says "(The comparison
ignores leading and trailing space.)". However, the fact that gofmt strips trailing
whitespace makes it hard to write certain examples (e.g. those involving raw HTTP
requests/responses) without this behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions