From af50f31f7dc264b810b2d13d1ce264df883c4e19 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 19 Nov 2017 19:58:09 +0000 Subject: [PATCH] mounttest: wait for Release after every Read to stop using in use files under Windows --- cmd/mountlib/mounttest/dir.go | 10 ++++------ cmd/mountlib/mounttest/fs.go | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/mountlib/mounttest/dir.go b/cmd/mountlib/mounttest/dir.go index 80ee6e7c7..81531d796 100644 --- a/cmd/mountlib/mounttest/dir.go +++ b/cmd/mountlib/mounttest/dir.go @@ -1,7 +1,6 @@ package mounttest import ( - "io/ioutil" "os" "testing" "time" @@ -78,17 +77,16 @@ func TestDirRenameFile(t *testing.T) { require.NoError(t, err) run.checkDir(t, "dir/|file2 6") - data, err := ioutil.ReadFile(run.path("file2")) - require.NoError(t, err) - assert.Equal(t, "potato", string(data)) + data := run.readFile(t, "file2") + assert.Equal(t, "potato", data) err = os.Rename(run.path("file2"), run.path("dir/file3")) require.NoError(t, err) run.checkDir(t, "dir/|dir/file3 6") - data, err = ioutil.ReadFile(run.path("dir/file3")) + data = run.readFile(t, "dir/file3") require.NoError(t, err) - assert.Equal(t, "potato", string(data)) + assert.Equal(t, "potato", data) run.rm(t, "dir/file3") run.rmdir(t, "dir") diff --git a/cmd/mountlib/mounttest/fs.go b/cmd/mountlib/mounttest/fs.go index 02b832a6a..8c0e90296 100644 --- a/cmd/mountlib/mounttest/fs.go +++ b/cmd/mountlib/mounttest/fs.go @@ -325,6 +325,7 @@ func (r *Run) readFile(t *testing.T, filepath string) string { filepath = r.path(filepath) result, err := ioutil.ReadFile(filepath) require.NoError(t, err) + time.Sleep(100 * time.Millisecond) // FIXME wait for Release return string(result) }