...

Text file src/cmd/go/testdata/script/version_buildvcs_svn.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 Subversion specifics.
     3# The Git test covers common functionality.
     4
     5[!exec:svn] skip
     6[!exec:svnadmin] skip
     7[short] skip
     8env GOBIN=$WORK/gopath/bin
     9env oldpath=$PATH
    10cd repo/a
    11
    12# If there's no local repository, there's no VCS info.
    13go install
    14go version -m $GOBIN/a$GOEXE
    15! stdout vcs.revision
    16stdout '\s+mod\s+example.com/a\s+\(devel\)'
    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 .svn
    23env PATH=$WORK${/}fakebin${:}$oldpath
    24chmod 0755 $WORK/fakebin/svn
    25! exec svn 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 .svn
    33
    34# Untagged repo.
    35exec svnadmin create repo
    36exec svn checkout file://$PWD/repo workingDir
    37cd workingDir
    38cp ../a/a.go .
    39cp ../a/go.mod .
    40cp ../README .
    41exec svn status
    42exec svn add a.go go.mod README
    43exec svn commit -m 'initial commit'
    44exec svn update
    45go install
    46go version -m $GOBIN/a$GOEXE
    47stdout '^\tbuild\tvcs=svn$'
    48stdout '^\tbuild\tvcs.revision=1$'
    49stdout '^\tbuild\tvcs.time='
    50stdout '^\tbuild\tvcs.modified=false$'
    51stdout '^\tmod\texample.com/a\tv0.0.0-\d+-\d+\t+'
    52rm $GOBIN/a$GOEXE
    53
    54# Building with -buildvcs=false suppresses the info.
    55go install -buildvcs=false
    56go version -m $GOBIN/a$GOEXE
    57! stdout vcs.revision
    58stdout '\s+mod\s+example.com/a\s+\(devel\)'
    59rm $GOBIN/a$GOEXE
    60
    61# An untracked file is shown as uncommitted, even if it isn't part of the build.
    62cp ../../outside/empty.txt extra.txt
    63go install
    64go version -m $GOBIN/a$GOEXE
    65stdout '^\tbuild\tvcs.modified=true$'
    66stdout '\s+mod\s+example.com/a\s+v0.0.0-\d+-\d+\+dirty\s+'
    67rm extra.txt
    68rm $GOBIN/a$GOEXE
    69
    70# An edited file is shown as uncommitted, even if it isn't part of the build.
    71cp ../../outside/empty.txt README
    72go install
    73go version -m $GOBIN/a$GOEXE
    74stdout '^\tbuild\tvcs.modified=true$'
    75stdout '\s+mod\s+example.com/a\s+v0.0.0-\d+-\d+\+dirty\s+'
    76exec svn revert README
    77rm $GOBIN/a$GOEXE
    78
    79-- $WORK/fakebin/svn --
    80#!/bin/sh
    81exit 1
    82-- $WORK/fakebin/svn.bat --
    83exit 1
    84-- repo/README --
    85Far out in the uncharted backwaters of the unfashionable end of the western
    86spiral arm of the Galaxy lies a small, unregarded yellow sun.
    87-- repo/a/go.mod --
    88module example.com/a
    89
    90go 1.18
    91-- repo/a/a.go --
    92package main
    93
    94func main() {}
    95
    96-- outside/empty.txt --

View as plain text