test_server_rb 1.1.0 → 1.2.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
- SHA256:
3
- metadata.gz: c1cda3f7439bae43ed53752469dfefe499f4f5d4d2ed9b0ce0e728bc610533ae
4
- data.tar.gz: 5d32d868a8d1915330c4b6c2f23fd79658c5d5c28b07465f7a6fc519c5c31093
2
+ SHA1:
3
+ metadata.gz: 12f06fcd7830907ad21377be3d8ce55e90880841
4
+ data.tar.gz: e3eb13085e67ef0d9f3a70fc0f1b33eb32089bea
5
5
  SHA512:
6
- metadata.gz: 9377948ecd66f754631e39a7e81630429e9ed36021ea432650b931415763db16e8211bbb7bb2c9234e622a9d1c645e00cde59982445acc116e3443c9ae9265ca
7
- data.tar.gz: 494eb827bfb190be5a197ea249b04bd097e69d64ff74be61e2766a2547ac2b2d442aecfc041e05df323380e4c57425e432315829dec19dedbe7cdc1ca5eb3279
6
+ metadata.gz: c075d40fb6873d2726b98c9261382b224b3454c08a3486dd270b658cd16d88fb4967360f63695bd07541bfe7edc087a66bb6d2f456fd0dee5b4b99081eb2300f
7
+ data.tar.gz: '0874d56b1fd247b3a36817cb106742f9a36a146a22f67c3da95932e96c12f7a49a296c96bf0dd693a02848f82715a1498494f126aafaf9b6306042c64a4c8f1f'
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  dead simple fork based test server
4
4
 
5
+ ## Description
6
+
7
+ `test_server` is a generic tool that lets you quickly build an ad-hoc Ruby workflow efficiently. It provides you with a server/client model where the client instructs the server on which files to load. The server will fork off a new child process which load those files and then the server will listen for more instructions. The most common use case for this is for testing, but it also could be used for compiling or other tasks
8
+
5
9
  ## Usage
6
10
 
7
11
  ```
data/exe/test_server CHANGED
@@ -46,6 +46,10 @@ OptionParser.new do |opts|
46
46
  opts.on("--after-fork CODE", "Ruby code to run immediately after forking (default: \"\")") do |code|
47
47
  options[:after_fork] = code
48
48
  end
49
+
50
+ opts.on("--forward-exit-code", "Calling process will exit with the fork child's exit code") do |forward_exit_code|
51
+ options[:forward_exit_code] = forward_exit_code
52
+ end
49
53
  end.parse!
50
54
 
51
55
  options[:files] = ARGV
@@ -1,5 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
+ $: << "lib"
3
4
  $: << 'test'
4
5
  require 'test_server'
5
6
  require 'optparse'
@@ -51,6 +52,10 @@ OptionParser.new do |opts|
51
52
  opts.on("--after-fork CODE", "Ruby code to run immediately after forking (default: \"\")") do |code|
52
53
  options[:after_fork] = code
53
54
  end
55
+
56
+ opts.on("--forward-exit-code", "Calling process will exit with the fork child's exit code") do |forward_exit_code|
57
+ options[:forward_exit_code] = forward_exit_code
58
+ end
54
59
  end.parse!
55
60
 
56
61
  options[:files] = ARGV
data/lib/test_server.rb CHANGED
@@ -15,6 +15,17 @@ module TestServer
15
15
  def test(options)
16
16
  with_client(options) do |client|
17
17
  client.sendmsg options[:files].join(' ')
18
+
19
+ if options[:forward_exit_code]
20
+ exit_code, _ = client.recvmsg
21
+ exit_code = exit_code.to_i
22
+ if exit_code == 0
23
+ notify("Tests passed :)") if options[:notify_on_pass]
24
+ else
25
+ notify("Warning! Tests failed :(") if options[:notify_on_fail]
26
+ end
27
+ exit(exit_code)
28
+ end
18
29
  end
19
30
  end
20
31
 
@@ -37,10 +48,16 @@ module TestServer
37
48
  end
38
49
  end
39
50
  _, status = Process.wait2(pid)
40
- if status.exitstatus == 0
41
- notify("Tests passed :)") if options[:notify_on_pass]
51
+ exit_code = status.exitstatus
52
+
53
+ if options[:forward_exit_code]
54
+ conn.sendmsg exit_code.to_s
42
55
  else
43
- notify("Warning! Tests failed :(") if options[:notify_on_fail]
56
+ if exit_code == 0
57
+ notify("Tests passed :)") if options[:notify_on_pass]
58
+ else
59
+ notify("Warning! Tests failed :(") if options[:notify_on_fail]
60
+ end
44
61
  end
45
62
  end
46
63
  end
@@ -1,3 +1,3 @@
1
1
  module TestServer
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_server_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bodah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-09 00:00:00.000000000 Z
11
+ date: 2019-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.7.6
94
+ rubygems_version: 2.5.2.3
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: dead simple fork based test server