Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
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
0
Merge Requests
0
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
Kirill Smelkov
jacobsa-fuse
Commits
ee8e869e
Commit
ee8e869e
authored
Mar 23, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buildMountSample
parent
5001868f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletion
+46
-1
samples/subprocess.go
samples/subprocess.go
+46
-1
No files found.
samples/subprocess.go
View file @
ee8e869e
...
...
@@ -20,7 +20,9 @@ import (
"io/ioutil"
"log"
"os/exec"
"path"
"strings"
"sync"
"time"
"github.com/jacobsa/bazilfuse"
...
...
@@ -63,9 +65,52 @@ func (t *SubprocessTest) SetUp(ti *ogletest.TestInfo) {
}
}
// Set by buildMountSample.
var
mountSamplePath
string
var
mountSampleErr
error
var
mountSampleOnce
sync
.
Once
// Build the mount_sample tool if it has not yet been built for this process.
// Return a path to the binary.
func
buildMountSample
()
(
path
string
,
err
error
)
func
buildMountSample
()
(
toolPath
string
,
err
error
)
{
// Build if we haven't yet.
mountSampleOnce
.
Do
(
func
()
{
// Create a temporary directory.
tempDir
,
err
:=
ioutil
.
TempDir
(
""
,
""
)
if
err
!=
nil
{
mountSampleErr
=
fmt
.
Errorf
(
"TempDir: %v"
,
err
)
return
}
mountSamplePath
=
path
.
Join
(
tempDir
,
"mount_sample"
)
// Build the command.
cmd
:=
exec
.
Command
(
"go"
,
"build"
,
"github.com/jacobsa/fuse/samples/mount_sample"
,
"-o"
,
mountSamplePath
)
output
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
mountSampleErr
=
fmt
.
Errorf
(
"mount_sample exited with %v, output:
\n
%s"
,
err
,
string
(
output
))
return
}
})
if
mountSampleErr
!=
nil
{
err
=
mountSampleErr
return
}
toolPath
=
mountSamplePath
return
}
// Invoke mount_sample, returning a running command.
func
invokeMountSample
(
path
string
,
args
[]
string
)
(
cmd
*
exec
.
Cmd
,
err
error
)
...
...
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