torkify 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -1
- data/.travis.yml +6 -0
- data/README.md +8 -2
- data/VERSION +1 -1
- data/lib/torkify/conductor.rb +25 -14
- data/lib/torkify/{events/event.rb → event/basic_event.rb} +4 -4
- data/lib/torkify/event/dispatcher.rb +91 -0
- data/lib/torkify/event/echo_event.rb +23 -0
- data/lib/torkify/{events/event_message.rb → event/message.rb} +2 -2
- data/lib/torkify/event/parser.rb +70 -0
- data/lib/torkify/{events → event}/pass_or_fail_event.rb +15 -3
- data/lib/torkify/event/ran_all_test_files_event.rb +30 -0
- data/lib/torkify/{events → event}/status_change_event.rb +3 -3
- data/lib/torkify/{events → event}/test_event.rb +4 -3
- data/lib/torkify/listener.rb +17 -8
- data/lib/torkify/log/line_matcher.rb +33 -0
- data/lib/torkify/log/log_reader.rb +32 -0
- data/lib/torkify/log/parser.rb +96 -0
- data/lib/torkify/log/test_error.rb +7 -0
- data/lib/torkify/reader.rb +7 -5
- data/lib/torkify/version.rb +1 -1
- data/lib/torkify.rb +2 -3
- data/spec/conductor_spec.rb +3 -4
- data/spec/event/basic_event_spec.rb +30 -0
- data/spec/event/dispatcher_spec.rb +190 -0
- data/spec/event/echo_event_spec.rb +22 -0
- data/spec/event/parser_spec.rb +288 -0
- data/spec/{pass_or_fail_event_spec.rb → event/pass_or_fail_event_spec.rb} +2 -2
- data/spec/event/ran_all_test_files_event_spec.rb +42 -0
- data/spec/{status_change_event_spec.rb → event/status_change_event_spec.rb} +3 -3
- data/spec/{test_event_spec.rb → event/test_event_spec.rb} +2 -2
- data/spec/log/integration_spec.rb +222 -0
- data/spec/log/line_matcher_spec.rb +247 -0
- data/spec/log/log_reader_spec.rb +54 -0
- data/spec/log/logs/invalid_ruby_error_1.log +1 -0
- data/spec/log/logs/rspec_failure_1.log +19 -0
- data/spec/log/logs/rspec_failure_2.log +57 -0
- data/spec/log/logs/ruby_error_1.log +16 -0
- data/spec/log/logs/ruby_error_2.log +17 -0
- data/spec/log/logs/ruby_error_3.log +18 -0
- data/spec/log/logs/test_unit_error_1.log +22 -0
- data/spec/log/logs/test_unit_failure_1.log +22 -0
- data/spec/log/test_error_spec.rb +36 -0
- data/torkify.gemspec +1 -1
- metadata +63 -40
- data/lib/torkify/event_parser.rb +0 -36
- data/lib/torkify/observer_set.rb +0 -62
- data/spec/event_parser_spec.rb +0 -154
- data/spec/event_spec.rb +0 -18
- data/spec/observer_set_spec.rb +0 -100
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/log/parser'
|
3
|
+
|
4
|
+
def open_test_log_file(name)
|
5
|
+
root = File.expand_path(File.dirname(__FILE__))
|
6
|
+
File.open "#{root}/logs/#{name}"
|
7
|
+
end
|
8
|
+
|
9
|
+
module Torkify::Log
|
10
|
+
describe "parsing" do
|
11
|
+
shared_examples "an error" do
|
12
|
+
it { should be_a TestError }
|
13
|
+
its(:clean_text) { should == expected_text }
|
14
|
+
its(:filename) { should == expected_filename }
|
15
|
+
its(:lnum) { should == expected_lnum }
|
16
|
+
its(:type) { should == expected_type }
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
shared_examples "an error list with one error" do
|
21
|
+
subject { errors }
|
22
|
+
|
23
|
+
it { should be_an Array }
|
24
|
+
its(:length) { should == 1 }
|
25
|
+
end
|
26
|
+
|
27
|
+
context "a ruby error log" do
|
28
|
+
let(:log) { open_test_log_file 'ruby_error_1.log' }
|
29
|
+
let(:errors) { Parser.new(log).parse.errors }
|
30
|
+
|
31
|
+
context "the error list" do
|
32
|
+
it_behaves_like "an error list with one error"
|
33
|
+
end
|
34
|
+
|
35
|
+
context "the error" do
|
36
|
+
let(:expected_text) { 'syntax error, unexpected $end, expecting keyword_end (SyntaxError)' }
|
37
|
+
let(:expected_filename) { 'spec/integration_spec.rb' }
|
38
|
+
let(:expected_lnum) { '6' }
|
39
|
+
let(:expected_type) { 'E' }
|
40
|
+
|
41
|
+
subject { errors.first }
|
42
|
+
|
43
|
+
it_behaves_like "an error"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "a different ruby error log" do
|
48
|
+
let(:log) { open_test_log_file 'ruby_error_2.log' }
|
49
|
+
let(:errors) { Parser.new(log).parse.errors }
|
50
|
+
|
51
|
+
context "the error list" do
|
52
|
+
it_behaves_like "an error list with one error"
|
53
|
+
end
|
54
|
+
|
55
|
+
context "the error" do
|
56
|
+
let(:expected_text) { 'syntax error, unexpected keyword_end, expecting `}` (SyntaxError)' }
|
57
|
+
let(:expected_filename) { 'spec/error_spec.rb' }
|
58
|
+
let(:expected_lnum) { '15' }
|
59
|
+
let(:expected_type) { 'E' }
|
60
|
+
|
61
|
+
subject { errors.first }
|
62
|
+
|
63
|
+
it_behaves_like "an error"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "yet another ruby error log" do
|
68
|
+
let(:log) { open_test_log_file 'ruby_error_3.log' }
|
69
|
+
let(:errors) { Parser.new(log).parse.errors }
|
70
|
+
|
71
|
+
context "the error list" do
|
72
|
+
it_behaves_like "an error list with one error"
|
73
|
+
end
|
74
|
+
|
75
|
+
context "the error" do
|
76
|
+
let(:expected_text) { 'in `<module:TorkLog>`: uninitialized constant TorkLog::Stream (NameError)' }
|
77
|
+
let(:expected_filename) { 'spec/stream_spec.rb' }
|
78
|
+
let(:expected_lnum) { '4' }
|
79
|
+
let(:expected_type) { 'E' }
|
80
|
+
|
81
|
+
subject { errors.first }
|
82
|
+
|
83
|
+
it_behaves_like "an error"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "an invalid ruby error" do
|
88
|
+
let(:log) { open_test_log_file 'invalid_ruby_error_1.log' }
|
89
|
+
let(:parser) { Parser.new(log) }
|
90
|
+
|
91
|
+
it "raises a parse error" do
|
92
|
+
expect { parser.parse }.to raise_error ParserError
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "a test::unit error" do
|
97
|
+
let(:log) { open_test_log_file 'test_unit_error_1.log' }
|
98
|
+
let(:errors) { Parser.new(log).parse.errors }
|
99
|
+
|
100
|
+
context "the error list" do
|
101
|
+
it_behaves_like "an error list with one error"
|
102
|
+
end
|
103
|
+
|
104
|
+
context "the error" do
|
105
|
+
let(:expected_text) do <<ERR.strip
|
106
|
+
1) Error:
|
107
|
+
test: a user should redirect to admin login when visiting admin subdomain. (UserFlowsTest):
|
108
|
+
NameError: undefined local variable or method `root_pathh` for #<UserFlowsTest:0x000000036f2388>
|
109
|
+
test/integration/user_flows_test.rb:8:in `block (2 levels) in <class:UserFlowsTest>`
|
110
|
+
ERR
|
111
|
+
end
|
112
|
+
let(:expected_filename) { 'test/integration/user_flows_test.rb' }
|
113
|
+
let(:expected_lnum) { '8' }
|
114
|
+
let(:expected_type) { 'E' }
|
115
|
+
subject { errors.first }
|
116
|
+
|
117
|
+
it_behaves_like "an error"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "a test::unit failure" do
|
122
|
+
let(:log) { open_test_log_file 'test_unit_failure_1.log' }
|
123
|
+
let(:errors) { Parser.new(log).parse.errors }
|
124
|
+
|
125
|
+
context "the error list" do
|
126
|
+
it_behaves_like "an error list with one error"
|
127
|
+
end
|
128
|
+
|
129
|
+
context "the error" do
|
130
|
+
let(:expected_text) do <<ERR.strip
|
131
|
+
1) Failure:
|
132
|
+
test: Address should have many companie. (AddressTest)
|
133
|
+
[]:
|
134
|
+
Expected Address to have a has_many association called companie (no association called companie)
|
135
|
+
ERR
|
136
|
+
end
|
137
|
+
let(:expected_filename) { 'test/unit/address_test.rb' }
|
138
|
+
let(:expected_lnum) { '0' }
|
139
|
+
let(:expected_type) { 'E' }
|
140
|
+
subject { errors.first }
|
141
|
+
|
142
|
+
it_behaves_like "an error"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
context "an rspec error" do
|
148
|
+
let(:log) { open_test_log_file 'rspec_failure_1.log' }
|
149
|
+
let(:errors) { Parser.new(log).parse.errors }
|
150
|
+
|
151
|
+
context "the error list" do
|
152
|
+
it_behaves_like "an error list with one error"
|
153
|
+
end
|
154
|
+
|
155
|
+
context "the error" do
|
156
|
+
let(:expected_text) do <<-ERR.strip
|
157
|
+
1) parsing a test::unit error the error behaves like an error text
|
158
|
+
Failure/Error: Unable to find matching line from backtrace
|
159
|
+
expected: "1) Error:\\ntest: a user should redirect to admin login when visiting admin subdomain. (UserFlowsTest):\\nNameError: undefined local variable or method `root_pathh\` for #<UserFlowsTest:0x000000036f2388>\\n test/integration/user_flows_test.rb:8:in `block (2 levels) in <class:UserFlowsTest>\`\\n"
|
160
|
+
got: "1) Error:\\ntest: a user should redirect to admin login when visiting admin subdomain. (UserFlowsTest):\\nNameError: undefined local variable or method `root_pathh\` for #<UserFlowsTest:0x000000036f2388>\\n test/integration/user_flows_test.rb:8:in `block (2 levels) in <class:UserFlowsTest>\`" (using ==)
|
161
|
+
Diff:
|
162
|
+
Shared Example Group: "an error" called from spec/integration_spec.rb:95
|
163
|
+
# spec/integration_spec.rb:12:in `block (3 levels) in <module:TorkLog>`
|
164
|
+
ERR
|
165
|
+
end
|
166
|
+
let(:expected_filename) { 'spec/integration_spec.rb' }
|
167
|
+
let(:expected_lnum) { '12' }
|
168
|
+
let(:expected_type) { 'E' }
|
169
|
+
subject { errors.first }
|
170
|
+
|
171
|
+
it_behaves_like "an error"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context "an rspec log with multiple errors" do
|
176
|
+
let(:log) { open_test_log_file 'rspec_failure_2.log' }
|
177
|
+
let(:errors) { Parser.new(log).parse.errors }
|
178
|
+
|
179
|
+
context "the error list" do
|
180
|
+
subject { errors }
|
181
|
+
|
182
|
+
it { should be_an Array }
|
183
|
+
its(:length) { should == 6 }
|
184
|
+
end
|
185
|
+
|
186
|
+
context "the first error" do
|
187
|
+
subject { errors.first }
|
188
|
+
let(:expected_text) do <<LIN.strip
|
189
|
+
1) parsing a test::unit error the error list behaves like an error list with one error
|
190
|
+
Failure/Error: Unable to find matching line from backtrace
|
191
|
+
expected #<TorkLog::Parser:0x00000002be8c08 @file=#<File:/home/jon/.vim/bundle/vim-tork/spec/logs/test_unit_error_1.log>, @errors=[]> to be a kind of Array
|
192
|
+
Shared Example Group: "an error list with one error" called from spec/integration_spec.rb:80
|
193
|
+
# spec/integration_spec.rb:20:in `block (3 levels) in <module:TorkLog>`
|
194
|
+
LIN
|
195
|
+
end
|
196
|
+
let(:expected_filename) { 'spec/integration_spec.rb' }
|
197
|
+
let(:expected_lnum) { '20' }
|
198
|
+
let(:expected_type) { 'E' }
|
199
|
+
|
200
|
+
it_behaves_like "an error"
|
201
|
+
end
|
202
|
+
|
203
|
+
context "the last error" do
|
204
|
+
subject { errors.last }
|
205
|
+
let(:expected_text) do <<LIN.strip
|
206
|
+
6) parsing a test::unit error the error behaves like an error type
|
207
|
+
Failure/Error: Unable to find matching line from backtrace
|
208
|
+
NoMethodError:
|
209
|
+
undefined method `type` for "type":String
|
210
|
+
Shared Example Group: "an error" called from spec/integration_spec.rb:94
|
211
|
+
# spec/integration_spec.rb:14:in `block (3 levels) in <module:TorkLog>`
|
212
|
+
LIN
|
213
|
+
end
|
214
|
+
let(:expected_filename) { 'spec/integration_spec.rb' }
|
215
|
+
let(:expected_lnum) { '14' }
|
216
|
+
let(:expected_type) { 'E' }
|
217
|
+
|
218
|
+
it_behaves_like "an error"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/log/parser'
|
3
|
+
|
4
|
+
module Torkify::Log
|
5
|
+
describe LineMatcher do
|
6
|
+
shared_examples "a ruby error" do
|
7
|
+
let(:matcher) { LineMatcher.new line }
|
8
|
+
|
9
|
+
context "calling ruby_error?" do
|
10
|
+
subject { matcher.ruby_error? }
|
11
|
+
|
12
|
+
it { should be_true }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
shared_examples "an error description" do
|
17
|
+
let(:matcher) { LineMatcher.new line }
|
18
|
+
|
19
|
+
context "calling error_description?" do
|
20
|
+
subject { matcher.error_description? }
|
21
|
+
|
22
|
+
it { should be_true }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
shared_examples "a tork load line" do
|
27
|
+
let(:matcher) { LineMatcher.new line }
|
28
|
+
|
29
|
+
context "calling tork_load_line?" do
|
30
|
+
subject { matcher.tork_load_line? }
|
31
|
+
|
32
|
+
it { should be_true }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
shared_examples "a tork error line" do
|
37
|
+
let(:matcher) { LineMatcher.new line }
|
38
|
+
|
39
|
+
context "calling tork_error_line?" do
|
40
|
+
subject { matcher.tork_error_line? }
|
41
|
+
|
42
|
+
it { should be_true }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
shared_examples "the end of errors" do
|
47
|
+
let(:matcher) { LineMatcher.new line }
|
48
|
+
|
49
|
+
context "calling end_of_errors?" do
|
50
|
+
subject { matcher.end_of_errors? }
|
51
|
+
|
52
|
+
it { should be_true }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
shared_examples "a test error or failure" do
|
57
|
+
let(:matcher) { LineMatcher.new line }
|
58
|
+
|
59
|
+
context "calling test_error_or_failure?" do
|
60
|
+
subject { matcher.test_error_or_failure? }
|
61
|
+
|
62
|
+
it { should be_true }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
shared_examples "a finished line" do
|
67
|
+
let(:matcher) { LineMatcher.new line }
|
68
|
+
|
69
|
+
context "calling finished_line?" do
|
70
|
+
subject { matcher.finished_line? }
|
71
|
+
|
72
|
+
it { should be_true }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
shared_examples "a test summary" do
|
77
|
+
let(:matcher) { LineMatcher.new line }
|
78
|
+
|
79
|
+
context "calling test_summary?" do
|
80
|
+
subject { matcher.test_summary? }
|
81
|
+
|
82
|
+
it { should be_true }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "the starting line of a ruby fatal error" do
|
87
|
+
let(:line) do <<LIN
|
88
|
+
test/unit/address_test.rb:3:in `<top (required)>': uninitialized constant Tes (NameError)
|
89
|
+
LIN
|
90
|
+
end
|
91
|
+
|
92
|
+
it_behaves_like "a ruby error"
|
93
|
+
|
94
|
+
context "calling ruby_error" do
|
95
|
+
let(:matches) { LineMatcher.new(line).ruby_error }
|
96
|
+
|
97
|
+
context "the whole match" do
|
98
|
+
subject { matches[0] }
|
99
|
+
it { should == "test/unit/address_test.rb:3:in" }
|
100
|
+
end
|
101
|
+
context "the file" do
|
102
|
+
subject { matches[1] }
|
103
|
+
it { should == "test/unit/address_test.rb" }
|
104
|
+
end
|
105
|
+
context "the line number" do
|
106
|
+
subject { matches[2] }
|
107
|
+
it { should == "3" }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "the starting line of another ruby fatal error" do
|
113
|
+
let(:line) do <<LIN
|
114
|
+
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `load': spec/line_matcher_spec.rb:79: syntax error, unexpected keyword_end, expecting '}' (SyntaxError)
|
115
|
+
LIN
|
116
|
+
end
|
117
|
+
|
118
|
+
it_behaves_like "a ruby error"
|
119
|
+
end
|
120
|
+
|
121
|
+
context "the starting line of an rspec test failure" do
|
122
|
+
let(:line) do <<LIN
|
123
|
+
1) torklog::linematcher with the starting line of a ruby fatal error calling test_error_or_failure?"
|
124
|
+
LIN
|
125
|
+
end
|
126
|
+
|
127
|
+
it_behaves_like "a test error or failure"
|
128
|
+
end
|
129
|
+
|
130
|
+
context "a line of a test::unit test failure" do
|
131
|
+
let(:line) { " 15) Failure: " }
|
132
|
+
|
133
|
+
it_behaves_like "a test error or failure"
|
134
|
+
end
|
135
|
+
|
136
|
+
context "an rpsec test summary line" do
|
137
|
+
let(:line) { "6 examples, 0 failures" }
|
138
|
+
|
139
|
+
it_behaves_like "a test summary"
|
140
|
+
it_behaves_like "the end of errors"
|
141
|
+
end
|
142
|
+
|
143
|
+
context "a test::unit test summary line" do
|
144
|
+
let(:line) do <<LIN
|
145
|
+
1 tests, 11 assertions, 3 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
|
146
|
+
LIN
|
147
|
+
end
|
148
|
+
|
149
|
+
it_behaves_like "a test summary"
|
150
|
+
it_behaves_like "the end of errors"
|
151
|
+
end
|
152
|
+
|
153
|
+
context "a test::unit finished line" do
|
154
|
+
let(:line) { "Finished in 1.0396772 seconds." }
|
155
|
+
|
156
|
+
it_behaves_like "a finished line"
|
157
|
+
it_behaves_like "the end of errors"
|
158
|
+
end
|
159
|
+
|
160
|
+
context "the final line of an rspec error" do
|
161
|
+
let(:line) do <<LIN
|
162
|
+
# spec/integration_spec.rb:20:in `block (3 levels) in <module:TorkLog>'
|
163
|
+
LIN
|
164
|
+
end
|
165
|
+
|
166
|
+
it_behaves_like "an error description"
|
167
|
+
|
168
|
+
context "calling error_description" do
|
169
|
+
let(:matches) { LineMatcher.new(line).error_description }
|
170
|
+
|
171
|
+
context "the whole match" do
|
172
|
+
subject { matches[0] }
|
173
|
+
it { should == " # spec/integration_spec.rb:20:in" }
|
174
|
+
end
|
175
|
+
context "the file" do
|
176
|
+
subject { matches[1] }
|
177
|
+
it { should == "spec/integration_spec.rb" }
|
178
|
+
end
|
179
|
+
context "the line number" do
|
180
|
+
subject { matches[2] }
|
181
|
+
it { should == "20" }
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
context "the final line of an test::unit error" do
|
187
|
+
let(:line) do <<LIN
|
188
|
+
test/integration/user_flows_test.rb:8:in `block (2 levels) in <class:UserFlowsTest>'
|
189
|
+
LIN
|
190
|
+
end
|
191
|
+
|
192
|
+
it_behaves_like "an error description"
|
193
|
+
|
194
|
+
context "calling error_description" do
|
195
|
+
let(:matches) { LineMatcher.new(line).error_description }
|
196
|
+
|
197
|
+
context "the whole match" do
|
198
|
+
subject { matches[0] }
|
199
|
+
it { should == " test/integration/user_flows_test.rb:8:in" }
|
200
|
+
end
|
201
|
+
context "the file" do
|
202
|
+
subject { matches[1] }
|
203
|
+
it { should == "test/integration/user_flows_test.rb" }
|
204
|
+
end
|
205
|
+
context "the line number" do
|
206
|
+
subject { matches[2] }
|
207
|
+
it { should == "8" }
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context "a tork load line" do
|
213
|
+
let(:line) { "Loaded suite tork-worker[1] test/unit/address_test" }
|
214
|
+
|
215
|
+
it_behaves_like "a tork load line"
|
216
|
+
|
217
|
+
|
218
|
+
context "calling tork_load_line" do
|
219
|
+
let(:matches) { LineMatcher.new(line).tork_load_line }
|
220
|
+
|
221
|
+
context "the whole match" do
|
222
|
+
subject { matches[0] }
|
223
|
+
it { should == "Loaded suite tork-worker[1] test/unit/address_test" }
|
224
|
+
end
|
225
|
+
context "the file" do
|
226
|
+
subject { matches[1] }
|
227
|
+
it { should == "test/unit/address_test" }
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
context "a tork error line" do
|
233
|
+
let(:line) { "/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `load': spec/integration_spec.rb:6: syntax error, unexpected $end, expecting keyword_end (SyntaxError)" }
|
234
|
+
|
235
|
+
it_behaves_like "a tork error line"
|
236
|
+
|
237
|
+
context "calling tork_error_line" do
|
238
|
+
let(:matches) { LineMatcher.new(line).tork_error_line }
|
239
|
+
|
240
|
+
context "the whole match" do
|
241
|
+
subject { matches[0] }
|
242
|
+
it { should == "/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `load': " }
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'torkify/log/parser'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
module Torkify::Log
|
6
|
+
describe LogReader do
|
7
|
+
context "with an IO like data stream" do
|
8
|
+
let(:stream) do
|
9
|
+
StringIO.new <<-EOD
|
10
|
+
This is the first line
|
11
|
+
A second line
|
12
|
+
The final line
|
13
|
+
EOD
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:reader) { LogReader.new stream }
|
17
|
+
|
18
|
+
context "calling line" do
|
19
|
+
subject { reader.line }
|
20
|
+
|
21
|
+
it { should == "This is the first line\n" }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "calling forward" do
|
25
|
+
before { reader.forward }
|
26
|
+
subject { reader.line }
|
27
|
+
it { should == "A second line\n" }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "calling matcher" do
|
31
|
+
subject { reader.matcher }
|
32
|
+
|
33
|
+
it { should be_a LineMatcher }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "calling forward on the last line" do
|
37
|
+
before { reader.forward.forward }
|
38
|
+
|
39
|
+
it "should raise an EOF error" do
|
40
|
+
expect { reader.forward }.to raise_error EOFError
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
context "with an empty stream" do
|
47
|
+
let(:stream) { StringIO.new "" }
|
48
|
+
|
49
|
+
it "should raise an EOF error" do
|
50
|
+
expect { LogReader.new(stream) }.to raise_error EOFError
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `load': this is an unexpected log
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Run options: include {:line_numbers=>[83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108]}
|
2
|
+
.F...
|
3
|
+
|
4
|
+
Failures:
|
5
|
+
|
6
|
+
1) parsing a test::unit error the error behaves like an error text
|
7
|
+
Failure/Error: Unable to find matching line from backtrace
|
8
|
+
expected: "1) Error:\ntest: a user should redirect to admin login when visiting admin subdomain. (UserFlowsTest):\nNameError: undefined local variable or method `root_pathh' for #<UserFlowsTest:0x000000036f2388>\n test/integration/user_flows_test.rb:8:in `block (2 levels) in <class:UserFlowsTest>'\n"
|
9
|
+
got: "1) Error:\ntest: a user should redirect to admin login when visiting admin subdomain. (UserFlowsTest):\nNameError: undefined local variable or method `root_pathh' for #<UserFlowsTest:0x000000036f2388>\n test/integration/user_flows_test.rb:8:in `block (2 levels) in <class:UserFlowsTest>'" (using ==)
|
10
|
+
Diff:
|
11
|
+
Shared Example Group: "an error" called from spec/integration_spec.rb:95
|
12
|
+
# spec/integration_spec.rb:12:in `block (3 levels) in <module:TorkLog>'
|
13
|
+
|
14
|
+
Finished in 0.00464 seconds
|
15
|
+
5 examples, 1 failure
|
16
|
+
|
17
|
+
Failed examples:
|
18
|
+
|
19
|
+
rspec spec/integration_spec.rb:12 # parsing a test::unit error the error behaves like an error text
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Run options: include {:line_numbers=>[10, 41, 62]}
|
2
|
+
.............FFFFFF
|
3
|
+
|
4
|
+
Failures:
|
5
|
+
|
6
|
+
1) parsing a test::unit error the error list behaves like an error list with one error
|
7
|
+
Failure/Error: Unable to find matching line from backtrace
|
8
|
+
expected #<TorkLog::Parser:0x00000002be8c08 @file=#<File:/home/jon/.vim/bundle/vim-tork/spec/logs/test_unit_error_1.log>, @errors=[]> to be a kind of Array
|
9
|
+
Shared Example Group: "an error list with one error" called from spec/integration_spec.rb:80
|
10
|
+
# spec/integration_spec.rb:20:in `block (3 levels) in <module:TorkLog>'
|
11
|
+
|
12
|
+
2) parsing a test::unit error the error list behaves like an error list with one error length
|
13
|
+
Failure/Error: Unable to find matching line from backtrace
|
14
|
+
NoMethodError:
|
15
|
+
undefined method `length' for #<TorkLog::Parser:0x00000002bec240>
|
16
|
+
Shared Example Group: "an error list with one error" called from spec/integration_spec.rb:80
|
17
|
+
# spec/integration_spec.rb:21:in `block (3 levels) in <module:TorkLog>'
|
18
|
+
|
19
|
+
3) parsing a test::unit error the error behaves like an error text
|
20
|
+
Failure/Error: Unable to find matching line from backtrace
|
21
|
+
NoMethodError:
|
22
|
+
undefined method `text' for "text":String
|
23
|
+
Shared Example Group: "an error" called from spec/integration_spec.rb:94
|
24
|
+
# spec/integration_spec.rb:11:in `block (3 levels) in <module:TorkLog>'
|
25
|
+
|
26
|
+
4) parsing a test::unit error the error behaves like an error filename
|
27
|
+
Failure/Error: Unable to find matching line from backtrace
|
28
|
+
NoMethodError:
|
29
|
+
undefined method `filename' for "filename":String
|
30
|
+
Shared Example Group: "an error" called from spec/integration_spec.rb:94
|
31
|
+
# spec/integration_spec.rb:12:in `block (3 levels) in <module:TorkLog>'
|
32
|
+
|
33
|
+
5) parsing a test::unit error the error behaves like an error lnum
|
34
|
+
Failure/Error: Unable to find matching line from backtrace
|
35
|
+
NoMethodError:
|
36
|
+
undefined method `lnum' for "lnum":String
|
37
|
+
Shared Example Group: "an error" called from spec/integration_spec.rb:94
|
38
|
+
# spec/integration_spec.rb:13:in `block (3 levels) in <module:TorkLog>'
|
39
|
+
|
40
|
+
6) parsing a test::unit error the error behaves like an error type
|
41
|
+
Failure/Error: Unable to find matching line from backtrace
|
42
|
+
NoMethodError:
|
43
|
+
undefined method `type' for "type":String
|
44
|
+
Shared Example Group: "an error" called from spec/integration_spec.rb:94
|
45
|
+
# spec/integration_spec.rb:14:in `block (3 levels) in <module:TorkLog>'
|
46
|
+
|
47
|
+
Finished in 0.01105 seconds
|
48
|
+
19 examples, 6 failures
|
49
|
+
|
50
|
+
Failed examples:
|
51
|
+
|
52
|
+
rspec spec/integration_spec.rb:20 # parsing a test::unit error the error list behaves like an error list with one error
|
53
|
+
rspec spec/integration_spec.rb:21 # parsing a test::unit error the error list behaves like an error list with one error length
|
54
|
+
rspec spec/integration_spec.rb:11 # parsing a test::unit error the error behaves like an error text
|
55
|
+
rspec spec/integration_spec.rb:12 # parsing a test::unit error the error behaves like an error filename
|
56
|
+
rspec spec/integration_spec.rb:13 # parsing a test::unit error the error behaves like an error lnum
|
57
|
+
rspec spec/integration_spec.rb:14 # parsing a test::unit error the error behaves like an error type
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `load': spec/integration_spec.rb:6: syntax error, unexpected $end, expecting keyword_end (SyntaxError)
|
2
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `block in test'
|
3
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:42:in `fork'
|
4
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:42:in `test'
|
5
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:77:in `recv'
|
6
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:46:in `block (2 levels) in loop'
|
7
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:36:in `each'
|
8
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:36:in `block in loop'
|
9
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:33:in `catch'
|
10
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:33:in `loop'
|
11
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:27:in `loop'
|
12
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/bin/tork-master:126:in `<top (required)>'
|
13
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/tork-master:19:in `load'
|
14
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/tork-master:19:in `<main>'
|
15
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `eval'
|
16
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `<main>'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `load': spec/error_spec.rb:15: syntax error, unexpected keyword_end, expecting '}' (SyntaxError)
|
2
|
+
spec/error_spec.rb:34: syntax error, unexpected keyword_end, expecting '}'
|
3
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `block in test'
|
4
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:42:in `fork'
|
5
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:42:in `test'
|
6
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:77:in `recv'
|
7
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:46:in `block (2 levels) in loop'
|
8
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:36:in `each'
|
9
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:36:in `block in loop'
|
10
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:33:in `catch'
|
11
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:33:in `loop'
|
12
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:27:in `loop'
|
13
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/bin/tork-master:126:in `<top (required)>'
|
14
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/tork-master:19:in `load'
|
15
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/tork-master:19:in `<main>'
|
16
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `eval'
|
17
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `<main>'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
spec/stream_spec.rb:4:in `<module:TorkLog>': uninitialized constant TorkLog::Stream (NameError)
|
2
|
+
from spec/stream_spec.rb:3:in `<top (required)>'
|
3
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `load'
|
4
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:62:in `block in test'
|
5
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:42:in `fork'
|
6
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:42:in `test'
|
7
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:77:in `recv'
|
8
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:46:in `block (2 levels) in loop'
|
9
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:36:in `each'
|
10
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:36:in `block in loop'
|
11
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:33:in `catch'
|
12
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/server.rb:33:in `loop'
|
13
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/lib/tork/master.rb:27:in `loop'
|
14
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/gems/tork-19.3.0/bin/tork-master:126:in `<top (required)>'
|
15
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/tork-master:19:in `load'
|
16
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/tork-master:19:in `<main>'
|
17
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `eval'
|
18
|
+
from /home/jon/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `<main>'
|