Skip to content

Commit

Permalink
testdata: add test for get -vcs
Browse files Browse the repository at this point in the history
This uses an external network dependency. Sigh.
  • Loading branch information
rogpeppe committed Oct 8, 2018
1 parent 877e07b commit f514bbf
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
59 changes: 59 additions & 0 deletions testdata/get-vcs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This is thame as get.txt except that we use the -vcs flag
# on gohack get. Until we can figure out better, this requires
# access to the network.

[!net] skip
[!exec:git] skip
env GOPROXY=

cd repo
go get rsc.io/quote@v1.5.2
env GOHACK=$WORK/gohack
gohack get -vcs rsc.io/quote
stdout '^rsc.io/quote => .*/gohack/rsc.io/quote$'
! stderr .+

# Check that the replace statement is there.
grep -count=1 '^replace rsc\.io/quote => .*/gohack/rsc.io/quote$' go.mod

# Check that it's a git repository
exists $WORK/gohack/rsc.io/quote/.git

# Check that the source files have been copied.
grep '^' $WORK/gohack/rsc.io/quote/quote.go

# Check that we can compile the command OK.
go install example.com/repo

# Hack the package a bit and check that it doesn't compile
# any more.
cp ../bogus.go $WORK/gohack/rsc.io/quote/bogus.go
! go install example.com/repo
stderr 'found packages wrong \(bogus\.go\) and quote \(quote\.go\)'

# Use git to reset the package.
cd $WORK/gohack/rsc.io/quote
exec git clean -xf

# We should be able to compile it again.
cd $WORK/repo
go install

-- repo/main.go --

package main
import (
"fmt"
"rsc.io/quote"
)

func main() {
fmt.Println(quote.Glass())
}

-- repo/go.mod --
module example.com/repo

-- bogus.go --

package wrong
3 changes: 3 additions & 0 deletions testdata/get.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ grep -count=1 '^replace rsc\.io/quote => .*/gohack/rsc.io/quote$' go.mod
# Check that the source files have been copied.
grep '^' $WORK/gohack/rsc.io/quote/quote.go

# It should not be a git repository.
! exists $WORK/gohack/rsc.io/quote/.git

# Check that we can compile the command OK.
go install example.com/repo

Expand Down

0 comments on commit f514bbf

Please sign in to comment.