103 lines
3.1 KiB
Plaintext
103 lines
3.1 KiB
Plaintext
env GO_VERSION_TEST=go1.18.29
|
|
|
|
# First, test a local build of gofumpt resulting from 'git clone'.
|
|
# Its version will be inferred from VCS, but since we want a stable test,
|
|
# we mock the VCS information. Note that test binaries do not have VCS info.
|
|
# Data obtained from a real build while developing.
|
|
env GARBLE_TEST_BUILDSETTINGS='[{"Key":"vcs","Value":"git"},{"Key":"vcs.revision","Value":"8dda8068d9f339047fc1777b688afb66a0a0db17"},{"Key":"vcs.time","Value":"2022-07-27T15:58:40Z"},{"Key":"vcs.modified","Value":"true"}]'
|
|
exec gofumpt foo.go
|
|
cmp stdout foo.go.golden
|
|
|
|
exec gofumpt outdated.go
|
|
cmp stdout foo.go.golden
|
|
|
|
exec gofumpt -extra foo.go
|
|
cmp stdout foo.go.golden-extra
|
|
|
|
exec gofumpt -lang=1.0 foo.go
|
|
cmp stdout foo.go.golden-lang
|
|
|
|
exec gofumpt -d nochange.go
|
|
! stdout .
|
|
|
|
exec gofumpt -d foo.go.golden
|
|
! stdout .
|
|
|
|
exec gofumpt -d -extra foo.go.golden-extra
|
|
! stdout .
|
|
|
|
# A local build without VCS information will result in a missing version.
|
|
env GARBLE_TEST_BUILDSETTINGS='[]'
|
|
exec gofumpt foo.go
|
|
cmp stdout foo.go.golden-devel
|
|
|
|
[short] stop 'the rest of this test builds gofumpt binaries'
|
|
|
|
# We want a published version of gofumpt on the public module proxies,
|
|
# because that's the only way that its module version will be included.
|
|
# Using a directory replace directive will not work.
|
|
# This means that any change in how gofumpt reports its own version
|
|
# will require two pull requests, the second one updating the test script.
|
|
# We could consider using go-internal/goproxytest, but then we would need to
|
|
# manually run something like go-internal/cmd/txtar-addmod reguarly.
|
|
# Or teach goproxytest to serve a mock version of gofumpt from its local checkout.
|
|
# Either way, both are relatively overkill for now.
|
|
env GOBIN=${WORK}/bin
|
|
env GOFUMPT_PUBLISHED_VERSION=v0.3.2-0.20220627183521-8dda8068d9f3
|
|
|
|
# TODO: update these once the library fix hits master
|
|
|
|
# gofumpt as the main binary with a real module version.
|
|
go install mvdan.cc/gofumpt@${GOFUMPT_PUBLISHED_VERSION}
|
|
exec ${GOBIN}/gofumpt foo.go
|
|
cmp stdout foo.go.golden-released
|
|
|
|
# gofumpt as a library with a real module version.
|
|
cd ${GOMOD_DIR}/testdata/gofumpt-external
|
|
go install .
|
|
cd ${WORK}
|
|
stdin foo.go
|
|
exec ${GOBIN}/gofumpt-external
|
|
cmp stdout foo.go.golden-external
|
|
|
|
-- go.mod --
|
|
module test
|
|
|
|
go 1.16
|
|
-- foo.go --
|
|
package p
|
|
|
|
//gofumpt:diagnose
|
|
-- outdated.go --
|
|
package p
|
|
|
|
//gofumpt:diagnose v0.1.0
|
|
-- nochange.go --
|
|
package p
|
|
|
|
//gofumpt:diagnosefoobar
|
|
-- foo.go.golden --
|
|
package p
|
|
|
|
//gofumpt:diagnose version: v0.0.0-20220727155840-8dda8068d9f3 (go1.18.29) flags: -lang=v1.16 -modpath=test
|
|
-- foo.go.golden-devel --
|
|
package p
|
|
|
|
//gofumpt:diagnose version: (devel) (go1.18.29) flags: -lang=v1.16 -modpath=test
|
|
-- foo.go.golden-extra --
|
|
package p
|
|
|
|
//gofumpt:diagnose version: v0.0.0-20220727155840-8dda8068d9f3 (go1.18.29) flags: -lang=v1.16 -modpath=test -extra
|
|
-- foo.go.golden-lang --
|
|
package p
|
|
|
|
//gofumpt:diagnose version: v0.0.0-20220727155840-8dda8068d9f3 (go1.18.29) flags: -lang=v1.0 -modpath=test
|
|
-- foo.go.golden-released --
|
|
package p
|
|
|
|
//gofumpt:diagnose v0.3.2-0.20220627183521-8dda8068d9f3 -lang=v1.16 -modpath=test
|
|
-- foo.go.golden-external --
|
|
package p
|
|
|
|
//gofumpt:diagnose (devel) -lang=v1.16 -modpath=
|