nonnative 1.28.0 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb604e3c902b73acba698a4c291a0ed9a269fddabbd6e354add54fd751422b9
4
- data.tar.gz: 7629e83827772b5e9770fe06b45e8d1014f957b8308d044029121fb75ef07f58
3
+ metadata.gz: 38e0bc3edd8186e46c09f6ced347428e59c84d2fd1fa3621b43d750e6869df24
4
+ data.tar.gz: bce006f5c6c8efec4ee05eed6e596a387362efd533d39a76730d4c418da3ca96
5
5
  SHA512:
6
- metadata.gz: 7ab05385158fe857b2aadfe587ac1b76e429957a50d91a67e9e62c54c0f9deb3f2fda00a3269883b000adee18ab6d9bf565f3e8a09d8f0e957c67accf55be500
7
- data.tar.gz: fd18a1d40215a7f520b6f30e72be9dde4ddb5473efa3357b79f9d304e0f81141168492caeb3fd112536b3ad586526db4a3dea4acc93baf272608f62242cc18c7
6
+ metadata.gz: de9987b642545511b4b4357b1b74670ba2f82d15c13b6df442ea6ef8954ac1f4225d2fdd8029395a085491dace93f827bae0fa85256a6c7c8fed90681e252b72
7
+ data.tar.gz: aecc4f783443ecfc13dc8a93329e16fbf0677f09dff875bf878316e64c468e19abf3d93f08a8e246de56c33c2c103a14653b07b9048e1be2cde2458e69ca7752
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (1.28.0)
4
+ nonnative (1.29.0)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.5)
6
6
  cucumber (>= 4, < 5)
7
7
  grpc (>= 1, < 2)
data/README.md CHANGED
@@ -373,3 +373,39 @@ server = Nonnative.pool.server_by_name(name)
373
373
  server.proxy.close_all # To use close_all.
374
374
  server.proxy.reset # To reset it back to a good state.
375
375
  ```
376
+
377
+
378
+ ### Go
379
+
380
+ As we love using go as a language for services we have added support to start binaries with defined parameters. This expects that you build your services in the format of `command sub_command --params`
381
+
382
+ To get this to work you will need to create a `main_test.go` file with these contents:
383
+
384
+ ```go
385
+ // +build features
386
+
387
+ package main
388
+
389
+ import (
390
+ "testing"
391
+ )
392
+
393
+ // TestFeatures is a hack that allows us to figure out what the coverage is during
394
+ // integration tests. I would not recommend that you use a binary built using
395
+ // this hack outside of a test suite.
396
+ func TestFeatures(t *testing.T) {
397
+ main()
398
+ }
399
+ ```
400
+
401
+ Then to compile this binary you will need to do the following:
402
+
403
+ ```sh
404
+ go test -mod vendor -c -tags features -covermode=count -o your_binary -coverpkg=./... github.com/your_location
405
+ ```
406
+
407
+ Then to get an executable you do the following:
408
+
409
+ ```ruby
410
+ Nonnative::GoCommand.new('your_binary', 'reports').executable('sub_command', '--config config.yaml')
411
+ ```
@@ -3,6 +3,7 @@
3
3
  require 'socket'
4
4
  require 'timeout'
5
5
  require 'yaml'
6
+ require 'open3'
6
7
 
7
8
  require 'grpc'
8
9
  require 'sinatra'
@@ -40,6 +41,7 @@ require 'nonnative/delay_socket_pair'
40
41
  require 'nonnative/invalid_data_socket_pair'
41
42
  require 'nonnative/socket_pair_factory'
42
43
  require 'nonnative/strategy'
44
+ require 'nonnative/go_command'
43
45
 
44
46
  module Nonnative
45
47
  class << self
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class GoCommand
5
+ def initialize(main, output)
6
+ @main = main
7
+ @output = output
8
+ end
9
+
10
+ def executable(cmd, *params)
11
+ params = params.join(' ')
12
+ "#{main} #{flags(cmd, params).join(' ')} #{cmd} #{params}"
13
+ end
14
+
15
+ def execute(cmd, *params)
16
+ Open3.popen3(executable(cmd, params)) do |_stdin, stdout, stderr, wait_thr|
17
+ return stdout.read, stderr.read, wait_thr.value
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :main, :output
24
+
25
+ def flags(cmd, params)
26
+ m = File.basename(main, File.extname(main))
27
+ p = params.gsub(/\W/, '')
28
+ path = "#{output}/#{m}-#{cmd}-#{p}"
29
+
30
+ [
31
+ "-test.cpuprofile=#{path}-cpu.prof",
32
+ "-test.memprofile=#{path}-mem.prof",
33
+ "-test.blockprofile=#{path}-block.prof",
34
+ "-test.mutexprofile=#{path}-mutex.prof",
35
+ "-test.coverprofile=#{path}.cov",
36
+ "-test.trace=#{path}-trace.out"
37
+ ]
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '1.28.0'
4
+ VERSION = '1.29.0'
5
5
  end
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: 1.28.0
4
+ version: 1.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Falkowski
@@ -292,6 +292,7 @@ files:
292
292
  - lib/nonnative/delay_socket_pair.rb
293
293
  - lib/nonnative/error.rb
294
294
  - lib/nonnative/fault_injection_proxy.rb
295
+ - lib/nonnative/go_command.rb
295
296
  - lib/nonnative/grpc_server.rb
296
297
  - lib/nonnative/http_client.rb
297
298
  - lib/nonnative/http_server.rb