Commit ec443730 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Zipfs: discover testdata location using runtime.Caller()

parent 6d5f84b0
......@@ -50,8 +50,7 @@ func TestMultiZipFs(t *testing.T) {
mountPoint, cleanup := setupMzfs()
defer cleanup()
wd, err := os.Getwd()
zipFile := wd + "/test.zip"
zipFile := testZipFile()
entries, err := ioutil.ReadDir(mountPoint)
CheckSuccess(err)
......
......@@ -4,13 +4,22 @@ import (
"github.com/hanwen/go-fuse/fuse"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"
)
func testZipFile() string {
_, file, _, ok := runtime.Caller(0)
if !ok {
panic("need runtime.Caller()'s file name to discover testdata")
}
dir, _ := filepath.Split(file)
return filepath.Join(dir, "test.zip")
}
func setupZipfs() (mountPoint string, cleanup func()) {
wd, err := os.Getwd()
CheckSuccess(err)
zfs, err := NewArchiveFileSystem(wd + "/test.zip")
zfs, err := NewArchiveFileSystem(testZipFile())
CheckSuccess(err)
mountPoint = fuse.MakeTempDir()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment