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 package mounttest
import ( import (
"io/ioutil"
"os" "os"
"testing" "testing"
"time" "time"
@ -78,17 +77,16 @@ func TestDirRenameFile(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
run.checkDir(t, "dir/|file2 6") run.checkDir(t, "dir/|file2 6")
data, err := ioutil.ReadFile(run.path("file2")) data := run.readFile(t, "file2")
require.NoError(t, err) assert.Equal(t, "potato", data)
assert.Equal(t, "potato", string(data))
err = os.Rename(run.path("file2"), run.path("dir/file3")) err = os.Rename(run.path("file2"), run.path("dir/file3"))
require.NoError(t, err) require.NoError(t, err)
run.checkDir(t, "dir/|dir/file3 6") 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) require.NoError(t, err)
assert.Equal(t, "potato", string(data)) assert.Equal(t, "potato", data)
run.rm(t, "dir/file3") run.rm(t, "dir/file3")
run.rmdir(t, "dir") run.rmdir(t, "dir")

View File

@ -325,6 +325,7 @@ func (r *Run) readFile(t *testing.T, filepath string) string {
filepath = r.path(filepath) filepath = r.path(filepath)
result, err := ioutil.ReadFile(filepath) result, err := ioutil.ReadFile(filepath)
require.NoError(t, err) require.NoError(t, err)
time.Sleep(100 * time.Millisecond) // FIXME wait for Release
return string(result) return string(result)
} }