Skip to content

[Bug]: go-snaps breaks, when tests are compiled with GOFLAGS=-trimpath #118

@klaernie

Description

@klaernie

Description

In editorconfig-checker we received bug reports from our users, that they failed building editorconfig-checker. Upon closer inspection we determined that this started occurring when we introduced snapshot testing using go-snaps, and being caused by their build systems (Arch and Alpine) globally setting $GOFLAGS to include -trimpath.

Should you want to read back into our analysis, you can find it in editorconfig-checker/editorconfig-checker#397.

From my perspective this issue arises from -trimpath trimming part of the path used by go-snaps to find it's __snapshots__ folders.

Steps to Reproduce

Run demonstrate.sh from https://github.com/klaernie/trimpath-repro.

It demonstrates the issue by creating a directory which would be created by go-snaps, making it non-writable to everyone. It then demonstrates that running go test ./... works fine, as long as GOFLAGS does not contain -trimpath.

Expected Behavior

snapshot verification should not depend if the test binary is build under -trimpath

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions