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

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

View as plain text