"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
test: move test commands under "rclone test" and make them visible
Nick Craig-Woodf88a5542cf24
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 2f071716a..96df841e3 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -333,8 +333,8 @@ Getting going* Try to implement as many optional methods as possible as it makes the remote more usable.* Use lib/encoder to make sure we can encode any path name and `rclone info` to help determine the encodings needed* `rclone purge -v TestRemote:rclone-info`- * `rclone info --remote-encoding None -vv --write-json remote.json TestRemote:rclone-info`- * `go run cmd/info/internal/build_csv/main.go -o remote.csv remote.json`+ * `rclone test info --all --remote-encoding None -vv --write-json remote.json TestRemote:rclone-info`+ * `go run cmd/test/info/internal/build_csv/main.go -o remote.csv remote.json`* open `remote.csv` in a spreadsheet and examineUnit testsdiff --git a/cmd/all/all.go b/cmd/all/all.goindex c3ad8bc78..6e195eff6 100644--- a/cmd/all/all.go+++ b/cmd/all/all.go@@ -25,7 +25,6 @@ import (_ "github.com/rclone/rclone/cmd/genautocomplete"_ "github.com/rclone/rclone/cmd/gendocs"_ "github.com/rclone/rclone/cmd/hashsum"- _ "github.com/rclone/rclone/cmd/info"_ "github.com/rclone/rclone/cmd/link"_ "github.com/rclone/rclone/cmd/listremotes"_ "github.com/rclone/rclone/cmd/ls"@@ -34,7 +33,6 @@ import (_ "github.com/rclone/rclone/cmd/lsjson"_ "github.com/rclone/rclone/cmd/lsl"_ "github.com/rclone/rclone/cmd/md5sum"- _ "github.com/rclone/rclone/cmd/memtest"_ "github.com/rclone/rclone/cmd/mkdir"_ "github.com/rclone/rclone/cmd/mount"_ "github.com/rclone/rclone/cmd/mount2"@@ -54,6 +52,9 @@ import (_ "github.com/rclone/rclone/cmd/sha1sum"_ "github.com/rclone/rclone/cmd/size"_ "github.com/rclone/rclone/cmd/sync"+ _ "github.com/rclone/rclone/cmd/test"+ _ "github.com/rclone/rclone/cmd/test/info"+ _ "github.com/rclone/rclone/cmd/test/memory"_ "github.com/rclone/rclone/cmd/touch"_ "github.com/rclone/rclone/cmd/tree"_ "github.com/rclone/rclone/cmd/version"diff --git a/cmd/info/all.sh b/cmd/test/info/all.shsimilarity index 100%rename from cmd/info/all.shrename to cmd/test/info/all.shdiff --git a/cmd/info/info.go b/cmd/test/info/info.gosimilarity index 92%rename from cmd/info/info.gorename to cmd/test/info/info.goindex c2006f20a..377353c36 100644--- a/cmd/info/info.go+++ b/cmd/test/info/info.go@@ -1,7 +1,7 @@package info// FIXME once translations are implemented will need a no-escape-// option for Put so we can make these tests work agaig+// option for Put so we can make these tests work againimport ("bytes"@@ -9,6 +9,7 @@ import ("encoding/json""fmt""io"+ "log""os""path""regexp"@@ -20,7 +21,8 @@ import ("github.com/pkg/errors""github.com/rclone/rclone/cmd"- "github.com/rclone/rclone/cmd/info/internal"+ "github.com/rclone/rclone/cmd/test"+ "github.com/rclone/rclone/cmd/test/info/internal""github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/config/flags""github.com/rclone/rclone/fs/hash"@@ -35,6 +37,7 @@ var (checkControl boolcheckLength boolcheckStreaming bool+ all booluploadWait time.DurationpositionLeftRe = regexp.MustCompile(`(?s)^(.*)-position-left-([[:xdigit:]]+)$`)positionMiddleRe = regexp.MustCompile(`(?s)^position-middle-([[:xdigit:]]+)-(.*)-$`)@@ -42,14 +45,15 @@ var ()func init() {- cmd.Root.AddCommand(commandDefinition)+ test.Command.AddCommand(commandDefinition)cmdFlags := commandDefinition.Flags()flags.StringVarP(cmdFlags, &writeJSON, "write-json", "", "", "Write results to file.")- flags.BoolVarP(cmdFlags, &checkNormalization, "check-normalization", "", true, "Check UTF-8 Normalization.")- flags.BoolVarP(cmdFlags, &checkControl, "check-control", "", true, "Check control characters.")+ flags.BoolVarP(cmdFlags, &checkNormalization, "check-normalization", "", false, "Check UTF-8 Normalization.")+ flags.BoolVarP(cmdFlags, &checkControl, "check-control", "", false, "Check control characters.")flags.DurationVarP(cmdFlags, &uploadWait, "upload-wait", "", 0, "Wait after writing a file.")- flags.BoolVarP(cmdFlags, &checkLength, "check-length", "", true, "Check max filename length.")- flags.BoolVarP(cmdFlags, &checkStreaming, "check-streaming", "", true, "Check uploads with indeterminate file size.")+ flags.BoolVarP(cmdFlags, &checkLength, "check-length", "", false, "Check max filename length.")+ flags.BoolVarP(cmdFlags, &checkStreaming, "check-streaming", "", false, "Check uploads with indeterminate file size.")+ flags.BoolVarP(cmdFlags, &all, "all", "", false, "Run all tests.")}var commandDefinition = &cobra.Command{@@ -59,10 +63,20 @@ var commandDefinition = &cobra.Command{to write to the paths passed in and how long they can be. It can take sometime. It will write test files into the remote:path passed in. It outputsa bit of go code for each one.++**NB** this can create undeletable files and other hazards - use with care`,- Hidden: true,Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1e6, command, args)+ if !checkNormalization && !checkControl && !checkLength && !checkStreaming && !all {+ log.Fatalf("no tests selected - select a test or use -all")+ }+ if all {+ checkNormalization = true+ checkControl = true+ checkLength = true+ checkStreaming = true+ }for i := range args {f := cmd.NewFsDir(args[i : i+1])cmd.Run(false, false, command, func() error {diff --git a/cmd/info/internal/build_csv/main.go b/cmd/test/info/internal/build_csv/main.gosimilarity index 98%rename from cmd/info/internal/build_csv/main.gorename to cmd/test/info/internal/build_csv/main.goindex 8e173dbdd..96aa20a19 100644--- a/cmd/info/internal/build_csv/main.go+++ b/cmd/test/info/internal/build_csv/main.go@@ -11,7 +11,7 @@ import ("sort""strconv"- "github.com/rclone/rclone/cmd/info/internal"+ "github.com/rclone/rclone/cmd/test/info/internal")func main() {diff --git a/cmd/info/internal/internal.go b/cmd/test/info/internal/internal.gosimilarity index 100%rename from cmd/info/internal/internal.gorename to cmd/test/info/internal/internal.godiff --git a/cmd/info/test.cmd b/cmd/test/info/test.cmdsimilarity index 100%rename from cmd/info/test.cmdrename to cmd/test/info/test.cmddiff --git a/cmd/info/test.sh b/cmd/test/info/test.shsimilarity index 100%rename from cmd/info/test.shrename to cmd/test/info/test.shdiff --git a/cmd/memtest/memtest.go b/cmd/test/memory/memory.gosimilarity index 85%rename from cmd/memtest/memtest.gorename to cmd/test/memory/memory.goindex f31b1a5e2..0fbf216fc 100644--- a/cmd/memtest/memtest.go+++ b/cmd/test/memory/memory.go@@ -1,4 +1,4 @@-package memtest+package memoryimport ("context"@@ -6,19 +6,19 @@ import ("sync""github.com/rclone/rclone/cmd"+ "github.com/rclone/rclone/cmd/test""github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/operations""github.com/spf13/cobra")func init() {- cmd.Root.AddCommand(commandDefinition)+ test.Command.AddCommand(commandDefinition)}var commandDefinition = &cobra.Command{- Use: "memtest remote:path",- Short: `Load all the objects at remote:path and report memory stats.`,- Hidden: true,+ Use: "memory remote:path",+ Short: `Load all the objects at remote:path into memory and report memory stats.`,Run: func(command *cobra.Command, args []string) {cmd.CheckArgs(1, 1, command, args)fsrc := cmd.NewFsSrc(args)diff --git a/cmd/test/test.go b/cmd/test/test.gonew file mode 100644index 000000000..39f5ccb29--- /dev/null+++ b/cmd/test/test.go@@ -0,0 +1,27 @@+package test++import (+ "github.com/rclone/rclone/cmd"+ "github.com/spf13/cobra"+)++func init() {+ cmd.Root.AddCommand(Command)+}++// Command definition for cobra+var Command = &cobra.Command{+ Use: "test <subcommand>",+ Short: `Run a test command`,+ Long: `Rclone test is used to run test commands.++Select which test comand you want with the subcommand, eg++ rclone test memory remote:++Each subcommand has its own options which you can see in their help.++**NB** Be careful running these commands, they may do strange things+so reading their documentation first is recommended.+`,+}