nonnative 2.19.1 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08e1e5b760ed902c52e55ef0694bddeb1e36580891ab9a778767a04ea02b1d9c'
4
- data.tar.gz: d632a3b8047ebada176e3db071caada192b87d8c255d6beb0e14a1010874103f
3
+ metadata.gz: 50e3259a9203deec0efaadd273f5dbb0af97707e7226399147e081c57c19e1a9
4
+ data.tar.gz: 3986e9250edbf08bd3b570610849cc6f6a998dc1773ef14eee7cb9da45771db6
5
5
  SHA512:
6
- metadata.gz: bfeba487e42d817e967c0a1cfe0814e5fc75c4d360399dcbd0caaf6ddef83c11efb8a4aff8ffe58ee6566be138b3b85e146e5ffe44dc431e734cf22544956019
7
- data.tar.gz: 268c3d360f3d23b18a69317cbe656b06d24b8f94799c245108e94e5e269ac852c000d74d3427168fd2ad5b2c56ea24a3bb21e1507c77d9e4cce713fac4b57a3b
6
+ metadata.gz: b7d31913722e55932103ab8855d3a01b4fccc358dfec987e16ebc6978cc39f6a34eed25f46d788084a3fa665fe5af9165da4091f8d512064ef550e12aa26c817
7
+ data.tar.gz: 8f3aa8a30785c105735916ba45275ee3f72d1f1d76edec4399124a262995664e7866901ca18cb7d9b85a7108196b46bf8c76d2376e6505d628f15854c821de9a
data/AGENTS.md CHANGED
@@ -29,7 +29,8 @@ of dependencies.
29
29
 
30
30
  Public entry point: `lib/nonnative.rb`.
31
31
 
32
- Main API: `configure`, `start`, `stop`, `clear`, `reset`, `pool`.
32
+ Main API: `configure`, `start`, `stop`, `clear`, `reset`, `pool`,
33
+ `go_argv`, `go_command`.
33
34
 
34
35
  Configuration is `Nonnative::Configuration`, built with
35
36
  `config.process`, `config.server`, `config.service`, or
@@ -81,7 +82,8 @@ Config rules:
81
82
 
82
83
  - YAML config is loaded as data only via `Nonnative::ConfigurationFile`; ERB is not evaluated and arbitrary Ruby object tags are rejected
83
84
  - Runner `host` and nested `proxy.host` default to `127.0.0.1`; use explicit `0.0.0.0` only when external access is intended
84
- - Process `command` can be a legacy shell string or an argv array; prefer argv arrays for new config, and `go:` config builds argv internally
85
+ - Process `command` can be a legacy shell string or an argv array; prefer argv arrays for new config, and `go:` config builds argv internally with `Nonnative.go_argv`
86
+ - Use `Nonnative.go_argv` for no-shell Go executable argv entries and `Nonnative.go_command` only when a caller needs Ruby shell-style command string spawning
85
87
  - YAML services belong under `services:`, not `processes:`
86
88
  - There is no top-level `config.wait`; `wait` is per runner
87
89
  - Programmatic service config uses `config.service do |s| ... end`, so use `s.host` / `s.port`
@@ -108,6 +110,7 @@ Limitations:
108
110
  - Lifecycle: `lib/nonnative.rb`, `lib/nonnative/pool.rb`
109
111
  - Readiness/timeouts: `lib/nonnative/port.rb`, `lib/nonnative/timeout.rb`
110
112
  - Process lifecycle: `lib/nonnative/process.rb`
113
+ - Go executable command/argv building: `lib/nonnative/go_executable.rb`
111
114
  - Proxies: `lib/nonnative/fault_injection_proxy.rb`, `lib/nonnative/socket_pair_factory.rb`
112
115
  - Cucumber: `lib/nonnative/cucumber.rb`, `lib/nonnative/startup.rb`, `features/support/env.rb`
113
116
  - Config loading: `lib/nonnative/configuration.rb`, `lib/nonnative/configuration_file.rb`, `lib/nonnative/configuration_runner.rb`, `lib/nonnative/configuration_proxy.rb`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (2.19.1)
4
+ nonnative (2.21.0)
5
5
  concurrent-ruby (>= 1, < 2)
6
6
  config (>= 5, < 6)
7
7
  cucumber (>= 7, < 12)
data/README.md CHANGED
@@ -781,12 +781,14 @@ Programmatic Go binaries can be configured as normal argv process commands:
781
781
  Nonnative.configure do |config|
782
782
  config.process do |p|
783
783
  p.name = 'go'
784
- p.command = -> { ['your_binary', 'sub_command', '--config', 'config.yaml'] }
784
+ p.command = -> { Nonnative.go_argv(%w[cover], 'reports', 'your_binary', 'sub_command', '-i file:.config/server.yml') }
785
785
  p.port = 12_345
786
786
  end
787
787
  end
788
788
  ```
789
789
 
790
+ Use `Nonnative.go_argv(...)` when a process should execute without shell interpretation, and `Nonnative.go_command(...)` when a caller needs a command string for Ruby's shell-style `spawn` behavior.
791
+
790
792
  YAML `go:` configuration is for Go test binaries compiled with `go test -c`. It builds argv entries in this order: executable, optional `-test.*` profiling/trace/coverage flags, command, then parameters. Parameter strings are parsed into argv words with shell-style quoting, but the argv entries are executed without shell interpretation.
791
793
 
792
794
  To get this to work you will need to create a `main_test.go` file with these contents:
@@ -141,7 +141,7 @@ module Nonnative
141
141
  params = go.parameters || []
142
142
  tools = go.tools || []
143
143
 
144
- -> { Nonnative.go_executable_args(tools, go.output, go.executable, go.command, *params) }
144
+ -> { Nonnative.go_argv(tools, go.output, go.executable, go.command, *params) }
145
145
  else
146
146
  -> { process.command }
147
147
  end
@@ -88,7 +88,7 @@ module Nonnative
88
88
  end
89
89
 
90
90
  module LifecycleSteps
91
- SERVICE_UNAVAILABLE = 'Service Unavailable'
91
+ SERVICE_UNAVAILABLE = 'service unavailable'
92
92
 
93
93
  def install_state_steps
94
94
  install_start_step
@@ -126,11 +126,12 @@ module Nonnative
126
126
  opts = observability_options
127
127
 
128
128
  Then('I should see {string} as unhealthy') do |service|
129
+ service = service.downcase
129
130
  wait_for { Nonnative.observability.health(opts).code }.to eq(503)
130
131
  wait_for { Nonnative.observability.health(opts).body }.to satisfy do |body|
131
- body = body.to_s.strip
132
+ body = body.to_s.strip.downcase
132
133
 
133
- body == SERVICE_UNAVAILABLE || body.include?(service)
134
+ body.include?(SERVICE_UNAVAILABLE) || body.include?(service)
134
135
  end
135
136
  end
136
137
  end
@@ -139,11 +140,12 @@ module Nonnative
139
140
  opts = observability_options
140
141
 
141
142
  Then('I should see {string} as healthy') do |service|
143
+ service = service.downcase
142
144
  wait_for { Nonnative.observability.health(opts).code }.to eq(200)
143
145
  wait_for { Nonnative.observability.health(opts).body }.to satisfy do |body|
144
- body = body.to_s.strip
146
+ body = body.to_s.strip.downcase
145
147
 
146
- body != SERVICE_UNAVAILABLE && !body.include?(service)
148
+ !body.include?(SERVICE_UNAVAILABLE) && !body.include?(service)
147
149
  end
148
150
  end
149
151
  end
@@ -19,15 +19,16 @@ module Nonnative
19
19
  #
20
20
  # If `tools` is `nil` or empty, all tools (`prof`, `trace`, `cover`) are enabled.
21
21
  #
22
- # Parameter strings are parsed into argv words using shell-style quoting, then executed without a shell.
22
+ # Parameter strings are parsed into argv words using shell-style quoting.
23
23
  #
24
24
  # @example
25
- # cmd = Nonnative::GoCommand.new(%w[prof cover], './svc.test', 'reports')
26
- # cmd.executable_args('serve', '--config', 'config.yaml')
25
+ # executable = Nonnative::GoExecutable.new(%w[prof cover], './svc.test', 'reports')
26
+ # executable.argv('serve', '--config', 'config.yaml')
27
27
  # # => ["./svc.test", "-test.cpuprofile=...", "-test.coverprofile=...", "serve", "--config", "config.yaml"]
28
28
  #
29
- # @see Nonnative.go_executable_args
30
- class GoCommand
29
+ # @see Nonnative.go_command
30
+ # @see Nonnative.go_argv
31
+ class GoExecutable
31
32
  # @param tools [Array<String>, nil] tool names to enable (see class docs)
32
33
  # @param exec [String] path to the compiled Go test binary
33
34
  # @param output [String] output directory for generated files
@@ -44,10 +45,19 @@ module Nonnative
44
45
  # @param cmd [String] command/sub-command argument passed to the Go test binary
45
46
  # @param params [Array<String>] additional parameter strings passed after `cmd`
46
47
  # @return [Array<String>] argv entries to execute
47
- def executable_args(cmd, *params)
48
+ def argv(cmd, *params)
48
49
  [exec, *flags(cmd), cmd, *parameter_args(params)]
49
50
  end
50
51
 
52
+ # Returns an executable command string including enabled `-test.*` flags.
53
+ #
54
+ # @param cmd [String] command/sub-command argument passed to the Go test binary
55
+ # @param params [Array<String>] additional parameter strings passed after `cmd`
56
+ # @return [String] the full command to execute
57
+ def command(cmd, *params)
58
+ Shellwords.join(argv(cmd, *params))
59
+ end
60
+
51
61
  private
52
62
 
53
63
  attr_reader :tools, :exec, :output
@@ -4,5 +4,5 @@ module Nonnative
4
4
  # The current gem version.
5
5
  #
6
6
  # @return [String]
7
- VERSION = '2.19.1'
7
+ VERSION = '2.21.0'
8
8
  end
data/lib/nonnative.rb CHANGED
@@ -94,7 +94,7 @@ require 'nonnative/close_all_socket_pair'
94
94
  require 'nonnative/delay_socket_pair'
95
95
  require 'nonnative/invalid_data_socket_pair'
96
96
  require 'nonnative/socket_pair_factory'
97
- require 'nonnative/go_command'
97
+ require 'nonnative/go_executable'
98
98
  require 'nonnative/cucumber'
99
99
  require 'nonnative/header'
100
100
 
@@ -154,9 +154,23 @@ module Nonnative
154
154
  File.readlines(path).select { |l| predicate.call(l) }
155
155
  end
156
156
 
157
+ # Builds a Go test executable command string with optional profiling/trace/coverage flags.
158
+ #
159
+ # Use this when passing a command string directly to `spawn`.
160
+ #
161
+ # @param tools [Array<String>] enabled tool names (e.g. `["prof", "trace", "cover"]`)
162
+ # @param output [String] directory where outputs should be written
163
+ # @param exec [String] the test binary (or wrapper) to execute
164
+ # @param cmd [String] the command argument passed to the test binary
165
+ # @param params [Array<String>] extra parameter strings for the command
166
+ # @return [String] executable command string
167
+ def go_command(tools, output, exec, cmd, *params)
168
+ Nonnative::GoExecutable.new(tools, exec, output).command(cmd, *params)
169
+ end
170
+
157
171
  # Builds a Go test executable argv array with optional profiling/trace/coverage flags.
158
172
  #
159
- # This is used when process configuration specifies a `go` section.
173
+ # Use this when passing argv entries directly to `spawn`.
160
174
  #
161
175
  # @param tools [Array<String>] enabled tool names (e.g. `["prof", "trace", "cover"]`)
162
176
  # @param output [String] directory where outputs should be written
@@ -164,8 +178,8 @@ module Nonnative
164
178
  # @param cmd [String] the command argument passed to the test binary
165
179
  # @param params [Array<String>] extra parameter strings for the command
166
180
  # @return [Array<String>] executable argv entries
167
- def go_executable_args(tools, output, exec, cmd, *params)
168
- Nonnative::GoCommand.new(tools, exec, output).executable_args(cmd, *params)
181
+ def go_argv(tools, output, exec, cmd, *params)
182
+ Nonnative::GoExecutable.new(tools, exec, output).argv(cmd, *params)
169
183
  end
170
184
 
171
185
  # Returns an HTTP client for common health/readiness endpoints.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonnative
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.1
4
+ version: 2.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Falkowski
@@ -298,7 +298,7 @@ files:
298
298
  - lib/nonnative/delay_socket_pair.rb
299
299
  - lib/nonnative/error.rb
300
300
  - lib/nonnative/fault_injection_proxy.rb
301
- - lib/nonnative/go_command.rb
301
+ - lib/nonnative/go_executable.rb
302
302
  - lib/nonnative/grpc_server.rb
303
303
  - lib/nonnative/header.rb
304
304
  - lib/nonnative/http_client.rb