guillaumegentil-rspactor 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rspactor/interactor.rb +20 -11
- data/lib/rspactor/listener.rb +13 -13
- data/lib/rspactor/runner.rb +20 -16
- data/spec/runner_spec.rb +1 -1
- metadata +2 -2
data/lib/rspactor/interactor.rb
CHANGED
@@ -2,16 +2,18 @@ require 'timeout'
|
|
2
2
|
|
3
3
|
module RSpactor
|
4
4
|
class Interactor
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
|
6
|
+
attr_reader :runner
|
7
|
+
|
8
|
+
def initialize(runner)
|
9
|
+
@runner = runner
|
8
10
|
ticker
|
9
11
|
end
|
10
12
|
|
11
|
-
def wait_for_enter_key(msg, seconds_to_wait
|
13
|
+
def wait_for_enter_key(msg, seconds_to_wait)
|
12
14
|
begin
|
13
15
|
Timeout::timeout(seconds_to_wait) do
|
14
|
-
system("clear;") if clear
|
16
|
+
system("clear;") if runner.options[:clear]
|
15
17
|
ticker(:start => true, :msg => msg)
|
16
18
|
$stdin.gets
|
17
19
|
return true
|
@@ -28,12 +30,19 @@ module RSpactor
|
|
28
30
|
Thread.new do
|
29
31
|
loop do
|
30
32
|
sleep 0.5
|
31
|
-
if $stdin.gets
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
if entry = $stdin.gets
|
34
|
+
case entry
|
35
|
+
when "c\n" # Cucumber: current tagged feature
|
36
|
+
runner.run_cucumber_command
|
37
|
+
when "ca\n" # Cucumber All: ~pending tagged feature
|
38
|
+
runner.run_cucumber_command('~pending')
|
39
|
+
else
|
40
|
+
if wait_for_enter_key("** Running all specs.. Hit <enter> again to exit RSpactor", 1)
|
41
|
+
@main_thread.exit
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
runner.run_all_specs
|
35
45
|
end
|
36
|
-
Runner.new(@root).run_all_specs
|
37
46
|
end
|
38
47
|
end
|
39
48
|
end
|
@@ -57,7 +66,7 @@ module RSpactor
|
|
57
66
|
end
|
58
67
|
end
|
59
68
|
end
|
60
|
-
|
69
|
+
|
61
70
|
def write(msg)
|
62
71
|
$stdout.print(msg)
|
63
72
|
$stdout.flush
|
data/lib/rspactor/listener.rb
CHANGED
@@ -5,18 +5,18 @@ module RSpactor
|
|
5
5
|
# based on http://rails.aizatto.com/2007/11/28/taming-the-autotest-beast-with-fsevents/
|
6
6
|
class Listener
|
7
7
|
attr_reader :last_check, :callback, :valid_extensions
|
8
|
-
|
8
|
+
|
9
9
|
def initialize(valid_extensions = nil)
|
10
10
|
@valid_extensions = valid_extensions
|
11
11
|
timestamp_checked
|
12
|
-
|
12
|
+
|
13
13
|
@callback = lambda do |stream, ctx, num_events, paths, marks, event_ids|
|
14
14
|
changed_files = extract_changed_files_from_paths(split_paths(paths, num_events))
|
15
15
|
timestamp_checked
|
16
16
|
yield changed_files unless changed_files.empty?
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def run(directories)
|
21
21
|
dirs = Array(directories)
|
22
22
|
stream = OSX::FSEventStreamCreate(OSX::KCFAllocatorDefault, callback, nil, dirs, OSX::KFSEventStreamEventIdSinceNow, 0.5, 0)
|
@@ -24,13 +24,13 @@ module RSpactor
|
|
24
24
|
$stderr.puts "Failed to create stream"
|
25
25
|
exit(1)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
OSX::FSEventStreamScheduleWithRunLoop(stream, OSX::CFRunLoopGetCurrent(), OSX::KCFRunLoopDefaultMode)
|
29
29
|
unless OSX::FSEventStreamStart(stream)
|
30
30
|
$stderr.puts "Failed to start stream"
|
31
31
|
exit(1)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
begin
|
35
35
|
OSX::CFRunLoopRun()
|
36
36
|
rescue Interrupt
|
@@ -39,18 +39,18 @@ module RSpactor
|
|
39
39
|
OSX::FSEventStreamRelease(stream)
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def timestamp_checked
|
44
44
|
@last_check = Time.now
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def split_paths(paths, num_events)
|
48
48
|
paths.regard_as('*')
|
49
49
|
rpaths = []
|
50
50
|
num_events.times { |i| rpaths << paths[i] }
|
51
51
|
rpaths
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def extract_changed_files_from_paths(paths)
|
55
55
|
changed_files = []
|
56
56
|
paths.each do |path|
|
@@ -62,25 +62,25 @@ module RSpactor
|
|
62
62
|
end
|
63
63
|
changed_files
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
def file_changed?(file)
|
67
67
|
File.stat(file).mtime > last_check
|
68
68
|
rescue Errno::ENOENT
|
69
69
|
false
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def ignore_path?(path)
|
73
73
|
path =~ /(?:^|\/)\.(git|svn)/
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
def ignore_file?(file)
|
77
77
|
File.basename(file).index('.') == 0 or not valid_extension?(file)
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
def file_extension(file)
|
81
81
|
file =~ /\.(\w+)$/ and $1
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
def valid_extension?(file)
|
85
85
|
valid_extensions.nil? or valid_extensions.include?(file_extension(file))
|
86
86
|
end
|
data/lib/rspactor/runner.rb
CHANGED
@@ -23,8 +23,8 @@ module RSpactor
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def start_interactor
|
26
|
-
@interactor = Interactor.new(
|
27
|
-
aborted = @interactor.wait_for_enter_key("** Hit <enter> to skip initial spec run",
|
26
|
+
@interactor = Interactor.new(self)
|
27
|
+
aborted = @interactor.wait_for_enter_key("** Hit <enter> to skip initial spec run", 2)
|
28
28
|
@interactor.start_termination_handler
|
29
29
|
run_all_specs unless aborted
|
30
30
|
end
|
@@ -62,8 +62,10 @@ module RSpactor
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
def run_cucumber_command
|
66
|
-
|
65
|
+
def run_cucumber_command(tags = 'current')
|
66
|
+
system("clear;") if @options[:clear]
|
67
|
+
puts "#{tags} tagged features"
|
68
|
+
cmd = [ruby_opts, cucumber_runner, cucumber_opts(tags)].flatten.join(' ')
|
67
69
|
@last_run_failed = run_command(cmd)
|
68
70
|
# Workaround for killing jruby process when used with celerity, cucumber and spork
|
69
71
|
# if you know how doing that better, please tell me: guillaumegentil@gmail.com
|
@@ -86,21 +88,23 @@ module RSpactor
|
|
86
88
|
all.concat inspector.determine_files(file)
|
87
89
|
end
|
88
90
|
unless files.empty?
|
89
|
-
system("clear;") if @options[:clear]
|
90
91
|
|
92
|
+
# cucumber features
|
91
93
|
if files.delete('cucumber')
|
92
|
-
puts '--- cucumber current tagged features ---'
|
93
94
|
run_cucumber_command
|
94
95
|
end
|
95
96
|
|
96
97
|
# specs files
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
unless files.empty?
|
99
|
+
system("clear;") if @options[:clear]
|
100
|
+
puts files.map { |f| f.to_s.gsub(/#{dir}/, '') }.join("\n")
|
101
|
+
|
102
|
+
previous_run_failed = last_run_failed?
|
103
|
+
run_spec_command(files)
|
104
|
+
|
105
|
+
if options[:retry_failed] and previous_run_failed and not last_run_failed?
|
106
|
+
run_all_specs
|
107
|
+
end
|
104
108
|
end
|
105
109
|
end
|
106
110
|
end
|
@@ -121,16 +125,16 @@ module RSpactor
|
|
121
125
|
opts
|
122
126
|
end
|
123
127
|
|
124
|
-
def cucumber_opts
|
128
|
+
def cucumber_opts(tags)
|
125
129
|
if File.exist?('features/support/cucumber.opts')
|
126
130
|
opts = File.read('features/support/cucumber.opts').gsub("\n", ' ')
|
127
131
|
else
|
128
132
|
opts = "--format progress --drb "
|
129
133
|
end
|
130
134
|
|
131
|
-
opts << " --tags
|
135
|
+
opts << " --tags #{tags}"
|
132
136
|
opts << cucumber_formatter_opts
|
133
|
-
opts << " --require features" # because
|
137
|
+
opts << " --require features" # because using require option overwrite default require
|
134
138
|
opts << " features"
|
135
139
|
opts
|
136
140
|
end
|
data/spec/runner_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guillaumegentil-rspactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Mislav Marohni\xC4\x87"
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2009-07-
|
15
|
+
date: 2009-07-22 00:00:00 -07:00
|
16
16
|
default_executable:
|
17
17
|
dependencies: []
|
18
18
|
|