test_server_rb 1.0.3 → 1.1.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: 1868589bb41aafde3cdadded8bfee7deb962c278a530977e5b101d414b5a549b
4
- data.tar.gz: 38114c59ce6be58ec62b0a4b57fa2fe6baecec239a4eab1ec50ef90aca10f3a3
3
+ metadata.gz: c1cda3f7439bae43ed53752469dfefe499f4f5d4d2ed9b0ce0e728bc610533ae
4
+ data.tar.gz: 5d32d868a8d1915330c4b6c2f23fd79658c5d5c28b07465f7a6fc519c5c31093
5
5
  SHA512:
6
- metadata.gz: c91e94640e44daca5478729067fafa212f6d5ea027eddc534b1d3a0a9f06dbe496b403e09a2417e03a3940d9dd60668068891d954bae07530c4dcb7be98e8567
7
- data.tar.gz: 576f28244dc5d709988f2d6a26e5cfd4b814fbea0d471bbde348100a9b4ecbd00491e91069f26d5f67f8b6d5ee43546e25600ea83ec4ea7c6e6fe2417a041a7b
6
+ metadata.gz: 9377948ecd66f754631e39a7e81630429e9ed36021ea432650b931415763db16e8211bbb7bb2c9234e622a9d1c645e00cde59982445acc116e3443c9ae9265ca
7
+ data.tar.gz: 494eb827bfb190be5a197ea249b04bd097e69d64ff74be61e2766a2547ac2b2d442aecfc041e05df323380e4c57425e432315829dec19dedbe7cdc1ca5eb3279
data/exe/test_server CHANGED
@@ -6,7 +6,9 @@ require 'optparse'
6
6
 
7
7
  options = {
8
8
  remote: false,
9
- sock: "test.sock"
9
+ sock: "test.sock",
10
+ preload: %(require "test_helper"),
11
+ after_fork: ""
10
12
  }
11
13
 
12
14
  OptionParser.new do |opts|
@@ -33,9 +35,17 @@ OptionParser.new do |opts|
33
35
  options[:notify_on_fail] = notify
34
36
  end
35
37
 
36
- opts.on("--socket", "Socket file to use") do |sock|
38
+ opts.on("--socket FILE", "Socket file to use") do |sock|
37
39
  options[:sock] = sock
38
40
  end
41
+
42
+ opts.on("--preload CODE", "Ruby code to run before forking (default: \"require 'test_helper'\")") do |code|
43
+ options[:preload] = code
44
+ end
45
+
46
+ opts.on("--after-fork CODE", "Ruby code to run immediately after forking (default: \"\")") do |code|
47
+ options[:after_fork] = code
48
+ end
39
49
  end.parse!
40
50
 
41
51
  options[:files] = ARGV
@@ -7,7 +7,9 @@ require 'optparse'
7
7
  options = {
8
8
  remote: true,
9
9
  host: "localhost",
10
- port: 4545
10
+ port: 4545,
11
+ preload: %(require "test_helper"),
12
+ after_fork: ""
11
13
  }
12
14
 
13
15
  OptionParser.new do |opts|
@@ -41,6 +43,14 @@ OptionParser.new do |opts|
41
43
  opts.on("--host HOST", "Server's host (default: \"localhost\")") do |host|
42
44
  options[:host] = host
43
45
  end
46
+
47
+ opts.on("--preload CODE", "Ruby code to run before forking (default: \"require 'test_helper'\")") do |code|
48
+ options[:preload] = code
49
+ end
50
+
51
+ opts.on("--after-fork CODE", "Ruby code to run immediately after forking (default: \"\")") do |code|
52
+ options[:after_fork] = code
53
+ end
44
54
  end.parse!
45
55
 
46
56
  options[:files] = ARGV
@@ -1,3 +1,3 @@
1
1
  module TestServer
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/test_server.rb CHANGED
@@ -21,13 +21,14 @@ module TestServer
21
21
  def serve!(options)
22
22
  with_server(options) do |server|
23
23
  puts "Initializing TestServer with pid #{$$}..."
24
- require 'test_helper'
24
+ eval options[:preload] if options[:preload].length > 0
25
25
  puts "Ready!"
26
26
  loop do
27
27
  conn = server.accept
28
28
  files, _ = conn.recvmsg
29
29
  pid = fork do
30
30
  puts "> Testing files: #{files}"
31
+ eval options[:after_fork] if options[:after_fork].length > 0
31
32
  if files == ":all".freeze
32
33
  all_glob = ENV['ALL_GLOB'] || 'test/**/*_test.rb'
33
34
  Dir.glob(all_glob).each { |f| load f }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_server_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bodah