From 3f1d7047169e32fd8d7858098304ad976cdbd355 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 23 Apr 2015 12:25:12 +0200 Subject: [PATCH] functional tests: use the correct version of go when using sudo The functional tests use sudo because the tests need to be run as root. Sudo does not preserve $PATH. When the user use a home-built go, it might have a different version thatn the system-wide installed go. It causes problems when linking the tests with github.com/coreos/rkt/common This patch fixes the issue by using the go environment of the user. --- tests/test | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test b/tests/test index 4fb9ac4..9fa6ee1 100755 --- a/tests/test +++ b/tests/test @@ -13,5 +13,10 @@ # To run only one test: # $ cd tests && ./test -run=TestEnv -sudo GOPATH="${PWD}/../gopath" RKT_ENABLE_DESTRUCTIVE_TESTS="$RKT_ENABLE_DESTRUCTIVE_TESTS" go test -v $* +# Sudo does not preserve $PATH. Use go from the user's $PATH instead of +# root's $PATH. It is needed when a home-built go does not have the same +# version as the system-wide installed go. +GO=`which go` + +sudo GOPATH="${PWD}/../gopath" RKT_ENABLE_DESTRUCTIVE_TESTS="$RKT_ENABLE_DESTRUCTIVE_TESTS" GOROOT="$GOROOT" $GO test -v $*