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) { ...@@ -50,8 +50,7 @@ func TestMultiZipFs(t *testing.T) {
mountPoint, cleanup := setupMzfs() mountPoint, cleanup := setupMzfs()
defer cleanup() defer cleanup()
wd, err := os.Getwd() zipFile := testZipFile()
zipFile := wd + "/test.zip"
entries, err := ioutil.ReadDir(mountPoint) entries, err := ioutil.ReadDir(mountPoint)
CheckSuccess(err) CheckSuccess(err)
......
...@@ -4,13 +4,22 @@ import ( ...@@ -4,13 +4,22 @@ import (
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath"
"runtime"
"testing" "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()) { func setupZipfs() (mountPoint string, cleanup func()) {
wd, err := os.Getwd() zfs, err := NewArchiveFileSystem(testZipFile())
CheckSuccess(err)
zfs, err := NewArchiveFileSystem(wd + "/test.zip")
CheckSuccess(err) CheckSuccess(err)
mountPoint = fuse.MakeTempDir() 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