...

Text file src/cmd/go/testdata/script/version_buildvcs_fossil.txt

Documentation: cmd/go/testdata/script

     1# This test checks that VCS information is stamped into Go binaries by default,
     2# controlled with -buildvcs. This test focuses on Fossil specifics.
     3# The Git test covers common functionality.
     4
     5# "fossil" is the Fossil file server on Plan 9.
     6[GOOS:plan9] skip
     7[!exec:fossil] skip
     8[short] skip
     9env GOBIN=$WORK/gopath/bin
    10env oldpath=$PATH
    11env HOME=$WORK
    12env USER=gopher
    13[!GOOS:windows] env fslckout=.fslckout
    14[GOOS:windows] env fslckout=_FOSSIL_
    15exec pwd
    16exec fossil init repo.fossil
    17cd repo/a
    18
    19# If there's no local repository, there's no VCS info.
    20go install
    21go version -m $GOBIN/a$GOEXE
    22! stdout vcs.revision
    23rm $GOBIN/a$GOEXE
    24
    25# If there is a repository, but it can't be used for some reason,
    26# there should be an error. It should hint about -buildvcs=false.
    27cd ..
    28mv fslckout $fslckout
    29env PATH=$WORK${/}fakebin${:}$oldpath
    30chmod 0755 $WORK/fakebin/fossil
    31! exec fossil help
    32cd a
    33! go install
    34stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    35rm $GOBIN/a$GOEXE
    36cd ..
    37env PATH=$oldpath
    38rm $fslckout
    39
    40# Revision and commit time are tagged for repositories with commits.
    41exec fossil open ../repo.fossil -f
    42exec fossil add a README
    43exec fossil commit -m 'initial commit'
    44cd a
    45go install
    46go version -m $GOBIN/a$GOEXE
    47stdout '^\tbuild\tvcs=fossil\n'
    48stdout '^\tbuild\tvcs.revision='
    49stdout '^\tbuild\tvcs.time='
    50stdout '^\tbuild\tvcs.modified=false$'
    51rm $GOBIN/a$GOEXE
    52
    53# Building with -buildvcs=false suppresses the info.
    54go install -buildvcs=false
    55go version -m $GOBIN/a$GOEXE
    56! stdout vcs.revision
    57rm $GOBIN/a$GOEXE
    58
    59# An untracked file is shown as modified, even if it isn't part of the build.
    60cp ../../outside/empty.txt .
    61go install
    62go version -m $GOBIN/a$GOEXE
    63stdout '^\tbuild\tvcs=fossil\n'
    64stdout '^\tbuild\tvcs.modified=true$'
    65rm empty.txt
    66rm $GOBIN/a$GOEXE
    67
    68# An edited file is shown as modified, even if it isn't part of the build.
    69cp ../../outside/empty.txt ../README
    70go install
    71go version -m $GOBIN/a$GOEXE
    72stdout '^\tbuild\tvcs=fossil\n'
    73stdout '^\tbuild\tvcs.modified=true$'
    74exec fossil revert ../README
    75rm $GOBIN/a$GOEXE
    76
    77-- $WORK/fakebin/fossil --
    78#!/bin/sh
    79exit 1
    80-- $WORK/fakebin/fossil.bat --
    81exit 1
    82-- repo/README --
    83Far out in the uncharted backwaters of the unfashionable end of the western
    84spiral arm of the Galaxy lies a small, unregarded yellow sun.
    85-- repo/fslckout --
    86-- repo/a/go.mod --
    87module example.com/a
    88
    89go 1.18
    90-- repo/a/a.go --
    91package main
    92
    93func main() {}
    94-- outside/empty.txt --

View as plain text