nonnative 2.19.1 → 2.20.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 +4 -4
- data/AGENTS.md +5 -2
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/nonnative/configuration.rb +1 -1
- data/lib/nonnative/{go_command.rb → go_executable.rb} +16 -6
- data/lib/nonnative/version.rb +1 -1
- data/lib/nonnative.rb +18 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3f867021d8754e7ef700f5b57991335299ea696410cc268f3ea6b18d4b3ae4d7
|
|
4
|
+
data.tar.gz: bea097cace138eab114d90b7b43404b0efd50479354c5448f247bafc78d93468
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 134bd430de52ad60233ccab7e71e08b593505cf69bcd4c9ee3dee1bc5c001c1416a628f0377c53dbecc1b9d3809ba0ad047c872f266b6ef2dd967ec22aaddeb6
|
|
7
|
+
data.tar.gz: a9461d8db4fba48d27ebdc9ffcb67916d4feb996769acf450cc0ab595633df94e00279bc415f17e0600e8d2edd9f8e114b2fa958f582b3e760d14129361c144b
|
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
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 = -> { ['
|
|
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.
|
|
144
|
+
-> { Nonnative.go_argv(tools, go.output, go.executable, go.command, *params) }
|
|
145
145
|
else
|
|
146
146
|
-> { process.command }
|
|
147
147
|
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
|
|
22
|
+
# Parameter strings are parsed into argv words using shell-style quoting.
|
|
23
23
|
#
|
|
24
24
|
# @example
|
|
25
|
-
#
|
|
26
|
-
#
|
|
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.
|
|
30
|
-
|
|
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
|
|
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
|
data/lib/nonnative/version.rb
CHANGED
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/
|
|
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
|
-
#
|
|
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
|
|
168
|
-
Nonnative::
|
|
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.
|
|
4
|
+
version: 2.20.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/
|
|
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
|