seeing_is_believing 3.0.0.beta.5 → 3.0.0.beta.6
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/.gitignore +15 -0
- data/.rspec +4 -0
- data/.travis.yml +1 -1
- data/Rakefile +28 -18
- data/Readme.md +22 -13
- data/bin/seeing_is_believing +0 -1
- data/features/errors.feature +3 -3
- data/features/examples.feature +65 -0
- data/features/flags.feature +19 -0
- data/lib/seeing_is_believing/binary.rb +1 -1
- data/lib/seeing_is_believing/binary/align_chunk.rb +0 -8
- data/lib/seeing_is_believing/binary/commentable_lines.rb +7 -12
- data/lib/seeing_is_believing/binary/config.rb +18 -6
- data/lib/seeing_is_believing/binary/engine.rb +11 -6
- data/lib/seeing_is_believing/binary/remove_annotations.rb +17 -19
- data/lib/seeing_is_believing/error.rb +2 -2
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +8 -6
- data/lib/seeing_is_believing/event_stream/consumer.rb +55 -24
- data/lib/seeing_is_believing/event_stream/events.rb +11 -0
- data/lib/seeing_is_believing/event_stream/handlers/record_exit_events.rb +26 -0
- data/lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb +0 -22
- data/lib/seeing_is_believing/event_stream/handlers/update_result.rb +1 -0
- data/lib/seeing_is_believing/result.rb +5 -15
- data/lib/seeing_is_believing/version.rb +1 -1
- data/seeing_is_believing.gemspec +3 -2
- data/spec/binary/config_spec.rb +25 -8
- data/spec/binary/engine_spec.rb +12 -5
- data/spec/evaluate_by_moving_files_spec.rb +17 -4
- data/spec/event_stream_spec.rb +45 -10
- data/spec/seeing_is_believing_spec.rb +29 -4
- data/spec/wrap_expressions_spec.rb +6 -1
- metadata +23 -10
- data/Changelog.md +0 -33
- data/lib/seeing_is_believing/event_stream/handlers/record_exitstatus.rb +0 -18
@@ -130,11 +130,24 @@ RSpec.describe SeeingIsBelieving::EvaluateByMovingFiles do
|
|
130
130
|
expect(result.stdout).to eq %("b"\n)
|
131
131
|
end
|
132
132
|
|
133
|
-
it '
|
133
|
+
it 'must provide an event handler, which receives the process\'s events' do
|
134
|
+
# raises error
|
135
|
+
expect { described_class.new("", filename, {}) }
|
136
|
+
.to raise_error ArgumentError, /event_handler/
|
137
|
+
|
138
|
+
# sees all the events
|
139
|
+
seen = []
|
140
|
+
invoke '1', event_handler: lambda { |e| seen << e }
|
141
|
+
expect(seen).to_not be_empty
|
142
|
+
expect(seen.last).to eq SeeingIsBelieving::EventStream::Events::Finished.new
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'can set a timeout, which KILL interrupts the process and then waits for the events to finish' do
|
134
146
|
expect(Timeout).to receive(:timeout).with(123).and_raise(Timeout::Error)
|
135
|
-
expect(Process).to receive(:kill)
|
136
|
-
|
137
|
-
|
147
|
+
expect(Process).to receive(:kill).with("KILL", an_instance_of(Fixnum))
|
148
|
+
result = invoke 'p gets', timeout_seconds: 123
|
149
|
+
expect(result.timeout?).to eq true
|
150
|
+
expect(result.timeout_seconds).to eq 123
|
138
151
|
end
|
139
152
|
|
140
153
|
it 'raises an ArgumentError if given arguments it doesn\'t know' do
|
data/spec/event_stream_spec.rb
CHANGED
@@ -106,19 +106,30 @@ module SeeingIsBelieving::EventStream
|
|
106
106
|
expect(consumer.call.value).to eq "a� å" # space just so its easier to see
|
107
107
|
end
|
108
108
|
|
109
|
+
it 'scrubs any invalid bytes to "�" when encoding was already UTF8, but was invalid' do
|
110
|
+
producer.record_sib_version("\xff√")
|
111
|
+
expect(consumer.call.value).to eq "�√"
|
112
|
+
end
|
113
|
+
|
109
114
|
it 'raises NoMoreEvents if input is closed before it finishes reading the number of requested inputs' do
|
110
115
|
finish!
|
111
116
|
expect { consumer.call 10 }.to raise_error SeeingIsBelieving::NoMoreEvents
|
112
117
|
end
|
113
118
|
|
114
|
-
it 'raises NoMoreEvents once
|
119
|
+
it 'raises NoMoreEvents once its input streams are all closed and its seen an exit status' do
|
115
120
|
close_streams eventstream_producer, stdout_producer, stderr_producer
|
116
|
-
producer.finish!
|
117
121
|
consumer.process_exitstatus 0
|
118
122
|
consumer.each { }
|
119
123
|
expect { consumer.call }.to raise_error SeeingIsBelieving::NoMoreEvents
|
120
124
|
end
|
121
125
|
|
126
|
+
it 'raises NoMoreEvents once its input streams are all closed and its seen a timeout' do
|
127
|
+
close_streams eventstream_producer, stdout_producer, stderr_producer
|
128
|
+
consumer.process_timeout 1
|
129
|
+
consumer.each { }
|
130
|
+
expect { consumer.call }.to raise_error SeeingIsBelieving::NoMoreEvents
|
131
|
+
end
|
132
|
+
|
122
133
|
it 'gracefully handles its side of the streams getting closed' do
|
123
134
|
close_streams eventstream_consumer, stdout_consumer, stderr_consumer
|
124
135
|
consumer.process_exitstatus 0
|
@@ -383,14 +394,15 @@ module SeeingIsBelieving::EventStream
|
|
383
394
|
backtrace_filename: __FILE__
|
384
395
|
end
|
385
396
|
|
386
|
-
example 'Example: Common edge case: name error' do
|
387
|
-
backtrace_line = record_exception(99) { not_a_local_or_meth }
|
388
|
-
backtrace_frame =
|
397
|
+
example 'Example: Common edge case: name error', t:true do
|
398
|
+
backtrace_line = record_exception(99) { BasicObject.new.instance_eval { not_a_local_or_meth } }
|
399
|
+
backtrace_frame = 0
|
400
|
+
backtrace_frame += 1 if defined? Rubinius # their method missing goes into the kernel
|
389
401
|
assert_exception consumer.call,
|
390
402
|
recorded_line_no: 99,
|
391
403
|
class_name_matcher: /^NameError$/,
|
392
404
|
message_matcher: /\bnot_a_local_or_meth\b/,
|
393
|
-
backtrace_index:
|
405
|
+
backtrace_index: backtrace_frame,
|
394
406
|
backtrace_line: backtrace_line,
|
395
407
|
backtrace_filename: __FILE__
|
396
408
|
end
|
@@ -579,13 +591,25 @@ module SeeingIsBelieving::EventStream
|
|
579
591
|
expect(consumer.call).to eq Events::Exitstatus.new(value: 92)
|
580
592
|
end
|
581
593
|
|
582
|
-
it 'emits a Finished event when all streams are closed and it has
|
583
|
-
|
584
|
-
|
585
|
-
expect(
|
594
|
+
it 'emits a Finished event when all streams are closed and it has an exit status' do
|
595
|
+
consumer.process_exitstatus 1
|
596
|
+
close_streams eventstream_producer, stdout_producer, stderr_producer
|
597
|
+
expect(consumer.each.to_a.last).to eq Events::Finished.new
|
598
|
+
end
|
599
|
+
|
600
|
+
it 'emits a Timeout event on process_timeout' do
|
601
|
+
consumer.process_timeout 1.23
|
602
|
+
expect(consumer.call).to eq Events::Timeout.new(seconds:1.23)
|
603
|
+
end
|
604
|
+
|
605
|
+
it 'emits a Finished event when all streams are closed and it has a timeout' do
|
606
|
+
consumer.process_timeout 1
|
607
|
+
close_streams eventstream_producer, stdout_producer, stderr_producer
|
608
|
+
expect(consumer.each.to_a.last).to eq Events::Finished.new
|
586
609
|
end
|
587
610
|
end
|
588
611
|
|
612
|
+
|
589
613
|
describe Events do
|
590
614
|
specify 'Event raises an error if .event_name was not overridden' do
|
591
615
|
expect { Event.event_name }.to raise_error NotImplementedError
|
@@ -600,6 +624,7 @@ module SeeingIsBelieving::EventStream
|
|
600
624
|
[Events::SiBVersion , :sib_version],
|
601
625
|
[Events::RubyVersion , :ruby_version],
|
602
626
|
[Events::Exitstatus , :exitstatus],
|
627
|
+
[Events::Timeout , :timeout],
|
603
628
|
[Events::Exec , :exec],
|
604
629
|
[Events::ResultsTruncated , :results_truncated],
|
605
630
|
[Events::LineResult , :line_result],
|
@@ -691,5 +716,15 @@ module SeeingIsBelieving::EventStream
|
|
691
716
|
end
|
692
717
|
end
|
693
718
|
end
|
719
|
+
|
720
|
+
# most tests are just in the sense that fkn everything uses it all over the place
|
721
|
+
# but they use the valid cases, so this is just hitting the invalid one
|
722
|
+
require 'seeing_is_believing/event_stream/handlers/update_result'
|
723
|
+
describe Handlers::UpdateResult do
|
724
|
+
it 'raises an error if it sees an event it doesn\'t know' do
|
725
|
+
expect { described_class.new(double :result).call("unknown event") }
|
726
|
+
.to raise_error /unknown event/
|
727
|
+
end
|
728
|
+
end
|
694
729
|
end
|
695
730
|
end
|
@@ -62,11 +62,11 @@ RSpec.describe SeeingIsBelieving do
|
|
62
62
|
expect(result.filename).to eq 'abc.rb'
|
63
63
|
end
|
64
64
|
|
65
|
-
it 'makes the Ruby
|
65
|
+
it 'makes the Ruby version info available' do
|
66
66
|
expect(invoke('').ruby_version).to eq RUBY_VERSION
|
67
67
|
end
|
68
68
|
|
69
|
-
it 'allows
|
69
|
+
it 'allows users to pass in their own rewrite_code' do
|
70
70
|
wrapper = lambda { |program|
|
71
71
|
SeeingIsBelieving::WrapExpressions.call program,
|
72
72
|
before_each: -> * { '(' },
|
@@ -348,8 +348,14 @@ RSpec.describe SeeingIsBelieving do
|
|
348
348
|
['6']]
|
349
349
|
end
|
350
350
|
|
351
|
-
it '
|
352
|
-
|
351
|
+
it 'records the timeouts on the result' do
|
352
|
+
result = invoke "1"
|
353
|
+
expect(result).to_not be_timeout
|
354
|
+
expect(result.timeout_seconds).to eq nil
|
355
|
+
|
356
|
+
result = invoke "sleep 0.2", timeout_seconds: 0.1
|
357
|
+
expect(result).to be_timeout
|
358
|
+
expect(result.timeout_seconds).to eq 0.1
|
353
359
|
end
|
354
360
|
|
355
361
|
it 'records the exit status' do
|
@@ -546,4 +552,23 @@ RSpec.describe SeeingIsBelieving do
|
|
546
552
|
expect(invoke('exec "ruby", "-e", "exit 5"').exitstatus).to eq 5
|
547
553
|
end
|
548
554
|
end
|
555
|
+
|
556
|
+
# Looked through the implementation of event_stream/producer to find a list of core behaviour it depends on
|
557
|
+
# this is a list of things to check that it can work without.
|
558
|
+
# based on this issue: https://github.com/JoshCheek/seeing_is_believing/issues/55
|
559
|
+
describe 'it works even in hostile environments' do
|
560
|
+
specify 'when IO does not have sync, <<, and flush'
|
561
|
+
specify 'when Queue does not have <<, shift, and clear'
|
562
|
+
specify 'when Symbol does not have ==, to_s, inspect'
|
563
|
+
specify 'when String does not have ==, to_s, inspect, to_i'
|
564
|
+
specify 'when Fixnum does not have <, next, =='
|
565
|
+
specify 'when Hash does not have [], []='
|
566
|
+
specify 'when Array does not have pack, <<, to_ary, grep, first, [], []='
|
567
|
+
specify 'when Marshal does not have dump'
|
568
|
+
specify 'when Kernel does not have defined?, kind_of?'
|
569
|
+
specify 'when SystemExit does not have status'
|
570
|
+
specify 'when Enumerable does not have map'
|
571
|
+
specify 'when Exception does not have status'
|
572
|
+
specify 'when Thread does not have new, join'
|
573
|
+
end
|
549
574
|
end
|
@@ -83,6 +83,12 @@ RSpec.describe SeeingIsBelieving::WrapExpressions do
|
|
83
83
|
expect(heredoc_wrap "<<A.size <<B\nA\nB").to eq "[{<<A.size <<B}]\nA\nB"
|
84
84
|
expect(heredoc_wrap "<<A.size(<<B)\nA\nB").to eq "[{<<A.size(<<B)}]\nA\nB"
|
85
85
|
end
|
86
|
+
|
87
|
+
example 'heredocs withs spaces in the delimiter' do
|
88
|
+
expect(heredoc_wrap "<<'a b'\n1\na b").to eq "[{<<'a b'}]\n1\na b"
|
89
|
+
expect(heredoc_wrap "<<'a b'\n1\na b\n1").to eq "[{<<'a b'}\n1\na b\n{1}]"
|
90
|
+
expect(heredoc_wrap '<<"a b"'+"\n1\na b").to eq '[{<<"a b"}]'+"\n1\na b"
|
91
|
+
end
|
86
92
|
end
|
87
93
|
|
88
94
|
it 'identifies the last line of the body' do
|
@@ -885,7 +891,6 @@ RSpec.describe SeeingIsBelieving::WrapExpressions do
|
|
885
891
|
expect(wrap("a b:1, **c")).to eq "<a b:1, **c>"
|
886
892
|
expect(wrap("{\na:1,\n**b\n}")).to eq "<{\na:<1>,\n**<b>\n}>"
|
887
893
|
expect(wrap("a(b:1,\n **c\n)")).to eq "<a(b:<1>,\n **<c>\n)>"
|
888
|
-
pending 'Fixed this in Parser, but it\'s not released yet https://github.com/whitequark/parser/commit/aeb95c776d11e212ed95b92c69e96d1cccdb6424'
|
889
894
|
expect(wrap("def a(*, **)\n1\nend")).to eq "<def a(*, **)\n<1>\nend>"
|
890
895
|
end
|
891
896
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seeing_is_believing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.beta.
|
4
|
+
version: 3.0.0.beta.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Cheek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.0.
|
19
|
+
version: 2.2.0.3
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '3.0'
|
@@ -26,10 +26,24 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.2.0.
|
29
|
+
version: 2.2.0.3
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: what_weve_got_here_is_an_error_to_communicate
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: haiti
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,14 +84,14 @@ dependencies:
|
|
70
84
|
requirements:
|
71
85
|
- - "~>"
|
72
86
|
- !ruby/object:Gem::Version
|
73
|
-
version: '3.
|
87
|
+
version: '3.2'
|
74
88
|
type: :development
|
75
89
|
prerelease: false
|
76
90
|
version_requirements: !ruby/object:Gem::Requirement
|
77
91
|
requirements:
|
78
92
|
- - "~>"
|
79
93
|
- !ruby/object:Gem::Version
|
80
|
-
version: '3.
|
94
|
+
version: '3.2'
|
81
95
|
- !ruby/object:Gem::Dependency
|
82
96
|
name: cucumber
|
83
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,8 +131,8 @@ extensions: []
|
|
117
131
|
extra_rdoc_files: []
|
118
132
|
files:
|
119
133
|
- ".gitignore"
|
134
|
+
- ".rspec"
|
120
135
|
- ".travis.yml"
|
121
|
-
- Changelog.md
|
122
136
|
- Gemfile
|
123
137
|
- Rakefile
|
124
138
|
- Readme.md
|
@@ -156,7 +170,7 @@ files:
|
|
156
170
|
- lib/seeing_is_believing/event_stream/consumer.rb
|
157
171
|
- lib/seeing_is_believing/event_stream/events.rb
|
158
172
|
- lib/seeing_is_believing/event_stream/handlers/debug.rb
|
159
|
-
- lib/seeing_is_believing/event_stream/handlers/
|
173
|
+
- lib/seeing_is_believing/event_stream/handlers/record_exit_events.rb
|
160
174
|
- lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb
|
161
175
|
- lib/seeing_is_believing/event_stream/handlers/update_result.rb
|
162
176
|
- lib/seeing_is_believing/event_stream/producer.rb
|
@@ -246,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
260
|
version: 1.3.1
|
247
261
|
requirements: []
|
248
262
|
rubyforge_project: seeing_is_believing
|
249
|
-
rubygems_version: 2.4.
|
263
|
+
rubygems_version: 2.4.5
|
250
264
|
signing_key:
|
251
265
|
specification_version: 4
|
252
266
|
summary: Records results of every line of code in your file
|
@@ -276,4 +290,3 @@ test_files:
|
|
276
290
|
- spec/seeing_is_believing_spec.rb
|
277
291
|
- spec/spec_helper.rb
|
278
292
|
- spec/wrap_expressions_spec.rb
|
279
|
-
has_rdoc:
|
data/Changelog.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Change Log
|
2
|
-
All notable changes to this project will be documented in this file.
|
3
|
-
The Changelog was introduced on 2014-09-15, and is approximately in
|
4
|
-
accordance with [http://keepachangelog.com/](http://keepachangelog.com/).
|
5
|
-
I do my best to follow [Semantic Versioning](http://semver.org/).
|
6
|
-
|
7
|
-
## 3.0.0.beta - 2014-??-??
|
8
|
-
### Added
|
9
|
-
- Issue for 3.0 is at https://github.com/JoshCheek/seeing_is_believing/issues/47
|
10
|
-
- Added a [Changelog](Changelog.md) in accordance with [http://keepachangelog.com/](http://keepachangelog.com/)
|
11
|
-
- `seeing_is_believing/version` is required by default,
|
12
|
-
you can now check your version by just typing `SeeingIsBelieving::VERSION` and running it.
|
13
|
-
|
14
|
-
### Changed
|
15
|
-
- Communication between SiB and the process running the code is no longer done by
|
16
|
-
serializing the result with JSON. Now, there is an
|
17
|
-
[EventStream](https://github.com/JoshCheek/seeing_is_believing/blob/4b9134ca45e001ebe5f139384bd1beee98b5e371/lib/seeing_is_believing/event_stream.rb)
|
18
|
-
class, which will send the information back to the parent process as soon as it
|
19
|
-
knows about it. For users who interact purely with the binary, this just means that
|
20
|
-
JSON will not already be required.
|
21
|
-
- WrapExpressions' `before_all` and `after_all` keys now point to values that are lambdas with no args.
|
22
|
-
Mostly this is for consistency since `before_each` and `after_each` are lambas,
|
23
|
-
But also, because at some point I might want to provide an argument, and this will make it easier.
|
24
|
-
And because it allows certain conveniences, such as setting local vars in the lambda.
|
25
|
-
- Loosened version constraints on parser dependency
|
26
|
-
- When you iterate over the result, it iterates over a result for each line of the file
|
27
|
-
rather than the number of lines it actually captured.
|
28
|
-
- The `--JSON` flag emits a different structure
|
29
|
-
|
30
|
-
### Removed
|
31
|
-
- Dependency on psych
|
32
|
-
- Remove HasException module. The only thing using it now is Result, so just relevant behaviour into there.
|
33
|
-
- SeeingIsBelieving::Line class
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class SeeingIsBelieving
|
2
|
-
module EventStream
|
3
|
-
module Handlers
|
4
|
-
class RecordExitStatus
|
5
|
-
attr_reader :exitstatus
|
6
|
-
|
7
|
-
def initialize(next_observer)
|
8
|
-
@next_observer = next_observer
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(event)
|
12
|
-
@exitstatus = event.value if event.event_name == :exitstatus
|
13
|
-
@next_observer.call(event)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|