1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-07-27 00:30:27 +00:00

test: Allow using an environment variable to override the test dir

Some build systems may not permit writing to . during build, so allow
that path to be overridden with an environment variable.
This commit is contained in:
Matthew Garrett 2017-04-13 11:35:01 -07:00
parent 93776cd69e
commit cb1fb5dded
3 changed files with 22 additions and 7 deletions

View file

@ -13,9 +13,14 @@ import (
)
func TestXattr(t *testing.T) {
// a bit dirty to create/destory a directory in cwd, but often /tmp is
// mounted tmpfs and doesn't support xattrs
dir, err := ioutil.TempDir(".", "test.xattrs.")
testDir, present := os.LookupEnv("MTREE_TESTDIR")
if present == false {
// a bit dirty to create/destory a directory in cwd,
// but often /tmp is mounted tmpfs and doesn't support
// xattrs
testDir = "."
}
dir, err := ioutil.TempDir(testDir, "test.xattrs.")
if err != nil {
t.Fatal(err)
}