diff options
author | Baodong <wwwicbd@gmail.com> | 2021-06-24 17:35:42 +0300 |
---|---|---|
committer | Baodong <wwwicbd@gmail.com> | 2021-06-24 17:35:42 +0300 |
commit | ef158adf3f8b8e418bcbbdf008af04b3448c5626 (patch) | |
tree | d34c8810b0ab47802c120fc0fb25e0326dd39165 | |
parent | 7dd92a725c85375ad19a92aa74e073d2347a2a75 (diff) |
Reassign the base directory of TempDir
UNIX-domain addresses are variable-length filesystem pathnames of at most 104 characters.
In order to avoid getting a too long temporary directory on mac, we need to specify a short base temporary directory.
You can set test temporary directory by environment variable "TEST_TMP_DIR" .
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | internal/testhelper/configure.go | 19 |
2 files changed, 16 insertions, 5 deletions
@@ -152,6 +152,7 @@ TEST_OUTPUT_NAME ?= go-${GO_VERSION}-git-${GIT_VERSION} TEST_OUTPUT ?= ${TEST_REPORT_DIR}/go-tests-output-${TEST_OUTPUT_NAME}.txt TEST_REPORT ?= ${TEST_REPORT_DIR}/go-tests-report-${TEST_OUTPUT_NAME}.xml TEST_EXIT ?= ${TEST_REPORT_DIR}/go-tests-exit-${TEST_OUTPUT_NAME}.txt +TEST_TMP_DIR ?= TEST_REPO_DIR := ${BUILD_DIR}/testrepos TEST_REPO := ${TEST_REPO_DIR}/gitlab-test.git TEST_REPO_GIT := ${TEST_REPO_DIR}/gitlab-git-test.git @@ -172,6 +173,7 @@ find_go_sources = $(shell find ${SOURCE_DIR} -type d \( -name ruby -o -nam # TEST_PACKAGES: packages which shall be tested run_go_tests = PATH='${SOURCE_DIR}/internal/testhelper/testdata/home/bin:${PATH}' \ GIT_DIR=/dev/null \ + TEST_TMP_DIR='${TEST_TMP_DIR}' \ go test ${GO_LDFLAGS} -tags '${GO_BUILD_TAGS}' ${TEST_OPTIONS} ${TEST_PACKAGES} unexport GOROOT diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go index 4f22c5f8f..f7758e4e8 100644 --- a/internal/testhelper/configure.go +++ b/internal/testhelper/configure.go @@ -31,11 +31,7 @@ func Configure() func() { configureOnce.Do(func() { gitalylog.Configure(gitalylog.Loggers, "json", "panic") - var err error - testDirectory, err = ioutil.TempDir("", "gitaly-") - if err != nil { - log.Fatal(err) - } + testDirectory = getTestTmpDir() for _, f := range []func() error{ ConfigureGit, @@ -212,3 +208,16 @@ func buildCommand(t testing.TB, outputDir, cmd string) { } MustRunCommand(t, nil, "go", goBuildArgs...) } + +func getTestTmpDir() string { + testTmpDir := os.Getenv("TEST_TMP_DIR") + if testTmpDir != "" { + return testTmpDir + } + + testTmpDir, err := ioutil.TempDir("/tmp/", "gitaly-") + if err != nil { + log.Fatal(err) + } + return testTmpDir +} |