karl-loris 0.0.9 → 0.0.10
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.
- data/Rakefile +1 -1
- data/TODO +5 -5
- data/VERSION +1 -1
- data/features/step_definitons/all.rb +1 -1
- data/lib/filters/ends_with_filter.rb +1 -1
- data/lib/filters/extension_filter.rb +1 -1
- data/lib/filters/file_filter.rb +1 -1
- data/lib/filters/modified_filter.rb +1 -1
- data/lib/loris.rb +59 -16
- data/lib/outputs/growl_output.rb +1 -1
- data/lib/outputs/output_collection.rb +3 -3
- data/lib/outputs/shell_output.rb +1 -1
- data/lib/outputs/unix_console_clearing_output.rb +2 -2
- data/lib/outputs/windows_console_clearing_output.rb +2 -2
- data/lib/pinger.rb +23 -0
- data/lib/task_manager.rb +23 -5
- data/lib/tasks/command_line_task.rb +28 -0
- data/lib/tasks/javascript_lint/javascript_lint_parser.rb +45 -0
- data/lib/tasks/javascript_lint/javascript_lint_runner.rb +5 -1
- data/lib/tasks/js_test_driver/js_test_driver_config.rb +22 -0
- data/lib/tasks/js_test_driver/{js_test_driver_task.rb → js_test_driver_parser.rb} +1 -26
- data/lib/tasks/js_test_driver/js_test_driver_runner.rb +8 -2
- data/lib/tasks/js_test_driver/js_test_driver_server.rb +30 -0
- data/lib/tasks/jspec/{jspec_task.rb → jspec_parser.rb} +2 -26
- data/lib/tasks/jspec/jspec_runner.rb +4 -0
- data/lib/tasks/rspec/rspec_parser.rb +25 -0
- data/lib/tasks/rspec/rspec_runner.rb +5 -1
- data/lib/unix_process.rb +7 -0
- data/lib/windows_process.rb +9 -0
- data/loris.gemspec +16 -10
- data/spec/file_actioner_spec.rb +2 -2
- data/spec/list_task_spec.rb +5 -5
- data/spec/poller_spec.rb +1 -1
- data/spec/tasks/js_test_driver/js_test_driver_runner_spec.rb +7 -6
- data/spec/tasks/jspec/jspec_parser_spec.rb +28 -0
- metadata +14 -8
- data/lib/tasks/javascript_lint/javascript_lint_task.rb +0 -66
- data/lib/tasks/rspec/rspec_task.rb +0 -50
- data/spec/tasks/jspec/jspec_task_spec.rb +0 -45
data/Rakefile
CHANGED
data/TODO
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
+
* Work out what is going on with fork in windows (running second copy of Loris?)
|
2
|
+
|
1
3
|
* Remove JsTestDriver.jar from lib dir
|
2
4
|
* Tidy Windows related if statements
|
3
5
|
* Tidy JSL filename removing
|
4
6
|
|
5
7
|
* javascript lint not installed? (package if not already installed?)
|
6
|
-
|
7
8
|
* JSpec not installed? (can require as gem)
|
8
9
|
|
9
|
-
*
|
10
|
-
|
10
|
+
* Detect file rename
|
11
11
|
* Detect file deletion/directory rename
|
12
12
|
|
13
|
+
* Factories to create tasks
|
14
|
+
|
13
15
|
* Deal with filesystem exceptions
|
14
|
-
* Deal with task exceptions
|
15
16
|
* jspec task (just modified files?)
|
16
17
|
* javascript lint task (just modified files?)
|
17
18
|
* separate thread (create new and kill old)
|
18
19
|
* listen for interrupt
|
19
|
-
* detect file deletion
|
20
20
|
* cucumber task
|
21
21
|
* Tidy growl windows code
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/lib/filters/file_filter.rb
CHANGED
data/lib/loris.rb
CHANGED
@@ -6,6 +6,8 @@ require 'bind'
|
|
6
6
|
require 'rbconfig'
|
7
7
|
require 'find'
|
8
8
|
require 'Growl'
|
9
|
+
require 'yaml'
|
10
|
+
require 'uri'
|
9
11
|
|
10
12
|
|
11
13
|
require 'file_finder'
|
@@ -14,6 +16,7 @@ require 'sleep_waiter'
|
|
14
16
|
require 'always_continuer'
|
15
17
|
require 'file_actioner'
|
16
18
|
require 'task_manager'
|
19
|
+
require 'pinger'
|
17
20
|
|
18
21
|
require 'filters/extension_filter'
|
19
22
|
require 'filters/modified_filter'
|
@@ -27,14 +30,13 @@ require 'outputs/unix_console_clearing_output'
|
|
27
30
|
require 'outputs/growl_output'
|
28
31
|
|
29
32
|
require 'tasks/list_task'
|
30
|
-
require 'tasks/
|
33
|
+
require 'tasks/command_line_task'
|
31
34
|
require 'tasks/jspec/jspec_runner'
|
32
|
-
require 'tasks/
|
35
|
+
require 'tasks/jspec/jspec_parser'
|
33
36
|
require 'tasks/javascript_lint/javascript_lint_runner'
|
34
|
-
require 'tasks/
|
35
|
-
require 'tasks/js_test_driver/js_test_driver_runner'
|
36
|
-
require 'tasks/rspec/rspec_task'
|
37
|
+
require 'tasks/javascript_lint/javascript_lint_parser'
|
37
38
|
require 'tasks/rspec/rspec_runner'
|
39
|
+
require 'tasks/rspec/rspec_parser'
|
38
40
|
|
39
41
|
|
40
42
|
include Config
|
@@ -62,8 +64,8 @@ module Loris
|
|
62
64
|
@stream = stream
|
63
65
|
end
|
64
66
|
|
65
|
-
def run
|
66
|
-
@actioner.run
|
67
|
+
def run
|
68
|
+
@actioner.run
|
67
69
|
@stream.puts '[Poll complete]'
|
68
70
|
@stream.flush
|
69
71
|
end
|
@@ -78,7 +80,7 @@ module Loris
|
|
78
80
|
is_windows = RUBY_PLATFORM =~ /mswin32/
|
79
81
|
dir = Dir.pwd
|
80
82
|
sleep_duration = 1
|
81
|
-
|
83
|
+
browser = is_windows ? 'C:/Program Files/Internet Explorer/iexplore.exe' : 'open'
|
82
84
|
|
83
85
|
# Create object graph
|
84
86
|
w = SleepWaiter.new(sleep_duration)
|
@@ -87,19 +89,19 @@ module Loris
|
|
87
89
|
ff.add_filter(FileFilter.new(File))
|
88
90
|
ff.add_filter(ModifiedFilter.new(File))
|
89
91
|
|
90
|
-
cco = is_windows ? WindowsConsoleClearingOutput.new
|
92
|
+
cco = is_windows ? WindowsConsoleClearingOutput.new : UnixConsoleClearingOutput.new
|
91
93
|
|
92
|
-
oc = OutputCollection.new
|
94
|
+
oc = OutputCollection.new
|
93
95
|
oc.add(ShellOutput.new($stdout))
|
94
96
|
oc.add(cco) unless debug
|
95
97
|
oc.add(GrowlOutput.new(Growl)) unless debug
|
96
98
|
|
97
99
|
tm = TaskManager.new(oc)
|
98
|
-
tm.add(ListTask.new
|
99
|
-
tm.add(
|
100
|
-
tm.add(
|
101
|
-
tm.add(
|
102
|
-
tm.add(
|
100
|
+
tm.add(ListTask.new) if debug
|
101
|
+
tm.add(CommandLineTask.new(JavascriptLintRunner.new(dir, ExtensionFilter.new(File, 'js')), JavascriptLintParser.new(dir)))
|
102
|
+
tm.add(CommandLineTask.new(JSpecRunner.new(dir, ExtensionFilter.new(File, 'js')), JSpecParser.new)) unless is_windows
|
103
|
+
tm.add(jsTestDriverTask(dir))
|
104
|
+
tm.add(CommandLineTask.new(RSpecRunner.new(dir, ExtensionFilter.new(File, 'rb'), EndsWithFilter.new('_spec.rb')), RSpecParser.new))
|
103
105
|
|
104
106
|
a = FileActioner.new(ff, tm)
|
105
107
|
|
@@ -108,9 +110,50 @@ module Loris
|
|
108
110
|
p = Poller.new(w, c, debug ? da : a)
|
109
111
|
|
110
112
|
# Start!
|
111
|
-
p.start
|
113
|
+
p.start
|
112
114
|
|
113
115
|
end
|
116
|
+
|
117
|
+
# Will need to be refactored into a factory
|
118
|
+
def jsTestDriverTask(dir)
|
119
|
+
require 'tasks/js_test_driver/js_test_driver_runner'
|
120
|
+
require 'tasks/js_test_driver/js_test_driver_parser'
|
121
|
+
require 'tasks/js_test_driver/js_test_driver_config'
|
122
|
+
require 'tasks/js_test_driver/js_test_driver_server'
|
123
|
+
|
124
|
+
jar = File.join(LIBDIR, 'JsTestDriver-1.0b.jar')
|
125
|
+
is_windows = RUBY_PLATFORM =~ /mswin32/
|
126
|
+
browser = is_windows ? 'C:/Program Files/Internet Explorer/iexplore.exe' : 'open'
|
127
|
+
sleep_time = is_windows ? 10 : 5
|
128
|
+
|
129
|
+
if is_windows
|
130
|
+
require 'windows_process'
|
131
|
+
else
|
132
|
+
require 'unix_process'
|
133
|
+
end
|
134
|
+
|
135
|
+
return CommandLineTask.new(
|
136
|
+
JsTestDriverRunner.new(
|
137
|
+
dir,
|
138
|
+
jar,
|
139
|
+
ExtensionFilter.new(File, 'js'),
|
140
|
+
JsTestDriverServer.new(
|
141
|
+
JsTestDriverConfig.new(
|
142
|
+
dir,
|
143
|
+
YAML,
|
144
|
+
URI
|
145
|
+
),
|
146
|
+
Pinger.new,
|
147
|
+
is_windows ? WindowsProcess.new : UnixProcess.new,
|
148
|
+
jar,
|
149
|
+
browser,
|
150
|
+
sleep_time
|
151
|
+
)
|
152
|
+
),
|
153
|
+
JsTestDriverParser.new
|
154
|
+
)
|
155
|
+
end
|
156
|
+
|
114
157
|
end
|
115
158
|
|
116
159
|
end
|
data/lib/outputs/growl_output.rb
CHANGED
data/lib/outputs/shell_output.rb
CHANGED
data/lib/pinger.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
class Pinger
|
5
|
+
|
6
|
+
def is_port_open?(ip, port)
|
7
|
+
begin
|
8
|
+
Timeout::timeout(1) do
|
9
|
+
begin
|
10
|
+
s = TCPSocket.new(ip, port)
|
11
|
+
s.close
|
12
|
+
return true
|
13
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
14
|
+
return false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
rescue Timeout::Error
|
18
|
+
end
|
19
|
+
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/task_manager.rb
CHANGED
@@ -10,18 +10,36 @@ class TaskManager
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def run(files)
|
13
|
-
@output.start_run
|
13
|
+
@output.start_run;
|
14
14
|
|
15
15
|
@tasks.each do |task|
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
begin
|
18
|
+
break if !run_task(files, task)
|
19
|
+
rescue Exception => ex
|
20
|
+
output_exception(ex)
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
|
+
def run_task(files, task)
|
28
|
+
result = task.run(files)
|
29
|
+
return true if result.nil?
|
30
|
+
|
31
|
+
@output.add_result(result)
|
32
|
+
return !([:error, :failure].include? result[:state])
|
33
|
+
end
|
34
|
+
|
35
|
+
def output_exception(ex)
|
36
|
+
@output.add_result({
|
37
|
+
:state => :error,
|
38
|
+
:title => 'Task',
|
39
|
+
:summary => 'Exception',
|
40
|
+
:first => ex.message,
|
41
|
+
:detail => ex.backtrace
|
42
|
+
})
|
43
|
+
end
|
44
|
+
|
27
45
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CommandLineTask
|
2
|
+
|
3
|
+
def initialize(runner, parser)
|
4
|
+
@runner = runner
|
5
|
+
@parser = parser
|
6
|
+
end
|
7
|
+
|
8
|
+
def run(files)
|
9
|
+
all_files = files[:all]
|
10
|
+
modified_files = files[:filtered]
|
11
|
+
|
12
|
+
return nil if (!@runner.is_configured? all_files)
|
13
|
+
return nil if (!@runner.should_run? modified_files)
|
14
|
+
|
15
|
+
detail = @runner.execute
|
16
|
+
|
17
|
+
state, summary, first = @parser.parse_result(detail)
|
18
|
+
|
19
|
+
return {
|
20
|
+
:state => state,
|
21
|
+
:title => @runner.name,
|
22
|
+
:summary => summary,
|
23
|
+
:first => first,
|
24
|
+
:detail => detail
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class JavascriptLintParser
|
2
|
+
|
3
|
+
def initialize(dir)
|
4
|
+
@dir = dir
|
5
|
+
|
6
|
+
# TODO: Tidy!
|
7
|
+
if (RUBY_PLATFORM =~ /mswin32/)
|
8
|
+
@dir = @dir.gsub('/', '\\')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse_result(detail)
|
13
|
+
summary_line = detail.grep( /\d+\s+error.*,\s+\d+\s+warning.*/ )[0]
|
14
|
+
|
15
|
+
if summary_line.nil?
|
16
|
+
# error
|
17
|
+
error_info = (detail + "\nUnknown Error!").to_a[0].strip
|
18
|
+
return :error, 'Error', error_info
|
19
|
+
end
|
20
|
+
|
21
|
+
if summary_line =~ /([1-9]+)\d*\s+error/
|
22
|
+
num_failures = $1
|
23
|
+
error_info = detail.grep(/\([0-9]+\):([^:]*)Error:/)[0].strip
|
24
|
+
return :failure, num_failures + ' Errors', strip_dir(error_info)
|
25
|
+
end
|
26
|
+
|
27
|
+
if summary_line =~ /([1-9]+)\d*\s+warning/
|
28
|
+
num_failures = $1
|
29
|
+
error_info = detail.grep(/\([0-9]+\)/)[0].strip
|
30
|
+
return :warning, num_failures + ' Warnings', strip_dir(error_info)
|
31
|
+
end
|
32
|
+
|
33
|
+
return :success, 'All files are clean', ''
|
34
|
+
end
|
35
|
+
|
36
|
+
def strip_dir(text)
|
37
|
+
|
38
|
+
# Move to function/class w/ win32 related code
|
39
|
+
if (text[0, @dir.length] == @dir)
|
40
|
+
text = text[(@dir.length + 1)..-1]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class JsTestDriverConfig
|
2
|
+
|
3
|
+
def initialize(dir, yaml, uri)
|
4
|
+
@config_file = dir + '/jsTestDriver.conf'
|
5
|
+
@yaml = yaml
|
6
|
+
@uri = uri
|
7
|
+
end
|
8
|
+
|
9
|
+
def reload
|
10
|
+
@conf = @yaml.load_file(@config_file)
|
11
|
+
@server = @uri.parse(@conf['server'])
|
12
|
+
end
|
13
|
+
|
14
|
+
def host
|
15
|
+
return @server.host
|
16
|
+
end
|
17
|
+
|
18
|
+
def port
|
19
|
+
return @server.port
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -1,30 +1,5 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
def initialize(js_test_driver)
|
4
|
-
@js_test_driver = js_test_driver
|
5
|
-
end
|
6
|
-
|
7
|
-
def run(files)
|
8
|
-
all_files = files[:all]
|
9
|
-
modified_files = files[:filtered]
|
10
|
-
|
11
|
-
return nil if (!@js_test_driver.is_configured? all_files)
|
12
|
-
return nil if (!@js_test_driver.should_run? modified_files)
|
13
|
-
|
14
|
-
detail = @js_test_driver.execute()
|
15
|
-
|
16
|
-
state, summary, first = parse_result(detail)
|
17
|
-
|
18
|
-
return {
|
19
|
-
:state => state,
|
20
|
-
:title => 'JS Test Driver',
|
21
|
-
:summary => summary,
|
22
|
-
:first => first,
|
23
|
-
:detail => detail
|
24
|
-
}
|
25
|
-
end
|
1
|
+
class JsTestDriverParser
|
26
2
|
|
27
|
-
# Move to parse class
|
28
3
|
def parse_result(detail)
|
29
4
|
summary_line = detail.grep( /Total \d+ tests/ )[0]
|
30
5
|
|
@@ -1,13 +1,19 @@
|
|
1
1
|
class JsTestDriverRunner
|
2
2
|
|
3
|
-
def initialize(dir, jar, filter)
|
3
|
+
def initialize(dir, jar, filter, server)
|
4
4
|
@config = dir + '/jsTestDriver.conf'
|
5
5
|
@dir = dir
|
6
6
|
@jar = jar
|
7
7
|
@filter = filter
|
8
|
+
@server = server
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
+
def name
|
12
|
+
return 'JS Test Driver'
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
@server.start_if_required
|
11
17
|
return `java -jar "#{@jar}" --config "#{@config}" --tests all --verbose 2>&1`
|
12
18
|
end
|
13
19
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class JsTestDriverServer
|
2
|
+
|
3
|
+
def initialize(config, pinger, process, jar, browser, sleep_time)
|
4
|
+
@config = config
|
5
|
+
@pinger = pinger
|
6
|
+
@process = process
|
7
|
+
@jar = jar
|
8
|
+
@browser = browser
|
9
|
+
@sleep_time = sleep_time
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_if_required
|
13
|
+
@config.reload
|
14
|
+
|
15
|
+
if @config.host == 'localhost' && server_not_running
|
16
|
+
start_server(@config.port)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def server_not_running
|
21
|
+
return !@pinger.is_port_open?('127.0.0.1', @config.port)
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_server(port)
|
25
|
+
command = "java -jar \"#{@jar}\" --port #{port} --browser \"#{@browser}\" "
|
26
|
+
@process.create(command)
|
27
|
+
sleep @sleep_time
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -1,30 +1,6 @@
|
|
1
|
-
class
|
1
|
+
class JSpecParser
|
2
2
|
|
3
|
-
def
|
4
|
-
@jspec = jspec
|
5
|
-
end
|
6
|
-
|
7
|
-
def run(files)
|
8
|
-
all_files = files[:all]
|
9
|
-
modified_files = files[:filtered]
|
10
|
-
|
11
|
-
return nil if (!@jspec.is_configured? all_files)
|
12
|
-
return nil if (!@jspec.should_run? modified_files)
|
13
|
-
|
14
|
-
detail = @jspec.execute
|
15
|
-
|
16
|
-
state, summary, first = parse_results(detail)
|
17
|
-
|
18
|
-
return {
|
19
|
-
:state => state,
|
20
|
-
:title => 'JSpec',
|
21
|
-
:summary => summary,
|
22
|
-
:first => first,
|
23
|
-
:detail => detail
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def parse_results(detail)
|
3
|
+
def parse_result(detail)
|
28
4
|
summary_line = detail.grep( /Passes:/ )[0]
|
29
5
|
|
30
6
|
if summary_line.nil?
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class RSpecParser
|
2
|
+
|
3
|
+
def parse_result(detail)
|
4
|
+
summary_line = detail.grep( /\d+ examples?, \d+ failures?/ )[0]
|
5
|
+
|
6
|
+
if summary_line.nil?
|
7
|
+
# error
|
8
|
+
error_info = (detail + "\nUnknown Error!").to_a[0].strip
|
9
|
+
return :error, 'Error', error_info
|
10
|
+
end
|
11
|
+
|
12
|
+
if summary_line =~ /([1-9]+) failures?/
|
13
|
+
num_errors = $1
|
14
|
+
|
15
|
+
items = detail.split("\n\n")
|
16
|
+
|
17
|
+
error_info = items[1].split("\n")[1]
|
18
|
+
return :failure, num_errors + ' Errors', error_info
|
19
|
+
end
|
20
|
+
|
21
|
+
return :success, 'All specs pass', ''
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/unix_process.rb
ADDED
data/loris.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{loris}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Karl O'Keeffe"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-21}
|
13
13
|
s.default_executable = %q{loris}
|
14
14
|
s.description = %q{Automatically run javascript unit tests}
|
15
15
|
s.email = %q{loris@monket.net}
|
@@ -50,18 +50,24 @@ Gem::Specification.new do |s|
|
|
50
50
|
"lib/outputs/shell_output.rb",
|
51
51
|
"lib/outputs/unix_console_clearing_output.rb",
|
52
52
|
"lib/outputs/windows_console_clearing_output.rb",
|
53
|
+
"lib/pinger.rb",
|
53
54
|
"lib/poller.rb",
|
54
55
|
"lib/sleep_waiter.rb",
|
55
56
|
"lib/task_manager.rb",
|
57
|
+
"lib/tasks/command_line_task.rb",
|
58
|
+
"lib/tasks/javascript_lint/javascript_lint_parser.rb",
|
56
59
|
"lib/tasks/javascript_lint/javascript_lint_runner.rb",
|
57
|
-
"lib/tasks/
|
60
|
+
"lib/tasks/js_test_driver/js_test_driver_config.rb",
|
61
|
+
"lib/tasks/js_test_driver/js_test_driver_parser.rb",
|
58
62
|
"lib/tasks/js_test_driver/js_test_driver_runner.rb",
|
59
|
-
"lib/tasks/js_test_driver/
|
63
|
+
"lib/tasks/js_test_driver/js_test_driver_server.rb",
|
64
|
+
"lib/tasks/jspec/jspec_parser.rb",
|
60
65
|
"lib/tasks/jspec/jspec_runner.rb",
|
61
|
-
"lib/tasks/jspec/jspec_task.rb",
|
62
66
|
"lib/tasks/list_task.rb",
|
67
|
+
"lib/tasks/rspec/rspec_parser.rb",
|
63
68
|
"lib/tasks/rspec/rspec_runner.rb",
|
64
|
-
"lib/
|
69
|
+
"lib/unix_process.rb",
|
70
|
+
"lib/windows_process.rb",
|
65
71
|
"loris.gemspec",
|
66
72
|
"loris.tmproj",
|
67
73
|
"spec/file_actioner_spec.rb",
|
@@ -76,8 +82,8 @@ Gem::Specification.new do |s|
|
|
76
82
|
"spec/task_manager_spec.rb",
|
77
83
|
"spec/tasks/javascript_lint/javascript_lint_runner_spec.rb",
|
78
84
|
"spec/tasks/js_test_driver/js_test_driver_runner_spec.rb",
|
79
|
-
"spec/tasks/jspec/
|
80
|
-
"spec/tasks/jspec/
|
85
|
+
"spec/tasks/jspec/jspec_parser_spec.rb",
|
86
|
+
"spec/tasks/jspec/jspec_runner_spec.rb"
|
81
87
|
]
|
82
88
|
s.homepage = %q{http://github.com/karl/loris}
|
83
89
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -97,8 +103,8 @@ Gem::Specification.new do |s|
|
|
97
103
|
"spec/task_manager_spec.rb",
|
98
104
|
"spec/tasks/javascript_lint/javascript_lint_runner_spec.rb",
|
99
105
|
"spec/tasks/js_test_driver/js_test_driver_runner_spec.rb",
|
100
|
-
"spec/tasks/jspec/
|
101
|
-
"spec/tasks/jspec/
|
106
|
+
"spec/tasks/jspec/jspec_parser_spec.rb",
|
107
|
+
"spec/tasks/jspec/jspec_runner_spec.rb"
|
102
108
|
]
|
103
109
|
|
104
110
|
if s.respond_to? :specification_version then
|
data/spec/file_actioner_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe FileActioner do
|
|
15
15
|
tm.should_receive(:run).with(files)
|
16
16
|
|
17
17
|
fa = FileActioner.new(ff, tm)
|
18
|
-
fa.run
|
18
|
+
fa.run
|
19
19
|
|
20
20
|
end
|
21
21
|
|
@@ -32,7 +32,7 @@ describe FileActioner do
|
|
32
32
|
tm.should_not_receive(:run)
|
33
33
|
|
34
34
|
fa = FileActioner.new(ff, tm)
|
35
|
-
fa.run
|
35
|
+
fa.run
|
36
36
|
|
37
37
|
end
|
38
38
|
|
data/spec/list_task_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe ListTask do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should output the given paths" do
|
13
|
-
oa = ListTask.new
|
13
|
+
oa = ListTask.new
|
14
14
|
result = oa.run(@files)
|
15
15
|
|
16
16
|
result[:detail].should eql "/path/to.file\n"
|
@@ -26,28 +26,28 @@ describe ListTask do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return a title" do
|
29
|
-
oa = ListTask.new
|
29
|
+
oa = ListTask.new
|
30
30
|
result = oa.run(@files)
|
31
31
|
|
32
32
|
result[:title].should eql "List"
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return success always" do
|
36
|
-
oa = ListTask.new
|
36
|
+
oa = ListTask.new
|
37
37
|
result = oa.run(@files)
|
38
38
|
|
39
39
|
result[:state].should eql :success
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should return summary for 1 file" do
|
43
|
-
oa = ListTask.new
|
43
|
+
oa = ListTask.new
|
44
44
|
result = oa.run(@files)
|
45
45
|
|
46
46
|
result[:first].should eql @files[:filtered][0]
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should return summary for 3 files" do
|
50
|
-
oa = ListTask.new
|
50
|
+
oa = ListTask.new
|
51
51
|
result = oa.run({ :filtered => ['first.file','second.file','third.file'] })
|
52
52
|
|
53
53
|
result[:first].should eql "3 files."
|
data/spec/poller_spec.rb
CHANGED
@@ -5,6 +5,7 @@ describe JsTestDriverRunner do
|
|
5
5
|
before do
|
6
6
|
@jar = '/path/to/jsTestDriver.jar'
|
7
7
|
@filter = mock('JS Extension Filter')
|
8
|
+
@server = mock('JS Test Driver Server')
|
8
9
|
end
|
9
10
|
|
10
11
|
describe "is_configured?" do
|
@@ -14,7 +15,7 @@ describe JsTestDriverRunner do
|
|
14
15
|
dir = '/a/dir/structure'
|
15
16
|
all_files = ['/a/dir/structure/jsTestDriver.conf']
|
16
17
|
|
17
|
-
runner = JsTestDriverRunner.new(dir, @jar, @filter)
|
18
|
+
runner = JsTestDriverRunner.new(dir, @jar, @filter, @server)
|
18
19
|
|
19
20
|
runner.is_configured?(all_files).should be_true
|
20
21
|
|
@@ -25,7 +26,7 @@ describe JsTestDriverRunner do
|
|
25
26
|
dir = '/a/dir/structure'
|
26
27
|
all_files = ['/a/dir/structure/other.conf']
|
27
28
|
|
28
|
-
runner = JsTestDriverRunner.new(dir, @jar, @filter)
|
29
|
+
runner = JsTestDriverRunner.new(dir, @jar, @filter, @server)
|
29
30
|
|
30
31
|
runner.is_configured?(all_files).should be_false
|
31
32
|
|
@@ -41,7 +42,7 @@ describe JsTestDriverRunner do
|
|
41
42
|
modified_files = ['/a/dir/structure/another_dir/example.js']
|
42
43
|
@filter.should_receive(:filter).and_return(true)
|
43
44
|
|
44
|
-
runner = JsTestDriverRunner.new(dir, @jar, @filter)
|
45
|
+
runner = JsTestDriverRunner.new(dir, @jar, @filter, @server)
|
45
46
|
|
46
47
|
runner.should_run?(modified_files).should be_true
|
47
48
|
|
@@ -54,7 +55,7 @@ describe JsTestDriverRunner do
|
|
54
55
|
@filter.should_receive(:filter).ordered.and_return(false)
|
55
56
|
@filter.should_receive(:filter).ordered.and_return(true)
|
56
57
|
|
57
|
-
runner = JsTestDriverRunner.new(dir, @jar, @filter)
|
58
|
+
runner = JsTestDriverRunner.new(dir, @jar, @filter, @server)
|
58
59
|
|
59
60
|
runner.should_run?(modified_files).should be_true
|
60
61
|
|
@@ -66,7 +67,7 @@ describe JsTestDriverRunner do
|
|
66
67
|
modified_files = ['/a/dir/structure/nonjs.file']
|
67
68
|
@filter.should_receive(:filter).ordered.and_return(false)
|
68
69
|
|
69
|
-
runner = JsTestDriverRunner.new(dir, @jar, @filter)
|
70
|
+
runner = JsTestDriverRunner.new(dir, @jar, @filter, @server)
|
70
71
|
|
71
72
|
runner.should_run?(modified_files).should be_false
|
72
73
|
|
@@ -78,7 +79,7 @@ describe JsTestDriverRunner do
|
|
78
79
|
modified_files = ['/a/dir/structure/jsTestDriver.conf']
|
79
80
|
@filter.should_receive(:filter).ordered.and_return(false)
|
80
81
|
|
81
|
-
runner = JsTestDriverRunner.new(dir, @jar, @filter)
|
82
|
+
runner = JsTestDriverRunner.new(dir, @jar, @filter, @server)
|
82
83
|
|
83
84
|
runner.should_run?(modified_files).should be_true
|
84
85
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'lib/tasks/jspec/jspec_parser.rb'
|
2
|
+
|
3
|
+
describe JSpecParser do
|
4
|
+
|
5
|
+
it "should return error if unable to parse jspec output" do
|
6
|
+
jspec_parser = JSpecParser.new
|
7
|
+
state, summary, first = jspec_parser.parse_result('A JSpec error message here...')
|
8
|
+
|
9
|
+
state.should eql :error
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return success if all tests pass" do
|
13
|
+
jspec_parser = JSpecParser.new
|
14
|
+
state, summary, first = jspec_parser.parse_result('Passes: 3 Failures: 0')
|
15
|
+
|
16
|
+
state.should eql :success
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return failure if any test fails" do
|
20
|
+
jspec_parser = JSpecParser.new
|
21
|
+
state, summary, first = jspec_parser.parse_result('Passes: 2 Failures: 1')
|
22
|
+
|
23
|
+
state.should eql :failure
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karl-loris
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl O'Keeffe
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-21 00:00:00 -07:00
|
13
13
|
default_executable: loris
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -83,18 +83,24 @@ files:
|
|
83
83
|
- lib/outputs/shell_output.rb
|
84
84
|
- lib/outputs/unix_console_clearing_output.rb
|
85
85
|
- lib/outputs/windows_console_clearing_output.rb
|
86
|
+
- lib/pinger.rb
|
86
87
|
- lib/poller.rb
|
87
88
|
- lib/sleep_waiter.rb
|
88
89
|
- lib/task_manager.rb
|
90
|
+
- lib/tasks/command_line_task.rb
|
91
|
+
- lib/tasks/javascript_lint/javascript_lint_parser.rb
|
89
92
|
- lib/tasks/javascript_lint/javascript_lint_runner.rb
|
90
|
-
- lib/tasks/
|
93
|
+
- lib/tasks/js_test_driver/js_test_driver_config.rb
|
94
|
+
- lib/tasks/js_test_driver/js_test_driver_parser.rb
|
91
95
|
- lib/tasks/js_test_driver/js_test_driver_runner.rb
|
92
|
-
- lib/tasks/js_test_driver/
|
96
|
+
- lib/tasks/js_test_driver/js_test_driver_server.rb
|
97
|
+
- lib/tasks/jspec/jspec_parser.rb
|
93
98
|
- lib/tasks/jspec/jspec_runner.rb
|
94
|
-
- lib/tasks/jspec/jspec_task.rb
|
95
99
|
- lib/tasks/list_task.rb
|
100
|
+
- lib/tasks/rspec/rspec_parser.rb
|
96
101
|
- lib/tasks/rspec/rspec_runner.rb
|
97
|
-
- lib/
|
102
|
+
- lib/unix_process.rb
|
103
|
+
- lib/windows_process.rb
|
98
104
|
- loris.gemspec
|
99
105
|
- loris.tmproj
|
100
106
|
- spec/file_actioner_spec.rb
|
@@ -109,8 +115,8 @@ files:
|
|
109
115
|
- spec/task_manager_spec.rb
|
110
116
|
- spec/tasks/javascript_lint/javascript_lint_runner_spec.rb
|
111
117
|
- spec/tasks/js_test_driver/js_test_driver_runner_spec.rb
|
118
|
+
- spec/tasks/jspec/jspec_parser_spec.rb
|
112
119
|
- spec/tasks/jspec/jspec_runner_spec.rb
|
113
|
-
- spec/tasks/jspec/jspec_task_spec.rb
|
114
120
|
has_rdoc: false
|
115
121
|
homepage: http://github.com/karl/loris
|
116
122
|
licenses:
|
@@ -151,5 +157,5 @@ test_files:
|
|
151
157
|
- spec/task_manager_spec.rb
|
152
158
|
- spec/tasks/javascript_lint/javascript_lint_runner_spec.rb
|
153
159
|
- spec/tasks/js_test_driver/js_test_driver_runner_spec.rb
|
160
|
+
- spec/tasks/jspec/jspec_parser_spec.rb
|
154
161
|
- spec/tasks/jspec/jspec_runner_spec.rb
|
155
|
-
- spec/tasks/jspec/jspec_task_spec.rb
|
@@ -1,66 +0,0 @@
|
|
1
|
-
class JavascriptLintTask
|
2
|
-
|
3
|
-
def initialize(javascript_lint, dir)
|
4
|
-
@javascript_lint = javascript_lint
|
5
|
-
@dir = dir
|
6
|
-
|
7
|
-
# TODO: Tidy!
|
8
|
-
if (RUBY_PLATFORM =~ /mswin32/)
|
9
|
-
@dir = @dir.gsub('/', '\\')
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def run(files)
|
15
|
-
all_files = files[:all]
|
16
|
-
modified_files = files[:filtered]
|
17
|
-
|
18
|
-
return nil if (!@javascript_lint.is_configured? all_files)
|
19
|
-
return nil if (!@javascript_lint.should_run? modified_files)
|
20
|
-
|
21
|
-
detail = @javascript_lint.execute()
|
22
|
-
|
23
|
-
state, summary, first = parse_result(detail)
|
24
|
-
|
25
|
-
# TODO: Tidy!
|
26
|
-
# Move to function/class w/ win32 related code
|
27
|
-
if (first[0, @dir.length] == @dir)
|
28
|
-
first = first[(@dir.length + 1)..-1]
|
29
|
-
end
|
30
|
-
|
31
|
-
return {
|
32
|
-
:state => state,
|
33
|
-
:title => 'Javascript Lint',
|
34
|
-
:summary => summary,
|
35
|
-
:first => first,
|
36
|
-
:detail => detail
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
# Move to parse class
|
41
|
-
def parse_result(detail)
|
42
|
-
summary_line = detail.grep( /\d+\s+error.*,\s+\d+\s+warning.*/ )[0]
|
43
|
-
|
44
|
-
if summary_line.nil?
|
45
|
-
# error
|
46
|
-
error_info = (detail + "\nUnknown Error!").to_a[0].strip
|
47
|
-
return :error, 'Error', error_info
|
48
|
-
end
|
49
|
-
|
50
|
-
if summary_line =~ /([1-9]+)\d*\s+error/
|
51
|
-
num_failures = $1
|
52
|
-
error_info = detail.grep(/\([0-9]+\):([^:]*)Error:/)[0].strip
|
53
|
-
return :failure, num_failures + ' Errors', error_info
|
54
|
-
end
|
55
|
-
|
56
|
-
if summary_line =~ /([1-9]+)\d*\s+warning/
|
57
|
-
num_failures = $1
|
58
|
-
error_info = detail.grep(/\([0-9]+\)/)[0].strip
|
59
|
-
return :warning, num_failures + ' Warnings', error_info
|
60
|
-
end
|
61
|
-
|
62
|
-
return :success, 'All files are clean', ''
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
class RSpecTask
|
2
|
-
|
3
|
-
def initialize(rspec)
|
4
|
-
@rspec = rspec
|
5
|
-
end
|
6
|
-
|
7
|
-
def run(files)
|
8
|
-
all_files = files[:all]
|
9
|
-
modified_files = files[:filtered]
|
10
|
-
|
11
|
-
return nil if (!@rspec.is_configured? all_files)
|
12
|
-
return nil if (!@rspec.should_run? modified_files)
|
13
|
-
|
14
|
-
detail = @rspec.execute()
|
15
|
-
|
16
|
-
state, summary, first = parse_result(detail)
|
17
|
-
|
18
|
-
return {
|
19
|
-
:state => state,
|
20
|
-
:title => 'RSpec',
|
21
|
-
:summary => summary,
|
22
|
-
:first => first,
|
23
|
-
:detail => detail
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
# Move to parse class
|
28
|
-
def parse_result(detail)
|
29
|
-
summary_line = detail.grep( /\d+ examples?, \d+ failures?/ )[0]
|
30
|
-
|
31
|
-
if summary_line.nil?
|
32
|
-
# error
|
33
|
-
error_info = (detail + "\nUnknown Error!").to_a[0].strip
|
34
|
-
return :error, 'Error', error_info
|
35
|
-
end
|
36
|
-
|
37
|
-
if summary_line =~ /([1-9]+) failures?/
|
38
|
-
num_errors = $1
|
39
|
-
|
40
|
-
items = detail.split("\n\n")
|
41
|
-
|
42
|
-
error_info = items[1].split("\n")[1]
|
43
|
-
return :failure, num_errors + ' Errors', error_info
|
44
|
-
end
|
45
|
-
|
46
|
-
return :success, 'All specs pass', ''
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'lib/tasks/jspec/jspec_task.rb'
|
2
|
-
|
3
|
-
describe JSpecTask do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@files = {
|
7
|
-
:all => [],
|
8
|
-
:filtered => []
|
9
|
-
}
|
10
|
-
|
11
|
-
@jspec = mock('JSpec Runner')
|
12
|
-
@jspec.should_receive(:is_configured?).and_return(true)
|
13
|
-
@jspec.should_receive(:should_run?).and_return(true)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should return error if unable to parse jspec output" do
|
17
|
-
@jspec.should_receive(:execute).and_return('A JSpec error message here...')
|
18
|
-
|
19
|
-
jspec_task = JSpecTask.new(@jspec)
|
20
|
-
result = jspec_task.run(@files)
|
21
|
-
|
22
|
-
result[:state].should eql :error
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should return success if all tests pass" do
|
26
|
-
@jspec.should_receive(:execute).and_return('Passes: 3 Failures: 0')
|
27
|
-
|
28
|
-
jspec_task = JSpecTask.new(@jspec)
|
29
|
-
result = jspec_task.run(@files)
|
30
|
-
|
31
|
-
result[:state].should eql :success
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return failure if any test fails" do
|
35
|
-
@jspec.should_receive(:execute).and_return('Passes: 2 Failures: 1')
|
36
|
-
|
37
|
-
jspec_task = JSpecTask.new(@jspec)
|
38
|
-
result = jspec_task.run(@files)
|
39
|
-
|
40
|
-
result[:state].should eql :failure
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
|