MCPcopy
hub / github.com/rclone/rclone / checkRcloneBinaryVersion

Function checkRcloneBinaryVersion

cmd/gitannex/e2e_test.go:25–53  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
25func 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.

Callers 1

skipE2eTestIfNecessaryFunction · 0.85

Calls 4

GetLinkingAndTagsFunction · 0.92
LogfMethod · 0.80
CommandMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…