From f514bbfeb3b6c63a7dc5406cd660cab97122a901 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Mon, 8 Oct 2018 21:28:12 +0100 Subject: [PATCH] testdata: add test for get -vcs This uses an external network dependency. Sigh. --- testdata/get-vcs.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++ testdata/get.txt | 3 +++ 2 files changed, 62 insertions(+) create mode 100644 testdata/get-vcs.txt diff --git a/testdata/get-vcs.txt b/testdata/get-vcs.txt new file mode 100644 index 0000000..f7149f0 --- /dev/null +++ b/testdata/get-vcs.txt @@ -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 diff --git a/testdata/get.txt b/testdata/get.txt index 53d311d..23882c5 100644 --- a/testdata/get.txt +++ b/testdata/get.txt @@ -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