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

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

View as plain text