forked from TrueCloudLab/rclone
mounttest: reduce duplicated code and improve test output #2154
The written out list of tests was replaced with a nested test for mount and cmount. The tests for each VFS cache mode were also replaced with nested tests which makes the output and the code much cleaner.
This commit is contained in:
parent
0fa700b3cf
commit
06e3fa3aba
3 changed files with 34 additions and 53 deletions
|
@ -14,26 +14,6 @@ import (
|
|||
"github.com/ncw/rclone/cmd/mountlib/mounttest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) { mounttest.TestMain(m, mount) }
|
||||
func TestDirLs(t *testing.T) { mounttest.TestDirLs(t) }
|
||||
func TestDirCreateAndRemoveDir(t *testing.T) { mounttest.TestDirCreateAndRemoveDir(t) }
|
||||
func TestDirCreateAndRemoveFile(t *testing.T) { mounttest.TestDirCreateAndRemoveFile(t) }
|
||||
func TestDirRenameFile(t *testing.T) { mounttest.TestDirRenameFile(t) }
|
||||
func TestDirRenameEmptyDir(t *testing.T) { mounttest.TestDirRenameEmptyDir(t) }
|
||||
func TestDirRenameFullDir(t *testing.T) { mounttest.TestDirRenameFullDir(t) }
|
||||
func TestDirModTime(t *testing.T) { mounttest.TestDirModTime(t) }
|
||||
func TestDirCacheFlush(t *testing.T) { mounttest.TestDirCacheFlush(t) }
|
||||
func TestDirCacheFlushOnDirRename(t *testing.T) { mounttest.TestDirCacheFlushOnDirRename(t) }
|
||||
func TestFileModTime(t *testing.T) { mounttest.TestFileModTime(t) }
|
||||
func TestFileModTimeWithOpenWriters(t *testing.T) { mounttest.TestFileModTimeWithOpenWriters(t) }
|
||||
func TestMount(t *testing.T) { mounttest.TestMount(t) }
|
||||
func TestRoot(t *testing.T) { mounttest.TestRoot(t) }
|
||||
func TestReadByByte(t *testing.T) { mounttest.TestReadByByte(t) }
|
||||
func TestReadChecksum(t *testing.T) { mounttest.TestReadChecksum(t) }
|
||||
func TestReadFileDoubleClose(t *testing.T) { mounttest.TestReadFileDoubleClose(t) }
|
||||
func TestReadSeek(t *testing.T) { mounttest.TestReadSeek(t) }
|
||||
func TestWriteFileNoWrite(t *testing.T) { mounttest.TestWriteFileNoWrite(t) }
|
||||
func TestWriteFileWrite(t *testing.T) { mounttest.TestWriteFileWrite(t) }
|
||||
func TestWriteFileOverwrite(t *testing.T) { mounttest.TestWriteFileOverwrite(t) }
|
||||
func TestWriteFileDoubleClose(t *testing.T) { mounttest.TestWriteFileDoubleClose(t) }
|
||||
func TestWriteFileFsync(t *testing.T) { mounttest.TestWriteFileFsync(t) }
|
||||
func TestMount(t *testing.T) {
|
||||
mounttest.RunTests(t, mount)
|
||||
}
|
||||
|
|
|
@ -8,26 +8,6 @@ import (
|
|||
"github.com/ncw/rclone/cmd/mountlib/mounttest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) { mounttest.TestMain(m, mount) }
|
||||
func TestDirLs(t *testing.T) { mounttest.TestDirLs(t) }
|
||||
func TestDirCreateAndRemoveDir(t *testing.T) { mounttest.TestDirCreateAndRemoveDir(t) }
|
||||
func TestDirCreateAndRemoveFile(t *testing.T) { mounttest.TestDirCreateAndRemoveFile(t) }
|
||||
func TestDirRenameFile(t *testing.T) { mounttest.TestDirRenameFile(t) }
|
||||
func TestDirRenameEmptyDir(t *testing.T) { mounttest.TestDirRenameEmptyDir(t) }
|
||||
func TestDirRenameFullDir(t *testing.T) { mounttest.TestDirRenameFullDir(t) }
|
||||
func TestDirModTime(t *testing.T) { mounttest.TestDirModTime(t) }
|
||||
func TestDirCacheFlush(t *testing.T) { mounttest.TestDirCacheFlush(t) }
|
||||
func TestDirCacheFlushOnDirRename(t *testing.T) { mounttest.TestDirCacheFlushOnDirRename(t) }
|
||||
func TestFileModTime(t *testing.T) { mounttest.TestFileModTime(t) }
|
||||
func TestFileModTimeWithOpenWriters(t *testing.T) { mounttest.TestFileModTimeWithOpenWriters(t) }
|
||||
func TestMount(t *testing.T) { mounttest.TestMount(t) }
|
||||
func TestRoot(t *testing.T) { mounttest.TestRoot(t) }
|
||||
func TestReadByByte(t *testing.T) { mounttest.TestReadByByte(t) }
|
||||
func TestReadChecksum(t *testing.T) { mounttest.TestReadChecksum(t) }
|
||||
func TestReadFileDoubleClose(t *testing.T) { mounttest.TestReadFileDoubleClose(t) }
|
||||
func TestReadSeek(t *testing.T) { mounttest.TestReadSeek(t) }
|
||||
func TestWriteFileNoWrite(t *testing.T) { mounttest.TestWriteFileNoWrite(t) }
|
||||
func TestWriteFileWrite(t *testing.T) { mounttest.TestWriteFileWrite(t) }
|
||||
func TestWriteFileOverwrite(t *testing.T) { mounttest.TestWriteFileOverwrite(t) }
|
||||
func TestWriteFileDoubleClose(t *testing.T) { mounttest.TestWriteFileDoubleClose(t) }
|
||||
func TestWriteFileFsync(t *testing.T) { mounttest.TestWriteFileFsync(t) }
|
||||
func TestMount(t *testing.T) {
|
||||
mounttest.RunTests(t, mount)
|
||||
}
|
||||
|
|
|
@ -37,11 +37,10 @@ var (
|
|||
mountFn MountFn
|
||||
)
|
||||
|
||||
// TestMain drives the tests
|
||||
func TestMain(m *testing.M, fn MountFn) {
|
||||
// RunTests runs all the tests against all the VFS cache modes
|
||||
func RunTests(t *testing.T, fn MountFn) {
|
||||
mountFn = fn
|
||||
flag.Parse()
|
||||
var rc int
|
||||
cacheModes := []vfs.CacheMode{
|
||||
vfs.CacheModeOff,
|
||||
vfs.CacheModeMinimal,
|
||||
|
@ -52,14 +51,36 @@ func TestMain(m *testing.M, fn MountFn) {
|
|||
for _, cacheMode := range cacheModes {
|
||||
run.cacheMode(cacheMode)
|
||||
log.Printf("Starting test run with cache mode %v", cacheMode)
|
||||
rc = m.Run()
|
||||
log.Printf("Finished test run with cache mode %v", cacheMode)
|
||||
if rc != 0 {
|
||||
ok := t.Run(fmt.Sprintf("CacheMode=%v", cacheMode), func(t *testing.T) {
|
||||
t.Run("TestDirLs", TestDirLs)
|
||||
t.Run("TestDirCreateAndRemoveDir", TestDirCreateAndRemoveDir)
|
||||
t.Run("TestDirCreateAndRemoveFile", TestDirCreateAndRemoveFile)
|
||||
t.Run("TestDirRenameFile", TestDirRenameFile)
|
||||
t.Run("TestDirRenameEmptyDir", TestDirRenameEmptyDir)
|
||||
t.Run("TestDirRenameFullDir", TestDirRenameFullDir)
|
||||
t.Run("TestDirModTime", TestDirModTime)
|
||||
t.Run("TestDirCacheFlush", TestDirCacheFlush)
|
||||
t.Run("TestDirCacheFlushOnDirRename", TestDirCacheFlushOnDirRename)
|
||||
t.Run("TestFileModTime", TestFileModTime)
|
||||
t.Run("TestFileModTimeWithOpenWriters", TestFileModTimeWithOpenWriters)
|
||||
t.Run("TestMount", TestMount)
|
||||
t.Run("TestRoot", TestRoot)
|
||||
t.Run("TestReadByByte", TestReadByByte)
|
||||
t.Run("TestReadChecksum", TestReadChecksum)
|
||||
t.Run("TestReadFileDoubleClose", TestReadFileDoubleClose)
|
||||
t.Run("TestReadSeek", TestReadSeek)
|
||||
t.Run("TestWriteFileNoWrite", TestWriteFileNoWrite)
|
||||
t.Run("TestWriteFileWrite", TestWriteFileWrite)
|
||||
t.Run("TestWriteFileOverwrite", TestWriteFileOverwrite)
|
||||
t.Run("TestWriteFileDoubleClose", TestWriteFileDoubleClose)
|
||||
t.Run("TestWriteFileFsync", TestWriteFileFsync)
|
||||
})
|
||||
log.Printf("Finished test run with cache mode %v (ok=%v)", cacheMode, ok)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
run.Finalise()
|
||||
os.Exit(rc)
|
||||
}
|
||||
|
||||
// Run holds the remotes for a test run
|
||||
|
|
Loading…
Reference in a new issue