...

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
    17stdout '^\tmod\texample.com/a\t\(devel\)'
    18rm $GOBIN/a$GOEXE
    19
    20# If there is a repository, but it can't be used for some reason,
    21# there should be an error. It should hint about -buildvcs=false.
    22cd ..
    23mkdir .bzr
    24env PATH=$WORK${/}fakebin${:}$oldpath
    25chmod 0755 $WORK/fakebin/bzr
    26! exec bzr help
    27cd a
    28! go install
    29stderr '^error obtaining VCS status: exit status 1\n\tUse -buildvcs=false to disable VCS stamping.$'
    30rm $GOBIN/a$GOEXE
    31cd ..
    32env PATH=$oldpath
    33rm .bzr
    34
    35# If there is an empty repository in a parent directory, only "modified" is tagged.
    36exec bzr init
    37cd a
    38go install
    39go version -m $GOBIN/a$GOEXE
    40stdout '^\tbuild\tvcs=bzr$'
    41! stdout vcs.revision
    42! stdout vcs.time
    43stdout '^\tbuild\tvcs.modified=true$'
    44cd ..
    45
    46# Revision and commit time are tagged for repositories with commits.
    47exec bzr add a README
    48exec bzr commit -m 'initial commit'
    49cd a
    50go install
    51go version -m $GOBIN/a$GOEXE
    52stdout '^\tbuild\tvcs=bzr$'
    53stdout '^\tbuild\tvcs.revision='
    54stdout '^\tbuild\tvcs.time='
    55stdout '^\tbuild\tvcs.modified=false$'
    56stdout '^\tmod\texample.com/a\tv0.0.0-\d+-\d+\t+'
    57rm $GOBIN/a$GOEXE
    58
    59# Tag is reflected in the version.
    60cd ..
    61cp README README2
    62exec bzr add a README2
    63exec bzr commit -m 'second commit'
    64exec bzr tag v1.2.3
    65cd a
    66go install
    67go version -m $GOBIN/a$GOEXE
    68stdout '^\tbuild\tvcs=bzr$'
    69stdout '^\tbuild\tvcs.revision='
    70stdout '^\tbuild\tvcs.time='
    71stdout '^\tbuild\tvcs.modified=false$'
    72stdout '^\tmod\texample.com/a\tv1.2.3\t+'
    73rm $GOBIN/a$GOEXE
    74
    75# Building an earlier commit should still build clean.
    76cp ../../outside/empty.txt ../NEWS
    77exec bzr add ../NEWS
    78exec bzr commit -m 'add NEWS'
    79exec bzr update -r1
    80go install
    81go version -m $GOBIN/a$GOEXE
    82stdout '^\tbuild\tvcs=bzr$'
    83stdout '^\tbuild\tvcs.revision='
    84stdout '^\tbuild\tvcs.time='
    85stdout '^\tbuild\tvcs.modified=false$'
    86
    87# Building with -buildvcs=false suppresses the info.
    88go install -buildvcs=false
    89go version -m $GOBIN/a$GOEXE
    90! stdout vcs.revision
    91rm $GOBIN/a$GOEXE
    92
    93# An untracked file is shown as modified, even if it isn't part of the build.
    94cp ../../outside/empty.txt .
    95go install
    96go version -m $GOBIN/a$GOEXE
    97stdout '^\tbuild\tvcs.modified=true$'
    98rm empty.txt
    99rm $GOBIN/a$GOEXE
   100
   101# An edited file is shown as modified, even if it isn't part of the build.
   102cp ../../outside/empty.txt ../README
   103go install
   104go version -m $GOBIN/a$GOEXE
   105stdout '^\tbuild\tvcs.modified=true$'
   106exec bzr revert ../README
   107rm $GOBIN/a$GOEXE
   108
   109-- $WORK/fakebin/bzr --
   110#!/bin/sh
   111exit 1
   112-- $WORK/fakebin/bzr.bat --
   113exit 1
   114-- repo/README --
   115Far out in the uncharted backwaters of the unfashionable end of the western
   116spiral arm of the Galaxy lies a small, unregarded yellow sun.
   117-- repo/a/go.mod --
   118module example.com/a
   119
   120go 1.18
   121-- repo/a/a.go --
   122package main
   123
   124func main() {}
   125-- outside/empty.txt --

View as plain text