diff --git a/cmd/cmount/mount_test.go b/cmd/cmount/mount_test.go index b6c6baab5..110fb16f9 100644 --- a/cmd/cmount/mount_test.go +++ b/cmd/cmount/mount_test.go @@ -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) +} diff --git a/cmd/mount/mount_test.go b/cmd/mount/mount_test.go index a2d56efb3..51ec05d3b 100644 --- a/cmd/mount/mount_test.go +++ b/cmd/mount/mount_test.go @@ -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) +} diff --git a/cmd/mountlib/mounttest/fs.go b/cmd/mountlib/mounttest/fs.go index ef7047b5e..7f5043317 100644 --- a/cmd/mountlib/mounttest/fs.go +++ b/cmd/mountlib/mounttest/fs.go @@ -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