Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-05-20 19:06:52 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-05-20 19:12:56 +0300
commit5844b2d0ddb98c135b7c58531979f268b1b4c4d7 (patch)
treee136d50583892c9523426b16f354996bc322d7f2
parent0ee0fc45f6feebae2983cec02494273d91ca485c (diff)
Makefile: Add canary for tests using outside Git envvars
In order to catch cases early where we do not sanitize Git environment variables passed to us by the outside, this commit adds a canary to our Makefile by setting `GIT_DIR=/dev/null` for our tests. If any test does not sanitize envvars, then our spawned Git commands would pick up this envvar, assume it as their repository path and (hopefully) end up failing in a controlled way. This does indeed detect one case where we spawn Git commands but don't yet sanitize the environment, which is also getting fixed by this commit.
-rw-r--r--Makefile1
-rw-r--r--internal/gitaly/config/testhelper_test.go19
2 files changed, 20 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index ac5731c15..806d646e3 100644
--- a/Makefile
+++ b/Makefile
@@ -165,6 +165,7 @@ find_go_sources = $(shell find ${SOURCE_DIR} -type d \( -name ruby -o -nam
# TEST_OPTIONS: any additional options
# TEST_PACKAGES: packages which shall be tested
run_go_tests = PATH='${SOURCE_DIR}/internal/testhelper/testdata/home/bin:${PATH}' \
+ GIT_DIR=/dev/null \
go test -tags '${GO_BUILD_TAGS}' ${TEST_OPTIONS} ${TEST_PACKAGES}
unexport GOROOT
diff --git a/internal/gitaly/config/testhelper_test.go b/internal/gitaly/config/testhelper_test.go
new file mode 100644
index 000000000..04e13330d
--- /dev/null
+++ b/internal/gitaly/config/testhelper_test.go
@@ -0,0 +1,19 @@
+package config_test
+
+import (
+ "os"
+ "testing"
+
+ "gitlab.com/gitlab-org/gitaly/internal/testhelper"
+)
+
+func TestMain(m *testing.M) {
+ os.Exit(testMain(m))
+}
+
+func testMain(m *testing.M) int {
+ defer testhelper.MustHaveNoChildProcess()
+ cleanup := testhelper.Configure()
+ defer cleanup()
+ return m.Run()
+}