Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
88cc7a86
Commit
88cc7a86
authored
Jul 31, 2018
by
Jacob Vosmaer (GitLab)
Committed by
Nick Thomas
Jul 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop calling 'make' from 'go test'
parent
25d866fa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
58 deletions
+34
-58
Makefile
Makefile
+16
-8
internal/artifacts/artifacts_test.go
internal/artifacts/artifacts_test.go
+3
-8
internal/testhelper/testhelper.go
internal/testhelper/testhelper.go
+10
-23
main_test.go
main_test.go
+5
-19
No files found.
Makefile
View file @
88cc7a86
...
...
@@ -6,32 +6,34 @@ export PATH:=${GOPATH}/bin:${PATH}
GOBUILD
=
go build
-ldflags
"-X main.Version=
${VERSION}
"
PKG
=
gitlab.com/gitlab-org/gitlab-workhorse
PKG_ALL
=
$(
shell
GOPATH
=
${GOPATH}
go list
${PKG}
/... |
grep
-v
/vendor/
)
EXE_ALL
=
gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
all
:
clean-build
gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
all
:
clean-build
$(EXE_ALL)
gitlab-zip-cat
:
${BUILD_DIR}/_build $(shell find cmd/gitlab-zip-cat/ -name '*.go')
gitlab-zip-cat
:
${BUILD_DIR}/_build
/.sync
$(shell find cmd/gitlab-zip-cat/ -name '*.go')
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
/cmd/
$@
gitlab-zip-metadata
:
${BUILD_DIR}/_build $(shell find cmd/gitlab-zip-metadata/ -name '*.go')
gitlab-zip-metadata
:
${BUILD_DIR}/_build
/.sync
$(shell find cmd/gitlab-zip-metadata/ -name '*.go')
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
/cmd/
$@
gitlab-workhorse
:
${BUILD_DIR}/_build $(shell find . -name '*.go' | grep -v '^
\.
/_')
gitlab-workhorse
:
${BUILD_DIR}/_build
/.sync
$(shell find . -name '*.go' | grep -v '^
\.
/_')
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
install
:
gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
mkdir
-p
$(DESTDIR)${PREFIX}
/bin/
cd
${BUILD_DIR}
&&
install
gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
${DESTDIR}${PREFIX}
/bin/
${BUILD_DIR}/_build
:
mkdir
-p
$
@
/src/
${PKG}
tar
-cf
-
--exclude
_build
--exclude
.git
.
|
(
cd
$
@
/src/
${PKG}
&&
tar
-xf
-
)
${BUILD_DIR}/_build
/.sync
:
mkdir
-p
$
{BUILD_DIR}
/_build
/src/
${PKG}
tar
-cf
-
--exclude
_build
--exclude
.git
.
|
(
cd
$
{BUILD_DIR}
/_build
/src/
${PKG}
&&
tar
-xf
-
)
touch
$@
.PHONY
:
test
test
:
clean-build clean-workhorse
all govendor
test
:
clean-build clean-workhorse
govendor prepare-tests
go
fmt
${PKG_ALL}
|
awk
'{ print } END { if (NR > 0) { print "Please run go fmt"; exit 1 } }'
_support/detect-context.sh
cd
${GOPATH}
/src/
${PKG}
&&
govendor
sync
cp
$(EXE_ALL)
${GOPATH}
/src/
${PKG}
go
test
${PKG_ALL}
@
echo
SUCCESS
...
...
@@ -61,3 +63,9 @@ release:
.PHONY
:
clean-build
clean-build
:
rm
-rf
${BUILD_DIR}
/_build
.PHONY
:
prepare-tests
prepare-tests
:
testdata/data/group/test.git $(EXE_ALL)
testdata/data/group/test.git
:
git clone
--quiet
--bare
https://gitlab.com/gitlab-org/gitlab-test.git
$@
internal/artifacts/artifacts_test.go
View file @
88cc7a86
...
...
@@ -10,15 +10,10 @@ import (
)
func
TestMain
(
m
*
testing
.
M
)
{
cleanup
,
err
:=
testhelper
.
BuildExecutables
()
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Print
(
"Test setup: failed to build executables"
)
os
.
Exit
(
1
)
if
err
:=
testhelper
.
BuildExecutables
();
err
!=
nil
{
log
.
WithError
(
err
)
.
Fatal
()
}
os
.
Exit
(
func
()
int
{
defer
cleanup
()
return
m
.
Run
()
}())
os
.
Exit
(
m
.
Run
())
}
internal/testhelper/testhelper.go
View file @
88cc7a86
...
...
@@ -5,11 +5,9 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"os/exec"
"path"
"regexp"
"runtime"
...
...
@@ -126,35 +124,24 @@ func TestServerWithHandler(url *regexp.Regexp, handler http.HandlerFunc) *httpte
}))
}
func
BuildExecutables
()
(
func
(),
error
)
{
rootDir
:=
RootDir
()
var
workhorseExecutables
=
[]
string
{
"gitlab-workhorse"
,
"gitlab-zip-cat"
,
"gitlab-zip-metadata"
}
// This method will be invoked more than once due to Go test
// parallelization. We must use a unique temp directory for each
// invokation so that they do not trample each other's builds.
testDir
,
err
:=
ioutil
.
TempDir
(
""
,
"gitlab-workhorse-test"
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"could not create temp directory"
)
}
func
BuildExecutables
()
error
{
rootDir
:=
RootDir
()
makeCmd
:=
exec
.
Command
(
"make"
,
"BUILD_DIR="
+
testDir
)
makeCmd
.
Dir
=
rootDir
makeCmd
.
Stderr
=
os
.
Stderr
makeCmd
.
Stdout
=
os
.
Stdout
if
err
:=
makeCmd
.
Run
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to run %v in %v"
,
makeCmd
,
rootDir
)
for
_
,
exe
:=
range
workhorseExecutables
{
if
_
,
err
:=
os
.
Stat
(
path
.
Join
(
rootDir
,
exe
));
os
.
IsNotExist
(
err
)
{
return
fmt
.
Errorf
(
"cannot find executable %s. Please run 'make prepare-tests'"
,
exe
)
}
}
oldPath
:=
os
.
Getenv
(
"PATH"
)
testPath
:=
fmt
.
Sprintf
(
"%s:%s"
,
tes
tDir
,
oldPath
)
testPath
:=
fmt
.
Sprintf
(
"%s:%s"
,
roo
tDir
,
oldPath
)
if
err
:=
os
.
Setenv
(
"PATH"
,
testPath
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to set PATH to %v"
,
testPath
)
return
fmt
.
Errorf
(
"failed to set PATH to %v"
,
testPath
)
}
return
func
()
{
os
.
Setenv
(
"PATH"
,
oldPath
)
os
.
RemoveAll
(
testDir
)
},
nil
return
nil
}
func
RootDir
()
string
{
...
...
main_test.go
View file @
88cc7a86
...
...
@@ -45,31 +45,17 @@ var cacheDir = path.Join(scratchDir, "cache")
func
TestMain
(
m
*
testing
.
M
)
{
git
.
Testing
=
true
source
:=
"https://gitlab.com/gitlab-org/gitlab-test.git"
clonePath
:=
path
.
Join
(
testRepoRoot
,
testRepo
)
if
_
,
err
:=
os
.
Stat
(
clonePath
);
err
!=
nil
{
testCmd
:=
exec
.
Command
(
"git"
,
"clone"
,
"--bare"
,
source
,
clonePath
)
testCmd
.
Stdout
=
os
.
Stdout
testCmd
.
Stderr
=
os
.
Stderr
if
err
:=
testCmd
.
Run
();
err
!=
nil
{
log
.
WithField
(
"testCmd"
,
testCmd
)
.
Print
(
"Test setup: failed to run"
)
os
.
Exit
(
-
1
)
}
if
_
,
err
:=
os
.
Stat
(
path
.
Join
(
testRepoRoot
,
testRepo
));
os
.
IsNotExist
(
err
)
{
log
.
Fatal
(
"cannot find test repository. Please run 'make prepare-tests'"
)
}
cleanup
,
err
:=
testhelper
.
BuildExecutables
()
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Print
(
"Test setup: failed to build executables"
)
os
.
Exit
(
1
)
if
err
:=
testhelper
.
BuildExecutables
();
err
!=
nil
{
log
.
WithError
(
err
)
.
Fatal
()
}
defer
gitaly
.
CloseConnections
()
os
.
Exit
(
func
()
int
{
defer
cleanup
()
return
m
.
Run
()
}())
os
.
Exit
(
m
.
Run
())
}
func
TestAllowedClone
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment