test_server_rb 0.2.0 → 1.0.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 +29 -53
- data/exe/test_server_remote +41 -51
- data/lib/test_server/version.rb +1 -1
- data/lib/test_server.rb +71 -1
- data/test_server.gemspec +2 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 289ffec419272ff9df85f63bd5010ced0c7e543a
|
4
|
+
data.tar.gz: cc92b99766d9795ea727b323d5a2b2b9f4c13fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c25d84e06f3e7d91e586f9c9a096a374b44fa6370d91bea48a0c3072c065516d6cf69484fe97624ecf0f5ddaf98c2388218d720c2b263442c873d262feeb86
|
7
|
+
data.tar.gz: 58deeca4da3796aaf15c6d2818a9b80a3f55cc1f5f7a613aee06ff7d14b5e60cd697cc155396738f7e27e1feb527377ee2273bb17888cfce66922e7c30b9843e
|
data/exe/test_server
CHANGED
@@ -2,66 +2,42 @@
|
|
2
2
|
|
3
3
|
$: << 'test'
|
4
4
|
require 'bundler/setup'
|
5
|
-
require '
|
6
|
-
require '
|
5
|
+
require 'test_server'
|
6
|
+
require 'optparse'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
options = {
|
9
|
+
remote: false,
|
10
|
+
sock: "test.sock"
|
11
|
+
}
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: test_server [OPTIONS] [TEST...]"
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
opts.on("--serve", "Boot the server") do |mode|
|
17
|
+
options[:mode] = :serve
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
opts.on("--test", "Push a test to the server") do |mode|
|
21
|
+
options[:mode] = :push
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
opts.on("--notify", "Send system notification based on test result") do |notify|
|
25
|
+
options[:notify_on_fail] = notify
|
26
|
+
options[:notify_on_pass] = notify
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("--notify-on-pass", "Send system notification when the test passes") do |notify|
|
30
|
+
options[:notify_on_pass] = notify
|
31
|
+
end
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
puts "Initializing TestServer with pid #{$$}..."
|
31
|
-
require 'test_helper'
|
32
|
-
puts "Ready!"
|
33
|
-
loop do
|
34
|
-
conn = server.accept
|
35
|
-
files, _ = conn.recvmsg
|
36
|
-
pid = fork do
|
37
|
-
puts "> Testing files: #{files}"
|
38
|
-
if files == ":all".freeze
|
39
|
-
all_glob = ENV['ALL_GLOB'] || 'test/unit/*_test.rb'
|
40
|
-
Dir.glob(all_glob).each { |f| load f }
|
41
|
-
else
|
42
|
-
files.split(' ').each { |f| load f }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
_, status = Process.wait2(pid)
|
46
|
-
if ENV['NOTIFY']
|
47
|
-
msg = (status.exitstatus == 0) ? "Tests passed :)" : "Warning! Tests failed :("
|
48
|
-
TerminalNotifier.notify(msg)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
ensure
|
52
|
-
`rm #{SOCK}`
|
53
|
-
end
|
33
|
+
opts.on("--notify-on-fail", "Send system notification when the test fails") do |notify|
|
34
|
+
options[:notify_on_fail] = notify
|
54
35
|
end
|
55
|
-
end
|
56
36
|
|
57
|
-
|
58
|
-
|
59
|
-
case queue.shift
|
60
|
-
when "--serve"
|
61
|
-
TestServer.start!
|
62
|
-
when "--test"
|
63
|
-
TestServer.test(queue)
|
64
|
-
queue = []
|
37
|
+
opts.on("--socket", "Socket file to use") do |sock|
|
38
|
+
options[:sock] = sock
|
65
39
|
end
|
66
|
-
end
|
40
|
+
end.parse!
|
67
41
|
|
42
|
+
options[:files] = ARGV
|
43
|
+
TestServer.run!(options)
|
data/exe/test_server_remote
CHANGED
@@ -2,57 +2,47 @@
|
|
2
2
|
|
3
3
|
$: << 'test'
|
4
4
|
require 'bundler/setup'
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
files, _ = conn.recvmsg
|
29
|
-
pid = fork do
|
30
|
-
puts "> Testing files: #{files}"
|
31
|
-
if files == ":all".freeze
|
32
|
-
all_glob = ENV['ALL_GLOB'] || 'test/unit/*_test.rb'
|
33
|
-
Dir.glob(all_glob).each { |f| load f }
|
34
|
-
else
|
35
|
-
files.split(' ').each { |f| load f }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
_, status = Process.wait2(pid)
|
39
|
-
if ENV['NOTIFY']
|
40
|
-
msg = (status.exitstatus == 0) ? "Tests passed :)" : "Warning! Tests failed :("
|
41
|
-
TerminalNotifier.notify(msg)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
5
|
+
require 'test_server'
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
options = {
|
9
|
+
remote: true,
|
10
|
+
host: "localhost",
|
11
|
+
port: 4545
|
12
|
+
}
|
13
|
+
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = "Usage: test_server_remote [OPTIONS] [TEST...]"
|
16
|
+
|
17
|
+
opts.on("--serve", "Boot the server") do |mode|
|
18
|
+
options[:mode] = :serve
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("--test", "Push a test to the server") do |mode|
|
22
|
+
options[:mode] = :push
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("--notify", "Send system notification based on test result") do |notify|
|
26
|
+
options[:notify_on_fail] = notify
|
27
|
+
options[:notify_on_pass] = notify
|
45
28
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
when "
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
29
|
+
|
30
|
+
opts.on("--notify-on-pass", "Send system notification when the test passes") do |notify|
|
31
|
+
options[:notify_on_pass] = notify
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("--notify-on-fail", "Send system notification when the test fails") do |notify|
|
35
|
+
options[:notify_on_fail] = notify
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on("--port", Integer, "Server's port (default: 4545)") do |port|
|
39
|
+
options[:port] = port
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on("--host", "Server's host (default: localhost)") do |host|
|
43
|
+
options[:host] = host
|
56
44
|
end
|
57
|
-
end
|
45
|
+
end.parse!
|
58
46
|
|
47
|
+
options[:files] = ARGV
|
48
|
+
TestServer.run!(options)
|
data/lib/test_server/version.rb
CHANGED
data/lib/test_server.rb
CHANGED
@@ -1,5 +1,75 @@
|
|
1
1
|
require "test_server/version"
|
2
2
|
|
3
|
+
require 'socket'
|
4
|
+
|
3
5
|
module TestServer
|
4
|
-
|
6
|
+
class << self
|
7
|
+
def run!(options)
|
8
|
+
case options[:mode]
|
9
|
+
when :serve
|
10
|
+
serve!(options)
|
11
|
+
when :push
|
12
|
+
test(options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test(options)
|
17
|
+
with_client(options) do |client|
|
18
|
+
client.sendmsg options[:files].join(' ')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def serve!(options)
|
23
|
+
with_server(options) do |server|
|
24
|
+
puts "Initializing TestServer with pid #{$$}..."
|
25
|
+
require 'test_helper'
|
26
|
+
puts "Ready!"
|
27
|
+
loop do
|
28
|
+
conn = server.accept
|
29
|
+
files, _ = conn.recvmsg
|
30
|
+
pid = fork do
|
31
|
+
puts "> Testing files: #{files}"
|
32
|
+
if files == ":all".freeze
|
33
|
+
all_glob = ENV['ALL_GLOB'] || 'test/unit/*_test.rb'
|
34
|
+
Dir.glob(all_glob).each { |f| load f }
|
35
|
+
else
|
36
|
+
files.split(' ').each { |f| load f }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
_, status = Process.wait2(pid)
|
40
|
+
if status.exitstatus == 0
|
41
|
+
notify("Tests passed :)") if options[:notify_on_pass]
|
42
|
+
else
|
43
|
+
notify("Warning! Tests failed :(") if options[:notify_on_fail]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def with_client(options)
|
50
|
+
if options[:remote]
|
51
|
+
yield TCPSocket.new(options[:host], options[:port])
|
52
|
+
else
|
53
|
+
yield UNIXSocket.new(options[:sock])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def with_server(options)
|
58
|
+
if options[:remote]
|
59
|
+
yield TCPServer.new(options[:host], options[:port])
|
60
|
+
else
|
61
|
+
begin
|
62
|
+
`rm #{options[:sock]}` if File.exist?(options[:sock])
|
63
|
+
yield UNIXServer.new(options[:sock])
|
64
|
+
ensure
|
65
|
+
`rm #{options[:sock]}` if File.exist?(options[:sock])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def notify(msg)
|
71
|
+
require 'terminal-notifier'
|
72
|
+
TerminalNotifier.notify(msg)
|
73
|
+
end
|
74
|
+
end
|
5
75
|
end
|
data/test_server.gemspec
CHANGED
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: 0.
|
4
|
+
version: 1.0.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:
|
11
|
+
date: 2019-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: terminal-notifier
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- joshuabodah@gmail.com
|
@@ -77,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
91
|
version: '0'
|
78
92
|
requirements: []
|
79
93
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.5.2
|
94
|
+
rubygems_version: 2.5.2.3
|
81
95
|
signing_key:
|
82
96
|
specification_version: 4
|
83
97
|
summary: dead simple fork based test server
|