summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/version_buildvcs_fossil.txt
blob: bd6b89d97aa5fe3569893c7d4c8d27d12151389e (plain)
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
# This test checks that VCS information is stamped into Go binaries by default,
# controlled with -buildvcs. This test focuses on Fossil specifics.
# The Git test covers common functionality.

# "fossil" is the Fossil file server on Plan 9.
[GOOS:plan9] skip
[!exec:fossil] skip
[short] skip
env GOBIN=$WORK/gopath/bin
env oldpath=$PATH
env HOME=$WORK
env USER=gopher
[!GOOS:windows] env fslckout=.fslckout
[GOOS:windows] env fslckout=_FOSSIL_
exec pwd
exec fossil init repo.fossil
cd repo/a

# If there's no local repository, there's no VCS info.
go install
go version -m $GOBIN/a$GOEXE
! stdout vcs.revision
rm $GOBIN/a$GOEXE

# If there is a repository, but it can't be used for some reason,
# there should be an error. It should hint about -buildvcs=false.
cd ..
mv fslckout $fslckout
env PATH=$WORK${/}fakebin${:}$oldpath
chmod 0755 $WORK/fakebin/fossil
! exec fossil help
cd a
! go install
stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
rm $GOBIN/a$GOEXE
cd ..
env PATH=$oldpath
rm $fslckout

# Revision and commit time are tagged for repositories with commits.
exec fossil open ../repo.fossil -f
exec fossil add a README
exec fossil commit -m 'initial commit'
cd a
go install
go version -m $GOBIN/a$GOEXE
stdout '^\tbuild\tvcs=fossil\n'
stdout '^\tbuild\tvcs.revision='
stdout '^\tbuild\tvcs.time='
stdout '^\tbuild\tvcs.modified=false$'
rm $GOBIN/a$GOEXE

# Building with -buildvcs=false suppresses the info.
go install -buildvcs=false
go version -m $GOBIN/a$GOEXE
! stdout vcs.revision
rm $GOBIN/a$GOEXE

# An untracked file is shown as modified, even if it isn't part of the build.
cp ../../outside/empty.txt .
go install
go version -m $GOBIN/a$GOEXE
stdout '^\tbuild\tvcs=fossil\n'
stdout '^\tbuild\tvcs.modified=true$'
rm empty.txt
rm $GOBIN/a$GOEXE

# An edited file is shown as modified, even if it isn't part of the build.
cp ../../outside/empty.txt ../README
go install
go version -m $GOBIN/a$GOEXE
stdout '^\tbuild\tvcs=fossil\n'
stdout '^\tbuild\tvcs.modified=true$'
exec fossil revert ../README
rm $GOBIN/a$GOEXE

-- $WORK/fakebin/fossil --
#!/bin/sh
exit 1
-- $WORK/fakebin/fossil.bat --
exit 1
-- repo/README --
Far out in the uncharted backwaters of the unfashionable end of the western
spiral arm of the Galaxy lies a small, unregarded yellow sun.
-- repo/fslckout --
-- repo/a/go.mod --
module example.com/a

go 1.18
-- repo/a/a.go --
package main

func main() {}
-- outside/empty.txt --