Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/cuetxtar: Append \n to generated txtar file content
Txtar archives cannot model files that lack a trailing newline. We have many tests that generate content and we then compare that content to files within txtar archives. Often, the generated content does not contain a trailing newline, which poses a problem when it must be compared to content from a txtar archive. We've typically worked around this by using `fmt.Fprintln` to write out the generated content, which adds the trailing newline. But this is fragile and you have to remember to use the println variant. In a couple of places we've done more elaborate trimming of content. Given this limitation of txtar archives, it is preferable to always ensure the generated file content (assuming there is some) ends with a newline, and to achieve this within the txtar test framework itself. As implemented here, this does not require any changes to our existing tests: the numerous sites where fmt.Fprintln is in use continue to work, but they are no longer necessary - using the plain buf.Write works just fine now. This has been tested with CUE_UPDATE=1 too, to ensure that that doesn't cause any churn. Signed-off-by: Matthew Sackman <[email protected]> Change-Id: I55a941c8b99198117af04e23f0c005df3dd09b4d Dispatch-Trailer: {"type":"trybot","CL":1210652,"patchset":1,"ref":"refs/changes/52/1210652/1","targetBranch":"master"}
- Loading branch information