mounttest: wait for Release after every Read to stop using in use files under Windows

This commit is contained in:
Nick Craig-Wood 2017-11-19 19:58:09 +00:00
parent 8e2213fbbd
commit af50f31f7d
2 changed files with 5 additions and 6 deletions

View File

@ -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")

View File

@ -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)
}