gusto 1.0.0.beta15 → 1.0.0.beta16
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 +4 -4
- data/bin/gusto +6 -1
- data/lib/gusto/configuration.rb +1 -1
- data/lib/gusto/runner.rb +3 -3
- data/lib/gusto/server.rb +15 -2
- data/lib/gusto/server_spawner.rb +18 -15
- data/lib/gusto/version.rb +1 -1
- data/lib/gusto.rb +21 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54c35d8ce34b62e62deaf3eefe54c240d29e3af6
|
4
|
+
data.tar.gz: 19e86b796fe7b07039aa2e96bcfca819833edd1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 118e514a59ee364b213c4169482a5cb856215fa593d63650f7f1a7919fde9622e2537c471909da6b2077541966781b40c478a39fb9aefd3f2be1aac7f74abd91
|
7
|
+
data.tar.gz: a3c22bdb20ca4b5519a55ab6c608ac1060d2d6d012cac4be863a446418e14822cef47db15f83a8b58aea82bd808da586c2ff575535556284188acaa5c5794d7b
|
data/bin/gusto
CHANGED
@@ -13,10 +13,15 @@ parser = OptionParser.new do |o|
|
|
13
13
|
end
|
14
14
|
|
15
15
|
options[:version] = false
|
16
|
-
o.on '
|
16
|
+
o.on '--version', 'Show version' do
|
17
17
|
options[:version] = true
|
18
18
|
end
|
19
19
|
|
20
|
+
options[:verbose] = false
|
21
|
+
o.on '-v', 'Verbose' do
|
22
|
+
options[:verbose] = true
|
23
|
+
end
|
24
|
+
|
20
25
|
o.on_tail '-h', '--help', 'Display this screen' do
|
21
26
|
puts o
|
22
27
|
exit
|
data/lib/gusto/configuration.rb
CHANGED
data/lib/gusto/runner.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
4
3
|
module Gusto
|
5
4
|
class Runner
|
6
5
|
def load_gusto
|
7
6
|
require File.join(File.dirname(__FILE__), '..', 'gusto')
|
7
|
+
Gusto.verbose = @verbose
|
8
8
|
Gusto::Configuration.load
|
9
9
|
Gusto::Configuration.port = @port
|
10
10
|
end
|
@@ -13,8 +13,9 @@ module Gusto
|
|
13
13
|
require File.join(File.dirname(__FILE__), '..', 'gusto', 'version')
|
14
14
|
end
|
15
15
|
|
16
|
-
def initialize
|
16
|
+
def initialize(mode, options={}, parser=nil)
|
17
17
|
@port = options[:port] || 4567
|
18
|
+
@verbose = options[:verbose]
|
18
19
|
|
19
20
|
if options[:version]
|
20
21
|
load_gusto_version
|
@@ -22,7 +23,6 @@ module Gusto
|
|
22
23
|
else
|
23
24
|
case mode
|
24
25
|
when 's', 'server'
|
25
|
-
puts "Starting gusto server at http://127.0.0.1:#{@port}/"
|
26
26
|
load_gusto
|
27
27
|
Gusto.server
|
28
28
|
when 'c', 'cli'
|
data/lib/gusto/server.rb
CHANGED
@@ -11,7 +11,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../gusto')
|
|
11
11
|
module Gusto
|
12
12
|
class Server < Sinatra::Application
|
13
13
|
def self.start(host, port)
|
14
|
-
|
14
|
+
options = {
|
15
|
+
app: rack_app,
|
16
|
+
server: 'webrick',
|
17
|
+
Host: host,
|
18
|
+
Port: port,
|
19
|
+
}
|
20
|
+
options[:AccessLog] = [] unless Gusto.verbose
|
21
|
+
Rack::Server.start options
|
15
22
|
end
|
16
23
|
|
17
24
|
def self.rack_app
|
@@ -30,7 +37,7 @@ module Gusto
|
|
30
37
|
Slim::Engine.set_default_options :pretty => true
|
31
38
|
|
32
39
|
# Hide redundant log messages
|
33
|
-
disable :logging
|
40
|
+
# disable :logging
|
34
41
|
|
35
42
|
::Sprockets::Helpers.configure do |config|
|
36
43
|
config.environment = Sprockets.environment
|
@@ -45,6 +52,8 @@ module Gusto
|
|
45
52
|
|
46
53
|
# Processes request for page index
|
47
54
|
get "/" do
|
55
|
+
Gusto.logger.debug{ "Rendering index page with params #{params.inspect}" }
|
56
|
+
|
48
57
|
# Fetch list of all specification files in specs path
|
49
58
|
@scripts = []
|
50
59
|
Gusto::Configuration.spec_paths.each do |path|
|
@@ -62,5 +71,9 @@ module Gusto
|
|
62
71
|
@headless = params[:headless]
|
63
72
|
render :slim, :index
|
64
73
|
end
|
74
|
+
|
75
|
+
get "/health_check" do
|
76
|
+
status 200
|
77
|
+
end
|
65
78
|
end
|
66
79
|
end
|
data/lib/gusto/server_spawner.rb
CHANGED
@@ -3,11 +3,10 @@ require 'timeout'
|
|
3
3
|
|
4
4
|
module Gusto
|
5
5
|
class ServerSpawner
|
6
|
-
attr :port
|
6
|
+
attr :port
|
7
7
|
|
8
8
|
def initialize(options={})
|
9
9
|
@port = options[:port]
|
10
|
-
@quiet = options.fetch(:quiet, false)
|
11
10
|
end
|
12
11
|
|
13
12
|
def host
|
@@ -16,16 +15,17 @@ module Gusto
|
|
16
15
|
|
17
16
|
def spawn
|
18
17
|
choose_open_port
|
18
|
+
Gusto.logger.info{ "Starting Gusto server on port #{port}" }
|
19
19
|
@server = Process.fork do
|
20
|
-
close_std_io if quiet
|
21
20
|
self.process_name = "gusto server on #{host}:#{port}"
|
22
21
|
start_server
|
23
22
|
end
|
24
|
-
wait_for_server_at
|
23
|
+
wait_for_server_at health_check_url
|
24
|
+
Gusto.logger.info{ "Gusto server ready at #{root_url}" }
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
Process.kill '
|
27
|
+
def stop
|
28
|
+
Process.kill 'INT', @server if @server
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
@@ -37,11 +37,6 @@ module Gusto
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def close_std_io
|
41
|
-
$stdout.reopen "/dev/null", "w"
|
42
|
-
$stderr.reopen "/dev/null", "w"
|
43
|
-
end
|
44
|
-
|
45
40
|
def process_name=(name)
|
46
41
|
$0 = name
|
47
42
|
end
|
@@ -54,11 +49,19 @@ module Gusto
|
|
54
49
|
"http://#{host}:#{port}/"
|
55
50
|
end
|
56
51
|
|
52
|
+
def health_check_url
|
53
|
+
"#{root_url}health_check"
|
54
|
+
end
|
55
|
+
|
57
56
|
def wait_for_server_at(url)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
Gusto.logger.debug{ "Waiting for server to respond" }
|
58
|
+
begin
|
59
|
+
Net::HTTP.get URI.parse(url)
|
60
|
+
rescue Errno::ECONNREFUSED
|
61
|
+
Gusto.logger.debug{ "Server not responding, retrying" }
|
62
|
+
sleep 1
|
63
|
+
retry
|
64
|
+
end
|
62
65
|
end
|
63
66
|
|
64
67
|
def port_open?(port)
|
data/lib/gusto/version.rb
CHANGED
data/lib/gusto.rb
CHANGED
@@ -5,9 +5,9 @@ require 'sprockets'
|
|
5
5
|
require 'net/http'
|
6
6
|
require 'rack'
|
7
7
|
require 'json'
|
8
|
+
require 'logger'
|
8
9
|
require File.join(File.dirname(__FILE__), 'gusto', 'version')
|
9
10
|
|
10
|
-
|
11
11
|
module Gusto
|
12
12
|
autoload :Configuration, File.join(File.dirname(__FILE__), 'gusto', 'configuration')
|
13
13
|
autoload :Server, File.join(File.dirname(__FILE__), 'gusto', 'server')
|
@@ -19,6 +19,14 @@ module Gusto
|
|
19
19
|
File.join(File.dirname(__FILE__), '..', 'phantom', 'headless_runner.js'))
|
20
20
|
|
21
21
|
class << self
|
22
|
+
attr_accessor :verbose
|
23
|
+
|
24
|
+
def logger
|
25
|
+
@logger ||= Logger.new(STDOUT).tap do |logger|
|
26
|
+
logger.level = verbose ? Logger::DEBUG : Logger::INFO
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
22
30
|
def root
|
23
31
|
File.expand_path File.join(File.dirname(__FILE__), '..')
|
24
32
|
end
|
@@ -34,7 +42,7 @@ module Gusto
|
|
34
42
|
end
|
35
43
|
|
36
44
|
def cli
|
37
|
-
server_spawner
|
45
|
+
server_spawner.spawn
|
38
46
|
result = run_suite?(server_spawner.port)
|
39
47
|
ensure
|
40
48
|
shut_down(result ? 0 : 1)
|
@@ -42,24 +50,30 @@ module Gusto
|
|
42
50
|
|
43
51
|
def autotest
|
44
52
|
trap_sigint
|
45
|
-
sever_spawner
|
53
|
+
sever_spawner.spawn
|
46
54
|
run_suite?(server_spawner.port)
|
47
55
|
watch_for_changes
|
48
56
|
Process.waitall
|
49
57
|
end
|
50
58
|
|
51
59
|
def run_suite?(port)
|
60
|
+
Gusto.logger.debug{ "Running test suite with phantomjs" }
|
52
61
|
json = `phantomjs #{Shellwords.escape HEADLESS_RUNNER_PATH} #{port}`
|
62
|
+
|
63
|
+
Gusto.logger.debug{ "Parsing JSON response" }
|
53
64
|
report = JSON.parse json
|
65
|
+
|
66
|
+
Gusto.logger.debug{ "Rendering test results" }
|
54
67
|
puts CliRenderer.new(report).render
|
68
|
+
|
55
69
|
report['status'] != 2
|
56
70
|
rescue => e
|
57
|
-
|
71
|
+
Gusto.logger.error{ "Error running test suite: #{e.inspect}" }
|
58
72
|
false
|
59
73
|
end
|
60
74
|
|
61
|
-
def server_spawner
|
62
|
-
@server_spawner ||= ServerSpawner.new(port: Configuration.port
|
75
|
+
def server_spawner
|
76
|
+
@server_spawner ||= ServerSpawner.new(port: Configuration.port)
|
63
77
|
end
|
64
78
|
|
65
79
|
def watch_for_changes
|
@@ -77,7 +91,7 @@ module Gusto
|
|
77
91
|
def shut_down(status=0)
|
78
92
|
@listener.stop if @listener
|
79
93
|
@browser.close if @browser
|
80
|
-
server_spawner.
|
94
|
+
@server_spawner.stop if @server_spawner
|
81
95
|
exit status
|
82
96
|
end
|
83
97
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gusto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Cohen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-script
|