Class: Nonnative::GoExecutable
- Inherits:
-
Object
- Object
- Nonnative::GoExecutable
- Defined in:
- lib/nonnative/go_executable.rb
Overview
Builds commands for running a Go test binary with optional profiling/trace/coverage flags.
This helper is used by YAML configuration when a process has a ‘go:` section (see Configuration).
The generated flags use Go’s ‘testing` package flags (e.g. `-test.cpuprofile=…`), so this is intended to run a binary compiled from `go test -c`.
## Tools
Tools can be enabled/disabled via the ‘tools` list. Supported values:
-
‘“prof”`: cpu/mem/block/mutex profiles
-
‘“trace”`: execution trace output
-
‘“cover”`: coverage profile output
If ‘tools` is `nil` or empty, all tools (`prof`, `trace`, `cover`) are enabled.
Parameter strings are parsed into argv words using shell-style quoting.
Instance Method Summary collapse
-
#argv(cmd, *params) ⇒ Array<String>
Returns an executable argv array including enabled ‘-test.*` flags.
-
#command(cmd, *params) ⇒ String
Returns an executable command string including enabled ‘-test.*` flags.
-
#initialize(tools, exec, output) ⇒ GoExecutable
constructor
A new instance of GoExecutable.
Constructor Details
#initialize(tools, exec, output) ⇒ GoExecutable
Returns a new instance of GoExecutable.
35 36 37 38 39 |
# File 'lib/nonnative/go_executable.rb', line 35 def initialize(tools, exec, output) @tools = tools.nil? || tools.empty? ? %w[prof trace cover] : tools @exec = exec @output = output end |
Instance Method Details
#argv(cmd, *params) ⇒ Array<String>
Returns an executable argv array including enabled ‘-test.*` flags.
A short random suffix is appended to output filenames to reduce collisions across runs.
48 49 50 |
# File 'lib/nonnative/go_executable.rb', line 48 def argv(cmd, *params) [exec, *flags(cmd), cmd, *parameter_args(params)] end |
#command(cmd, *params) ⇒ String
Returns an executable command string including enabled ‘-test.*` flags.
57 58 59 |
# File 'lib/nonnative/go_executable.rb', line 57 def command(cmd, *params) Shellwords.join(argv(cmd, *params)) end |