...

Text file src/cmd/go/testdata/script/version_buildvcs_bzr.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 Bazaar specifics.
     3# The Git test covers common functionality.
     4
     5[!exec:bzr] skip
     6[short] skip
     7env GOBIN=$WORK/gopath/bin
     8env oldpath=$PATH
     9env HOME=$WORK
    10cd repo/a
    11exec bzr whoami 'J.R. Gopher <gopher@golang.org>'
    12
    13# If there's no local repository, there's no VCS info.
    14go install
    15go version -m $GOBIN/a$GOEXE
    16! stdout bzrrevision
    17rm $GOBIN/a$GOEXE
    18
    19# If there is a repository, but it can't be used for some reason,
    20# there should be an error. It should hint about -buildvcs=false.
    21cd ..
    22mkdir .bzr
    23env PATH=$WORK${/}fakebin${:}$oldpath
    24chmod 0755 $WORK/fakebin/bzr
    25! exec bzr help
    26cd a
    27! go install
    28stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    29rm $GOBIN/a$GOEXE
    30cd ..
    31env PATH=$oldpath
    32rm .bzr
    33
    34# If there is an empty repository in a parent directory, only "modified" is tagged.
    35exec bzr init
    36cd a
    37go install
    38go version -m $GOBIN/a$GOEXE
    39stdout '^\tbuild\tvcs=bzr$'
    40! stdout vcs.revision
    41! stdout vcs.time
    42stdout '^\tbuild\tvcs.modified=true$'
    43cd ..
    44
    45# Revision and commit time are tagged for repositories with commits.
    46exec bzr add a README
    47exec bzr commit -m 'initial commit'
    48cd a
    49go install
    50go version -m $GOBIN/a$GOEXE
    51stdout '^\tbuild\tvcs=bzr$'
    52stdout '^\tbuild\tvcs.revision='
    53stdout '^\tbuild\tvcs.time='
    54stdout '^\tbuild\tvcs.modified=false$'
    55rm $GOBIN/a$GOEXE
    56
    57# Building an earlier commit should still build clean.
    58cp ../../outside/empty.txt ../NEWS
    59exec bzr add ../NEWS
    60exec bzr commit -m 'add NEWS'
    61exec bzr update -r1
    62go install
    63go version -m $GOBIN/a$GOEXE
    64stdout '^\tbuild\tvcs=bzr$'
    65stdout '^\tbuild\tvcs.revision='
    66stdout '^\tbuild\tvcs.time='
    67stdout '^\tbuild\tvcs.modified=false$'
    68
    69# Building with -buildvcs=false suppresses the info.
    70go install -buildvcs=false
    71go version -m $GOBIN/a$GOEXE
    72! stdout vcs.revision
    73rm $GOBIN/a$GOEXE
    74
    75# An untracked file is shown as modified, even if it isn't part of the build.
    76cp ../../outside/empty.txt .
    77go install
    78go version -m $GOBIN/a$GOEXE
    79stdout '^\tbuild\tvcs.modified=true$'
    80rm empty.txt
    81rm $GOBIN/a$GOEXE
    82
    83# An edited file is shown as modified, even if it isn't part of the build.
    84cp ../../outside/empty.txt ../README
    85go install
    86go version -m $GOBIN/a$GOEXE
    87stdout '^\tbuild\tvcs.modified=true$'
    88exec bzr revert ../README
    89rm $GOBIN/a$GOEXE
    90
    91-- $WORK/fakebin/bzr --
    92#!/bin/sh
    93exit 1
    94-- $WORK/fakebin/bzr.bat --
    95exit 1
    96-- repo/README --
    97Far out in the uncharted backwaters of the unfashionable end of the western
    98spiral arm of the Galaxy lies a small, unregarded yellow sun.
    99-- repo/a/go.mod --
   100module example.com/a
   101
   102go 1.18
   103-- repo/a/a.go --
   104package main
   105
   106func main() {}
   107-- outside/empty.txt --

View as plain text