autogold
autogold copied to clipboard
go test -update doesn't work when /tmp and workdir are different devices (?)
Hi! When running go test -update
on a freshly created tests I get:
❯ go test -update 2021-03-16 15:19:44
--- FAIL: Test_WorstScores_nilResult (0.00s)
autogold.go:82: rename testdata/nil.golden /tmp/go-golden-074934610/nil.golden: invalid cross-device link
FAIL
exit status 1
FAIL <pkg name redacted> 0.006s
service/dashboard/score on master #.
❯ 2021-03-16 15:19:54
relevant mounts:
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,nr_inodes=409600,inode64)
/dev/mapper/mainroot on /home type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache,subvolid=258,subvol=/@home)
This is weird, I assume that most people have /tmp
mounted as tmpfs
, so someone else should already encounter this error.
Thanks for filing this. I think that atomic renames are not possible across tmpfs <-> other file systems and this has gone unnoticed on Mac OS and WSL environments, as those are the main places I have tested autogold.
To fix this, I think we will need to change the tmp dir to be in the same directory as the Go package itself here1 and here2
However, this introduces some challenges since autogold can currently leave some of these tmp files around if your tests crash, we may need https://github.com/hexops/autogold/issues/8 to be fixed in order for this to be a nice experience all around.
I'll see if I can get to this soon.