Class: Nonnative::GoCommand
- Inherits:
-
Object
- Object
- Nonnative::GoCommand
- Defined in:
- lib/nonnative/go_command.rb
Overview
Builds command lines for running a Go test binary with optional profiling/trace/coverage flags.
This helper is used by go_executable and 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.
Instance Method Summary collapse
-
#executable(cmd, *params) ⇒ String
Returns an executable command string including enabled
-test.*flags. -
#initialize(tools, exec, output) ⇒ GoCommand
constructor
A new instance of GoCommand.
Constructor Details
#initialize(tools, exec, output) ⇒ GoCommand
Returns a new instance of GoCommand.
32 33 34 35 36 |
# File 'lib/nonnative/go_command.rb', line 32 def initialize(tools, exec, output) @tools = tools.nil? || tools.empty? ? %w[prof trace cover] : tools @exec = exec @output = output end |
Instance Method Details
#executable(cmd, *params) ⇒ String
Returns an executable command string including enabled -test.* flags.
A short random suffix is appended to output filenames to reduce collisions across runs.
45 46 47 48 |
# File 'lib/nonnative/go_command.rb', line 45 def executable(cmd, *params) params = params.join(' ') "#{exec} #{flags(cmd).join(' ')} #{cmd} #{params}".strip end |