checkRcloneBinaryVersion runs whichever rclone is on the PATH and checks whether it reports a version that matches the test's expectations. Returns nil when the version is the expected version, otherwise returns an error.
(t *testing.T)
| 23 | // whether it reports a version that matches the test's expectations. Returns |
| 24 | // nil when the version is the expected version, otherwise returns an error. |
| 25 | func checkRcloneBinaryVersion(t *testing.T) error { |
| 26 | // versionInfo is a subset of information produced by "core/version". |
| 27 | type versionInfo struct { |
| 28 | Version string |
| 29 | IsGit bool |
| 30 | GoTags string |
| 31 | } |
| 32 | |
| 33 | cmd := exec.Command("rclone", "rc", "--loopback", "core/version") |
| 34 | stdout, err := cmd.Output() |
| 35 | require.NoError(t, err) |
| 36 | |
| 37 | var parsed versionInfo |
| 38 | if err := json.Unmarshal(stdout, &parsed); err != nil { |
| 39 | return fmt.Errorf("failed to parse rclone version: %w", err) |
| 40 | } |
| 41 | if parsed.Version != fs.Version { |
| 42 | return fmt.Errorf("expected version %q, but got %q", fs.Version, parsed.Version) |
| 43 | } |
| 44 | if parsed.IsGit != strings.HasSuffix(fs.Version, "-DEV") { |
| 45 | return errors.New("expected rclone to be a dev build") |
| 46 | } |
| 47 | _, tagString := buildinfo.GetLinkingAndTags() |
| 48 | if parsed.GoTags != tagString { |
| 49 | // TODO: Skip the test when tags do not match. |
| 50 | t.Logf("expected tag string %q, but got %q. Not skipping!", tagString, parsed.GoTags) |
| 51 | } |
| 52 | return nil |
| 53 | } |
| 54 | |
| 55 | // countFilesRecursively returns the number of files nested underneath `dir`. It |
| 56 | // counts files only and excludes directories. |
no test coverage detected
searching dependent graphs…