From adf4e05079f1ffeb040d53e158ab527918f660cb Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Mon, 26 Feb 2018 01:21:53 -0500 Subject: [PATCH] test, build: Fix gopath creation --- build | 41 +++++++++++++++++++++++++++++++++++++++++ test | 6 +++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/build b/build index 2a73e0114..c8b6ce06a 100755 --- a/build +++ b/build @@ -23,6 +23,26 @@ toggle_failpoints() { fi } +etcd_setup_gopath() { + echo "Setting GOPATH from vendor directory at 'gopath'" + d=$(dirname "$0") + CDIR=$(cd "$d" && pwd) + cd "$CDIR" + etcdGOPATH="${CDIR}/gopath" + # preserve old gopath to support building with unvendored tooling deps (e.g., gofail) + if [ -n "$GOPATH" ]; then + GOPATH="$GOPATH" + fi + rm -rf "${etcdGOPATH:?}/" + mkdir -p "${etcdGOPATH}/vendor" "${etcdGOPATH}/etcd_src/src/github.com/coreos" + export GOPATH=${etcdGOPATH}/vendor:${etcdGOPATH}/etcd_src:$GOPATH + ln -s "${CDIR}/vendor" "${etcdGOPATH}/vendor/src" + ln -s "${CDIR}" "${etcdGOPATH}/etcd_src/src/github.com/coreos/etcd" + + #ln -s "${CDIR}/vendor" "${etcdGOPATH}/src" + #ln -s "${CDIR}" "${etcdGOPATH}/src/github.com/coreos" +} + toggle_failpoints_default() { mode="disable" if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi @@ -41,6 +61,27 @@ etcd_build() { CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o "${out}/etcdctl" ${REPO_PATH}/etcdctl || return } +tools_build() { + out="bin" + if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi + # shellcheck disable=SC2039 + tools=( + benchmark + etcd-dump-db + etcd-dump-logs + functional-tester/etcd-agent + functional-tester/etcd-tester + functional-tester/etcd-runner + local-tester/bridge + ) + # shellcheck disable=SC2039 + for tool in "${tools[@]}" + do + # shellcheck disable=SC2086 + CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o "${out}/${tool}" "${REPO_PATH}/tools/${tool}" || return + done +} + toggle_failpoints_default # only build when called directly, not sourced diff --git a/test b/test index 04ed92ec8..3dd6e9914 100755 --- a/test +++ b/test @@ -16,6 +16,10 @@ set -e source ./build +if [[ "${ETCD_SETUP_GOPATH}" == "1" ]]; then + etcd_setup_gopath +fi + # build before setting up test GOPATH if [[ "${PASSES}" == *"functional"* ]]; then ./tools/functional-tester/build @@ -540,7 +544,7 @@ function build_cov_pass { function compile_pass { echo "Checking build..." - go build -v ./tools/... + GO_BUILD_FLAGS="-a -v" tools_build } # fail fast on static tests