-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
diagnose.txtar
102 lines (78 loc) · 3.12 KB
/
diagnose.txtar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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=