top

A wrapper around the os/exec package that supports timeouts and testing.

Example usage:

Simple command with argument: err := Run(&Command{

Name: "touch",
Args: []string{file},

})

More complicated example: output := bytes.Buffer{} err := Run(&Command{

Name: "make",
Args: []string{"all"},
// Set environment:
Env: []string{fmt.Sprintf("GOPATH=%s", projectGoPath)},
// Set working directory:
Dir: projectDir,
// Capture output:
CombinedOutput: &output,
// Set a timeout:
Timeout: 10*time.Minute,

})

Inject a Run function for testing: var actualCommand *Command SetRunForTesting(func(command *Command) error {

actualCommand = command
return nil

}) defer SetRunForTesting(DefaultRun) TestCodeCallingRun() expect.Equal(t, "touch", actualCommand.Name) expect.Equal(t, 1, len(actualCommand.Args)) expect.Equal(t, file, actualCommand.Args[0])

Types and functions to help with testing code that uses exec.Run.

Imported by 43 package(s)

  1. github.com/google/skia-buildbot/go/android_skia_checkout
  2. github.com/google/skia-buildbot/go/buildbucket/generate
  3. github.com/google/skia-buildbot/go/buildskia
  4. github.com/google/skia-buildbot/go/cq/generate
  5. github.com/google/skia-buildbot/go/dataproc
  6. github.com/google/skia-buildbot/go/exec/testutils
  7. github.com/google/skia-buildbot/go/gce
  8. github.com/google/skia-buildbot/go/gce/swarming
  9. github.com/google/skia-buildbot/go/git
  10. github.com/google/skia-buildbot/go/git/git_common
  11. github.com/google/skia-buildbot/go/git/gitinfo
  12. github.com/google/skia-buildbot/go/git/testutils
  13. github.com/google/skia-buildbot/go/gitinfo
  14. github.com/google/skia-buildbot/go/gitrepo
  15. github.com/google/skia-buildbot/go/isolate
  16. github.com/google/skia-buildbot/go/packages
  17. github.com/google/skia-buildbot/go/swarming
  18. github.com/google/skia-buildbot/scripts/roll_recipe_deps
  19. github.com/jcgregorio/piccolo/piccolo
  20. go.skia.org/infra/go/buildbucket/generate
  21. go.skia.org/infra/go/buildskia
  22. go.skia.org/infra/go/cq/generate
  23. go.skia.org/infra/go/exec/testutils
  24. go.skia.org/infra/go/git
  25. go.skia.org/infra/go/git/gitinfo
  26. go.skia.org/infra/go/git/testutils
  27. go.skia.org/infra/go/gitinfo
  28. go.skia.org/infra/go/gitrepo
  29. go.skia.org/infra/go/isolate
  30. go.skia.org/infra/go/packages
  31. go.skia.org/infra/go/swarming
  32. go.skia.org/infra/scripts/roll_recipe_deps
  33. skia.googlesource.com/buildbot.git/go/buildbucket/generate
  34. skia.googlesource.com/buildbot.git/go/buildskia
  35. skia.googlesource.com/buildbot.git/go/cq/generate
  36. skia.googlesource.com/buildbot.git/go/exec/testutils
  37. skia.googlesource.com/buildbot.git/go/git
  38. skia.googlesource.com/buildbot.git/go/git/gitinfo
  39. skia.googlesource.com/buildbot.git/go/git/testutils
  40. skia.googlesource.com/buildbot.git/go/isolate
  41. skia.googlesource.com/buildbot.git/go/packages
  42. skia.googlesource.com/buildbot.git/go/swarming
  43. skia.googlesource.com/buildbot.git/scripts/roll_recipe_deps

Imports 2 package(s)

  1. go.skia.org/infra/go/sklog
  2. go.skia.org/infra/go/util

Test imports 3 package(s)

  1. github.com/stretchr/testify/assert
  2. github.com/stretchr/testify/require
  3. go.skia.org/infra/go/testutils