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
56a4377c
Commit
56a4377c
authored
Aug 15, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify BuildExecutables
parent
75ba7ebe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
37 deletions
+2
-37
internal/testhelper/testhelper.go
internal/testhelper/testhelper.go
+2
-37
No files found.
internal/testhelper/testhelper.go
View file @
56a4377c
...
...
@@ -15,12 +15,6 @@ import (
"testing"
)
var
executables
=
[]
string
{
"gitlab-workhorse"
,
"gitlab-zip-cat"
,
"gitlab-zip-metadata"
,
}
func
AssertResponseCode
(
t
*
testing
.
T
,
response
*
httptest
.
ResponseRecorder
,
expectedCode
int
)
{
if
response
.
Code
!=
expectedCode
{
t
.
Fatalf
(
"for HTTP request expected to get %d, got %d instead"
,
expectedCode
,
response
.
Code
)
...
...
@@ -72,13 +66,6 @@ func BuildExecutables() (func(), error) {
return
nil
,
errors
.
New
(
"could not create temp directory"
)
}
for
_
,
executable
:=
range
executables
{
utilPath
:=
path
.
Join
(
testDir
,
executable
)
if
err
:=
os
.
Remove
(
utilPath
);
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
nil
,
fmt
.
Errorf
(
"failed to remove: %v"
,
utilPath
)
}
}
makeCmd
:=
exec
.
Command
(
"make"
,
"BUILD_DIR="
+
testDir
)
makeCmd
.
Dir
=
rootDir
makeCmd
.
Stderr
=
os
.
Stderr
...
...
@@ -87,32 +74,10 @@ func BuildExecutables() (func(), error) {
return
nil
,
fmt
.
Errorf
(
"failed to run %v in %v"
,
makeCmd
,
rootDir
)
}
for
_
,
executable
:=
range
executables
{
utilPath
:=
path
.
Join
(
testDir
,
executable
)
if
_
,
err
:=
os
.
Stat
(
utilPath
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not stat %v"
,
utilPath
)
}
}
// Try to ensure the list of executables is complete by asking "make" to only build files in the list.
cleanArgs
:=
append
([]
string
{
"clean-workhorse"
},
executables
...
)
cleanArgs
=
append
(
cleanArgs
,
"BUILD_DIR="
+
testDir
)
makeCmd
=
exec
.
Command
(
"make"
,
cleanArgs
...
)
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
)
}
oldPath
:=
os
.
Getenv
(
"PATH"
)
testPath
:=
fmt
.
Sprintf
(
"%s:%s"
,
testDir
,
oldPath
)
for
_
,
setting
:=
range
[]
struct
{
key
,
value
string
}{
{
"PATH"
,
testPath
},
}
{
if
err
:=
os
.
Setenv
(
setting
.
key
,
setting
.
value
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to set %v to %v"
,
setting
.
key
,
setting
.
value
)
}
if
err
:=
os
.
Setenv
(
"PATH"
,
testPath
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to set PATH to %v"
,
testPath
)
}
return
func
()
{
...
...
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