test_server_rb 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/test_server +12 -2
- data/exe/test_server_remote +11 -1
- data/lib/test_server/version.rb +1 -1
- data/lib/test_server.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1cda3f7439bae43ed53752469dfefe499f4f5d4d2ed9b0ce0e728bc610533ae
|
4
|
+
data.tar.gz: 5d32d868a8d1915330c4b6c2f23fd79658c5d5c28b07465f7a6fc519c5c31093
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/exe/test_server_remote
CHANGED
@@ -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
|
data/lib/test_server/version.rb
CHANGED
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
|
-
|
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 }
|