joshcheek / seeing_is_believing Goto Github PK
View Code? Open in Web Editor NEWDisplays the results of every line of code in your file
Displays the results of every line of code in your file
SeeingIsBelieving::VERSION "2.1.4"
Parser::VERSION "2.2.0.pre.4"
RUBY_VERSION "2.1.1"
ENV['RUBY_VERSION'] "2.1.1"
require 'json' # => false
initial = "”" # => "”"
result =
JSON.dump( # => JSON
initial # => "”"
) # => "\"”\""
JSON.parse result
begin; $SiB.number_of_captures = Float::INFINITY; $SiB.record_result(1, (require 'json'))
$SiB.record_result(3, (initial = "”"))
$SiB.record_result(8, (result =
$SiB.record_result(6, (JSON)).dump(
$SiB.record_result(7, (initial))
)))
$SiB.record_result(10, (JSON.parse result));rescue Exception;lambda {line_number = $!.backtrace.grep(/#{__FILE__}/).first[/:\d+/][1..-1].to_i;$SiB.record_exception line_number, $!;$SiB.exitstatus = 1;$SiB.exitstatus = $!.status if $!.kind_of? SystemExit;}.call;end
Is empty.
/Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/json/common.rb:223:in `encode': "\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/json/common.rb:223:in `generate'
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/json/common.rb:223:in `generate'
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/json/common.rb:394:in `dump'
from /Users/josh/.gem/ruby/2.1.1/gems/seeing_is_believing-2.1.4/lib/seeing_is_believing/the_matrix.rb:39:in `block in <top (required)>'
1
{}[:a] ||= {
}
Winds up wrapping like this
<{}[:a]> ||= {
}
But it should wrap like this
<{}[:a] ||= {
}>
Or maybe like this, IDK.
{}[:a] ||= <{
}>
ALSO Check &&=
and others
In TextMate, when I run this code, it hangs indefinitely, even though there is a timeout set. Probably something in the parent process waits (probably either the consumer or EvaluateByMovingFiles). Or maybe the fork prevents the timeout from working correctly. Regardless, users shouldn't have to go grepping and killing processes on their own, SiB should respect the timeout.
read, write = IO.pipe
stream = IO.open write.to_i
if fork
p $$
stream.puts "parent"
# stream.close unless stream.closed? # => nil
# write.close unless write.closed? # ~> Errno::EBADF: Bad file descriptor
else
p $$
stream.puts "child"
# stream.close unless stream.closed?
# write.close unless write.closed?
end
stream
write
read.read
There is a surprisingly large number of processes spawned to accomplish SiB on my machine. I've analyzed them and know where they all come from, except for why there is three of the bottommost invocation:
# The original invocation from TextMate
# https://github.com/JoshCheek/text_mate_1-seeing-is_believing/blob/db1c2fd3e0de50370e3c0e2d2d834c4ed4b16edf/Commands/annotate%20all%20lines.tmCommand#L11-22
/bin/sh
/Users/josh/code/dotfiles/bin/sib_ruby
-S seeing_is_believing
-Ku
--result-length 400
--number-of-captures 200 --alignment-strategy chunk --timeout 5 --shebang /Users/josh/code/dotfiles/bin/sib_rub
# looks like this is chruby-exec
# https://github.com/postmodern/chruby/blob/e7187af3347ff7da3be363f40f479fe7332b6942/bin/chruby-exec#L36-40
# also, apparently my chruby is outdated, b/c that code has been replaced on master
/bin/bash -l -c
chruby 2.1.2 &&
ruby -S
seeing_is_believing
-Ku
--result-length 400
--number-of-captures 200
--alignment-strategy chunk
--timeout 5
--shebang /Users/josh/code/dotfiles/bin/sib_ruby
# This would be what we are telling chruby to exec, so RHS of the call above, after it's fixed the environment
# In newer versions, it calls exec, so wouldn't have two processes like this
ruby -S
seeing_is_believing
-Ku
--result-length 400
--number-of-captures 200
--alignment-strategy chunk
--timeout 5
--shebang /Users/josh/code/dotfiles/bin/sib_ruby
# SiB executing the rewritten code. We see this one twice because it forked.
/Users/josh/.rubies/ruby-2.1.2/bin/ruby
-W0
-Ku
-I /Users/josh/.gem/ruby/2.1.2/gems/seeing_is_believing-3.0.0.beta.5/lib
-I /Users/josh/.gem/ruby/2.1.2/gems/seeing_is_believing-3.0.0.beta.5/lib
-r seeing_is_believing/the_matrix
/var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20150131-66512-yo5vuh/program.rb
/Users/josh/.rubies/ruby-2.1.2/bin/ruby
-W0
-Ku
-I /Users/josh/.gem/ruby/2.1.2/gems/seeing_is_believing-3.0.0.beta.5/lib
-I /Users/josh/.gem/ruby/2.1.2/gems/seeing_is_believing-3.0.0.beta.5/lib
-r seeing_is_believing/the_matrix
/var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20150131-66512-yo5vuh/program.rb
No matter what I run it on, seeing_is_believing outputs this kind of error:
program-without-annotations:1:1: error: cannot insert "$SiB.record_result(1, ("
program-without-annotations:1: foo = 1 # =>
program-without-annotations:1:
program-without-annotations:1:1: note: clobbered by: insert "begin; $SiB.number_of_captures = Float::INFINITY; "
program-without-annotations:1: foo = 1 # =>
program-without-annotations:1:
Parser::ClobberingError
Parser::Source::Rewriter detected clobbering
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/parser-2.3.0.4/lib/parser/source/rewriter.rb:387:in `raise_clobber_error'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/parser-2.3.0.4/lib/parser/source/rewriter.rb:209:in `append'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/parser-2.3.0.4/lib/parser/source/rewriter.rb:64:in `insert_before'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:36:in `block in call'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:35:in `each'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:35:in `call'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:11:in `call'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:52:in `program_that_will_record_expressions'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:34:in `call'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:15:in `call'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary/add_annotations.rb:29:in `initialize'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:154:in `new'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:154:in `annotator'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:114:in `evaluate_program'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:45:in `call'
/Users/brandonpittman/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/seeing_is_believing-2.2.0/bin/seeing_is_believing:6:in `<top (required)>'
/Users/brandonpittman/.rbenv/versions/2.3.0/bin/seeing_is_believing:22:in `load'
/Users/brandonpittman/.rbenv/versions/2.3.0/bin/seeing_is_believing:22:in `<main>'
Happens from Vim or using the CLI.
Ruby prints warnings to standard error. Seeing Is Believing does not capture them (as of 3.0.0.beta.5)
$ cat f.rb
warn 'wat'
$ ruby f.rb
wat
$ seeing_is_believing f.rb
warn 'wat' # => nil
It blew up because SeeingIsBelieving isn't good enough >.<
Please log an issue at: https://github.com/JoshCheek/seeing_is_believing/issues
Program: "begin;($seeing_is_believing_current_result.record_result(3, (class CreditCard\n\nend)))\n\n(
Stdout: "\x04\bo:\x1ESeeingIsBelieving::Result\v:\x15@max_line_numberi\n:\x15@min_line_numberi\x06:\r@results{\ai\bo:\x1CSeeingIsBelieving::Line\x06:\v@array[\x06I"\bnil\x06:\x06EFi\no;\t\a;\n[\0:\x0F@exceptiono:\x12NoMethodError\t:\tmesgu:\x17NameError::message0undefined method describe' for main:Object:\abt[\x06I\"'/Users/koriroys/test:5:in
Stderr: ""
Status: #<Process::Status: pid 65385 exit 0>
ArgumentError
undefined class/module CreditCard
V3 is basically ready at this point. But I'm going to wait until my next break so I can try and make the editor integrations better. I figure a big version bump will get a little bit of attention, so it should be particularly slick when it rolls out. But I spent a lot of time on this (270 commits since I started my break) and want to spend the rest of it on https://github.com/JoshCheek/ruby_object_model_viewer
To accommodate the changes I want, should bump the major version. As long as I'm doing that, might as well stick in a bunch of things I want.
Code is now on master, see the commits.
956bd0c..a38fcf4
Lots more stuff happened than is listed here. But I don't think anyone other than me cares about this, so not going to put the effort in to update it.
:inspect
and :pp
), and Caller can inject their own expression wrapping.--shebang
since RbConfig.ruby
gives the information we needed this for.YAML cannot be used because it can't deal with hostile environments. Run this as normal Ruby (not SiB)
class Object
def !(a)
end
end
require 'yaml'
p YAML.load YAML.dump Object.new
blows up:
bug:2:in `!': wrong number of arguments (0 for 1) (ArgumentError)
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.rb:886:in `block in suffixes'
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.rb:884:in `map'
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.rb:884:in `suffixes'
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.rb:1091:in `find_unresolved_default_spec'
from /Users/josh/.rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:43:in `require'
from bug:6:in `<main>'
class A < BasicObject # => BasicObject
end # => nil
A.new # ~> NoMethodError: undefined method `tap' for #<A:0x007fc81c9259a0>
Recently sib
started blowing up on me, and I traced it to the parser
gem version. I had the latest version (2.3.0.6) installed, along with an older one (2.2.3.0). When I removed the newer version, stuff started working again.
Here's the error I was getting on any Ruby source code:
program-without-annotations:3:1: error: cannot insert "$SiB.record_result(3, ("
program-without-annotations:3: STOP_WORDS = %w[when in the of]
program-without-annotations:3:
program-without-annotations:3:1: note: clobbered by: insert "begin; $SiB.number_of_captures = Float::INFINITY; "
program-without-annotations:3: STOP_WORDS = %w[when in the of]
program-without-annotations:3:
Parser::ClobberingError
Parser::Source::Rewriter detected clobbering
/home/avdi/.gem/ruby/2.3.0/gems/parser-2.3.0.6/lib/parser/source/rewriter.rb:387:in `raise_clobber_error'
/home/avdi/.gem/ruby/2.3.0/gems/parser-2.3.0.6/lib/parser/source/rewriter.rb:209:in `append'
/home/avdi/.gem/ruby/2.3.0/gems/parser-2.3.0.6/lib/parser/source/rewriter.rb:64:in `insert_before'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:36:in `block in call'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:35:in `each'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:35:in `call'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/wrap_expressions.rb:11:in `call'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:52:in `program_that_will_record_expressions'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:34:in `call'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:15:in `call'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary/add_annotations.rb:29:in `initialize'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:154:in `new'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:154:in `annotator'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:114:in `evaluate_program'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:45:in `call'
/home/avdi/.gem/ruby/2.3.0/gems/seeing_is_believing-2.2.0/bin/seeing_is_believing:6:in `<top (required)>'
/home/avdi/.gem/ruby/2.3.0/bin/seeing_is_believing:23:in `load'
/home/avdi/.gem/ruby/2.3.0/bin/seeing_is_believing:23:in `<main>'
Do not know why it happened? Any hint about why it happened or how to solve it?
Thanks a lot.
/Users/crokobit/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0/json-1.8.2/json/ext/parser.bundle: [BUG] Segmentation fault at 0x00000000000440
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
-- Control frame information -----------------------------------------------
c:0027 p:-17542969831314 s:0123 e:000122 TOP [FINISH]
c:0026 p:---- s:0121 e:000120 CFUNC :require
c:0025 p:0170 s:0117 e:000116 METHOD /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69
c:0024 p:0009 s:0107 e:000106 CLASS /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/ext.rb:13
c:0023 p:0011 s:0105 e:000104 CLASS /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/ext.rb:12
c:0022 p:0056 s:0103 e:000102 TOP /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/ext.rb:9 [FINISH]
c:0021 p:---- s:0101 e:000100 CFUNC :require
c:0020 p:0170 s:0097 e:000096 METHOD /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69
c:0019 p:0019 s:0087 e:000086 CLASS /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json.rb:58
c:0018 p:0017 s:0085 e:000084 TOP /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json.rb:54 [FINISH]
c:0017 p:---- s:0083 e:000082 CFUNC :require
c:0016 p:0170 s:0079 e:000078 METHOD /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69
c:0015 p:0007 s:0069 e:000068 TOP /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/evaluate_by_moving_files.rb:14 [FINISH]
c:0014 p:---- s:0067 e:000066 CFUNC :require
c:0013 p:0170 s:0063 e:000062 METHOD /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69
c:0012 p:0055 s:0053 e:000052 TOP /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:8 [FINISH]
c:0011 p:---- s:0051 e:000050 CFUNC :require
c:0010 p:0170 s:0047 e:000046 METHOD /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69
c:0009 p:0007 s:0037 e:000036 TOP /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:1 [FINISH]
c:0008 p:---- s:0035 e:000034 CFUNC :require
c:0007 p:0170 s:0031 e:000030 METHOD /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69
c:0006 p:0027 s:0021 e:000020 TOP /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/bin/seeing_is_believing:5 [FINISH]
c:0005 p:---- s:0019 e:000018 CFUNC :load
c:0004 p:0135 s:0015 E:000ae0 EVAL /Users/crokobit/.rvm/gems/ruby-2.2.0/bin/seeing_is_believing:23 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC :eval
c:0002 p:0118 s:0005 E:002328 EVAL /Users/crokobit/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15 [FINISH]
c:0001 p:0000 s:0002 E:0006e0 TOP [FINISH]
-- Ruby level backtrace information ----------------------------------------
/Users/crokobit/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in <main>' /Users/crokobit/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in
eval'
/Users/crokobit/.rvm/gems/ruby-2.2.0/bin/seeing_is_believing:23:in <main>' /Users/crokobit/.rvm/gems/ruby-2.2.0/bin/seeing_is_believing:23:in
load'
/Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/bin/seeing_is_believing:5:in <top (required)>' /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in
require'
/usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in require' /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/binary.rb:1:in
<top (required)>'
/usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in require' /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in
require'
/Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing.rb:8:in <top (required)>' /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in
require'
/usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in require' /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/evaluate_by_moving_files.rb:14:in
<top (required)>'
/usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in require' /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in
require'
/Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json.rb:54:in <top (required)>' /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json.rb:58:in
module:JSON'
/usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in require' /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in
require'
/Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/ext.rb:9:in <top (required)>' /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/ext.rb:12:in
module:JSON'
/Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/ext.rb:13:in <module:Ext>' /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in
require'
/usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
-- Machine register context ------------------------------------------------
rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x0000000000000000
rdx: 0x0000000000000000 rdi: 0x0000000000000000 rsi: 0x0000000000000025
rbp: 0x00007fff5e9f75a0 rsp: 0x00007fff5e9f74f0 r8: 0x0000000000000000
r9: 0x00007fff7d8d9300 r10: 0x00000000000057b8 r11: 0x00007fff90bb9160
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000001
r15: 0x0000000000000025 rip: 0x00000001015fec8a rfl: 0x0000000000010206
-- C level backtrace information -------------------------------------------
0 libruby.2.2.0.dylib 0x0000000101354924 rb_print_backtrace + 29
1 libruby.2.2.0.dylib 0x0000000101354a1d rb_vm_bugreport + 142
2 libruby.2.2.0.dylib 0x000000010124011a rb_bug_context + 210
3 libruby.2.2.0.dylib 0x00000001012ebf60 check_reserved_signal_ + 0
4 libsystem_platform.dylib 0x00007fff93c87f1a _sigtramp + 26
5 libruby.2.2.0.dylib 0x00000001015fec8a newobj_of + 42
6 libdyld.dylib 0x00007fff7d8f2110 _ZL12sGlobalMutex + 24
-- Other runtime information -----------------------------------------------
Loaded script: /Users/crokobit/.rvm/gems/ruby-2.2.0/bin/seeing_is_believing
Loaded features:
0 enumerator.so
1 rational.so
2 complex.so
3 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/enc/encdb.bundle
4 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/enc/trans/transdb.bundle
5 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/unicode_normalize.rb
6 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/rbconfig.rb
7 thread.rb
8 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/thread.bundle
9 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/compatibility.rb
10 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/defaults.rb
11 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/deprecate.rb
12 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/errors.rb
13 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/version.rb
14 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/requirement.rb
15 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/platform.rb
16 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/basic_specification.rb
17 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/stub_specification.rb
18 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/util/stringio.rb
19 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/specification.rb
20 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/exceptions.rb
21 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/defaults/operating_system.rb
22 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb
23 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/monitor.rb
24 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
25 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems.rb
26 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/path_support.rb
27 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/dependency.rb
28 /Users/crokobit/.rvm/gems/ruby-2.2.0@global/gems/executable-hooks-1.3.2/lib/executable-hooks/hooks.rb
29 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/etc.bundle
30 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/fileutils.rb
31 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/pathname.bundle
32 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/pathname.rb
33 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/gem_path_manipulation.rb
34 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/gem_helpers.rb
35 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/match_platform.rb
36 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/rubygems_ext.rb
37 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/io/console.bundle
38 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/user_interaction.rb
39 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/config_file.rb
40 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/ext/build_error.rb
41 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/ext/builder.rb
42 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/ext/configure_builder.rb
43 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/delegate.rb
44 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/tmpdir.rb
45 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/tempfile.rb
46 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/ext/ext_conf_builder.rb
47 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/ext/rake_builder.rb
48 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/optparse.rb
49 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/command.rb
50 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/ext/cmake_builder.rb
51 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/rubygems/ext.rb
52 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/rubygems_integration.rb
53 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/version.rb
54 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/constants.rb
55 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler/current_ruby.rb
56 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/bundler-1.9.1/lib/bundler.rb
57 /Users/crokobit/.rvm/gems/ruby-2.2.0@global/gems/bundler-unload-1.0.2/lib/bundler-unload.rb
58 /Users/crokobit/.rvm/gems/ruby-2.2.0@global/gems/rubygems-bundler-1.4.4/lib/rubygems-bundler/noexec.rb
59 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/x86_64-darwin14/stringio.bundle
60 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/timeout.rb
61 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/has_exception.rb
62 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/line.rb
63 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/result.rb
64 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/version.rb
65 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/seeing_is_believing-2.2.0/lib/seeing_is_believing/debugger.rb
66 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/version.rb
67 /usr/local/Cellar/ruby/2.2.0/lib/ruby/2.2.0/ostruct.rb
68 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/generic_object.rb
69 /Users/crokobit/.rvm/gems/ruby-2.2.0/gems/json-1.8.2/lib/json/common.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Don't forget to include the above Crash Report log file.
For details: http://www.ruby-lang.org/bugreport.html
require 'factory_girl'
class Post
attr_accessor :title, :description
def save!
end
end
# main factory
FactoryGirl.define do
factory :post do
title "some title"
self
method(:factory).source_location
end
end
# use modify to add the trait
FactoryGirl.modify do
factory :post do
trait :with_desc do
description "some desc"
end
method(:factory).source_location
factory :described_post, traits: [:with_desc]
end
end
FactoryGirl.create :post, :with_desc
FactoryGirl.create :described_post
If user is using it on another implementation, there can be extra flags (e.g. -J-Xmx512m for some JVM flag JRuby), and existing might not match exactly (e.g. -U for unicode encoding in Rubinius, but -Ku in MRI).
When running 'annotate all lines' in textmate with a file I had been working on, This File. It froze textmate for a good 10 mins while it chewed on that problem. After realizing it wasn't going finish I killed it and began to investigate. I was able to narrow it down to the benchmarks, as commenting them out had it working fine.
It might be helpful to also note that it hangs when trying the process from the command line as well, so I don't think there is any direction connection to text mate.
This is the ruby process after running for a few minutes.
I'm not sure if this is of any importance, but this is what happens to my source file after I kill the process.
# Standard coin changer
begin;def changer(change)
$SiB.record_result(8, ($SiB.record_result(4, ([25,10,5,1])).flat_map do |coin|
$SiB.record_result(5, (remaining = (change / coin)))
$SiB.record_result(6, (change -= (remaining * coin)))
$SiB.record_result(7, ([coin] * remaining))
end))
end
$SiB.record_result(10, (changer(99)))
# Coin changer with reduced assignment operations
def ch(amt)
$SiB.record_result(19, ($SiB.record_result(14, ([25,10,5,1])).flat_map do |coin|
$SiB.record_result(18, ([coin] * ($SiB.record_result(15, (amt / coin)))
.tap { |rem|
$SiB.record_result(17, (amt -= rem * coin))
}))
end))
end
$SiB.record_result(21, (ch(99)))
# "Golfed" coin changer
def z(a)$SiB.record_result(24, ([25,10,5,1].flat_map{|c|[c]*(a/c).tap{|x|a-=x*c}}))end
$SiB.record_result(25, (z(99)))
# "No Assignment" coin changer
def chr(amt)
$SiB.record_result(35, ($SiB.record_result(31, ($SiB.record_result(30, ($SiB.record_result(29, ([25,10,5,1].map { |x| amt / x }))
.zip([25,10,5,1])))
.flat_map{|quot, coin| [coin] * quot }))
.inject([]) { |acc, n|
$SiB.record_result(33, (acc << n if acc.inject(n,:+) <= amt))
$SiB.record_result(34, (acc))
}))
end
$SiB.record_result(37, (chr(99)))
$SiB.record_result(74, (if $SiB.record_result(39, ($0 !~ /rspec/))
$SiB.record_result(40, (require 'benchmark'))
$SiB.record_result(41, (GC.disable))
$SiB.record_result(47, ($SiB.record_result(42, (Benchmark)).bm(10) do |x|
$SiB.record_result(43, (x.report('changer') { 1000.times { (0..100).each { |c| changer(c) }}}))
$SiB.record_result(44, (x.report('ch') { 1000.times { (0..100).each { |c| ch(c) }}}))
$SiB.record_result(45, (x.report('z') { 1000.times { (0..100).each { |c| z(c) }}}))
$SiB.record_result(46, (x.report('chr') { 1000.times { (0..100).each { |c| chr(c) }}}))
end))
else
$SiB.record_result(73, (describe "provides correct change" do
$SiB.record_result(72, ($SiB.record_result(57, ([
$SiB.record_result(51, ([100, [25,25,25,25]])),
$SiB.record_result(52, ([75, [25,25,25]])),
$SiB.record_result(53, ([50, [25,25]])),
$SiB.record_result(54, ([25, [25]])),
$SiB.record_result(55, ([65, [25, 25, 10, 5]])),
$SiB.record_result(56, ([37, [25,10,1,1]]))
])).each do |amount, change|
$SiB.record_result(71, (context "for #{amount}" do
$SiB.record_result(61, (it "changer: #{change}" do
$SiB.record_result(60, (changer(amount).should == change))
end))
$SiB.record_result(64, (it "chr: #{change}" do
$SiB.record_result(63, (chr(amount).should == change))
end))
$SiB.record_result(67, (it "ch: #{change}" do
$SiB.record_result(66, (ch(amount).should == change))
end))
$SiB.record_result(70, (it "z: #{change}" do
$SiB.record_result(69, (z(amount).should == change))
end))
end))
end))
end))
end));rescue Exception;line_number = $!.backtrace.grep(/#{__FILE__}/).first[/:\d+/][1..-1].to_i;$SiB.record_exception line_number, $!;$SiB.exitstatus = 1;$SiB.exitstatus = $!.status if $!.kind_of? SystemExit;end
They're close! Actually, Rubinius should work, it just doesn't pass all the tests. JRuby is broken, though, interface to IO.popen
seems different.
Love this trick in pry to check syntax: https://github.com/banister/method_source/blob/5e5c55642662c248e721282cc287b41a49778ee8/lib/method_source/code_helpers.rb#L58-72
Mine is pretty heavy-handed, and has a potential bug in it:
https://github.com/JoshCheek/seeing_is_believing/blob/bbca512b99f2720bf03b13d5e97987eb1ac7fd8e/lib/seeing_is_believing/binary.rb#L165-177
Looks like when you have an expression with an implicit begin/end wrapped around them, and the last expression is not on the last line, then it incorrectly identifies where the body is and wraps the wrong thing:
a
def b
c = 1
end
Wraps like this (rescue comes after the line in m, rather than the final end):
begin; $SiB.number_of_captures = Float::INFINITY; $SiB.record_result(1, (a))
def b
$SiB.record_result(3, (c = 1));rescue Exception;line_number = $!.backtrace.grep(/#{__FILE__}/).first[/:\d+/][1..-1].to_i;$SiB.record_exception line_number, $!;$SiB.exitstatus = 1;$SiB.exitstatus = $!.status if $!.kind_of? SystemExit;end
end
Expose a flag --safe that runs the code in http://eval.in using the eval_in gem
Building a gem and using this to check the output.
Requiring a file fails
require "./prayertimes/version" # ~> LoadError: cannot load such file -- ./prayertimes/version
or
require "prayertimes/version" # ~> LoadError: cannot load such file -- prayertimes/version
But this works:
require "/Users/mmahalwy/Desktop/Code/opensource/beautifulprayer-api/prayertimes/lib/prayertimes/version" # => true
This code blew up in SiB before this issue was resolved.
system "echo abc"
Example of the underlying problem:
File.open '/dev/null', 'w' do |black_hole|
STDERR = $stderr = black_hole
STDOUT = $stdout = black_hole
puts "You won't see this, it goes into the black hole"
system "echo but system gets around it!"
end
There is what I consider a bug (tested in MRI 2.1) where numerous methods such as Kernel#system
and Kernel#spawn
print directly to the original stdout and stderr file descriptor.
This is because they invoke C's system
function from stlib.h
, which apparently talks directly to existing "real" output streams even if you override $stdout
and STDOUT
(same for err)
Following the code:
What this means is that you can't capture the output from commands like Kernel.system("echo a")
but it's worse than that, Seeing Is Believing dumps its Result
data structure on stdout which is then parsed on the other side. If system commands dump their stdout there, then that fucks up the data, and it will raise a parsing error.
Initially I began overriding Kernel#system and the others. So I went to RubySpec to make sure my override did all the same stuff as the original. Which led me to wonder how they got around this issue in their tests, which led to their test framework mspec, which used a solution far smarter than any I was considering, it reopened the stream to capture it.
So, I used RubySpec's solution, but modified it slightly to use IO.pipe
so that I don't have to deal with temp files.
You will need to be aware of this and think about how it affects your use case and how to deal with it.
WrapExpressions should know how many lines there are, use that to identify this info rather than body.lines.count in main SiB script.
Also, might be worth including this info in the Result object.
first off, this project is super, super cool. I'm now evaluating it to see if it would be a viable replacement for xmpfilter in RubyTapas.
One feature that I use a lot in xmpfilter is the difference between annotating the end of a line and annotating on the next line. In xmpfilter, if you annotate the following line, it switches to using pp
indented output instead of inspect
output. This is handy for showing the contents of large or nested data structures.
Here's an example using xmpfilter
:
h = {
foo: 42,
bar: {
baz: 1,
buz: 2,
fuz: 3,
},
wibble: {
magic_word: "xyzzy",
}
}
h # => {:foo=>42, :bar=>{:baz=>1, :buz=>2, :fuz=>3}, :wibble=>{:magic_word=>"xyzzy"}}
h
# => {:foo=>42,
# :bar=>{:baz=>1, :buz=>2, :fuz=>3},
# :wibble=>{:magic_word=>"xyzzy"}}
Is this a possibility in SIB?
This code adds the error into the string "INSERT INTO students (name, email, grade, blog)"
require "sqlite3"
# Open a database
db = SQLite3::Database.new ":memory:"
# Create a database
rows = db.execute <<-SQL
create table numbers (
name varchar(30),
val int
);
SQL
# Execute a few inserts
{ "one" => 1,
"two" => 2,
}.each do |pair|
db.execute "insert into numbers values ( ?, ? )", pair
end
# Execute inserts with parameter markers
db.execute("INSERT INTO students (name, email, grade, blog)
VALUES (?, ?, ?, ?)", [@name, @email, @grade, @blog])
# Find a few rows
db.execute( "select * from numbers" ) do |row|
row
# =>
end
Example:
$ seeing_is_believing -e 'at_exit { raise "omg" }'
This happens in the real world, for example, Atom sets its CWD to the root dir. If user is running some piece of code with an at_exit
hook that raises an exception (e.g. they run it on a test and SimpleCov tries to write the results to "./coverage", but cwd is "/", making this "/coverage", which it can't access, and thus Errno::EACCES
is raised from the at_exit
hook.
In Atom, this leads to an error screen about bug reporting:
Correct behaviour is to print the error at the end, like we would print any other error.
Perhaps we can identify errors raised from within SiB vs outside it by looking at the backtrace?
Thanks to @katelane for reporting.
Find where this is (prob RubySpec and Parser both hit it pretty thoroughly), make sure SiB correctly wraps it.
When using fork, the child does not update its results. I'm not sure if exec matters, originally I thought it did since it triggers finalization, but more experimenting leads to the conclusion that the child doesn't affect the parent (either one execing is probably totally irrelevant to the other).
Cukes to test this behaviour are here.
Some experiments show the likely cause is that the thread in the producer dies when it forks.
# It looks like the reason forked SiB code stops recording is that it kills the thread in the fork
q = Queue.new # => #<Thread::Queue:0x007fe5408fbdf8>
t = Thread.new { # => Thread
while value = q.shift # => :parent, :break
break if value == :break # => false, true
puts "Dequeued #{value.inspect} for (#$$)" # => nil
end # => nil
puts "Thread finished for (#$$)" # => nil
} # => #<Thread:0x007fe5408fb9e8 run>
if fork # => 67750
q << :parent # => #<Thread::Queue:0x007fe5408fbdf8>
puts "Parent (#$$) thread: #{t.inspect}" # => nil
else
q << :child
puts "Child (#$$) thread: #{t.inspect}"
end # => nil
sleep 1 # => 1
q << :break # => #<Thread::Queue:0x007fe5408fbdf8>
t.join # => #<Thread:0x007fe5408fb9e8 dead>
puts "PROCESS (#$$) FINISHED" # => nil
# >> Parent (67749) thread: #<Thread:0x007fe5408fb9e8 run>
# >> Dequeued :parent for (67749)
# >> Child (67750) thread: #<Thread:0x007fe5408fb9e8 dead>
# >> PROCESS (67750) FINISHED
# >> Thread finished for (67749)
# >> PROCESS (67749) FINISHED
event_stream_fd = Marshal.load(ENV["SIB_VARIABLES.MARSHAL.B64"].unpack('m0').first)[:event_stream_fd] # => 12
stream = nil # => nil
ObjectSpace.each_object(IO) { |io| stream = io if !io.closed? && io.to_i == event_stream_fd } # => 28
# This shows that the FD is still open in the child, it is the thread inside the producer that died
'child will set a result here:' # => "child will set a result here:", Result from child
target_line = __LINE__ - 1 # => 5
if fork # => 68326
# parent is noop
else
line_number = target_line
type = :inspect
inspected = "Result from child"
tokenized = [Marshal.dump(inspected.to_s)].pack('m0')
stream << "result #{line_number} #{type} #{tokenized}\n"
end # => nil
e.g.
local_variables # => [:line_number]
IIRC, this comes from the ensure block wrapped around the program. Probably if we wrap it in a lambda and then call it, we can get it out of this scope.
It's a bug in these versions of Ruby.
Example here
Reported here.
Fixed here.
You have to upgrade to a newer version of Ruby (right now that means compile source yourself). It's a bug hit by the suite, not the lib, so shouldn't matter to end-users. This is how I built mine:
Didn't have a ./configure, so I Had to install autoconf
$ brew install autoconf
Then generate the ./configure
$ autoconf
Then run configure to get a Makefile. This prefix is for chruby, you'll do something different if your rubies get installed elsewhere.
$ ./configure --prefix="$HOME/.rubies/ruby-2.2.0.bleeding" --with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline
Then make to compile it
$ make
Then make install to put the compiled files where they belong
$ make install
Now you can use it (you may have to launch a new shell). I may have also had to make the "$HOME/.rubies/ruby-2.2.0" dir myself, not sure b/c I got confused and did that when the problem was something else.
To debug #49, I turned the debugger on, but it's being invoked by Atom, so I set it to print its output to a file instead of stdout. Then I ran it, watched it blow up, and looked at the file to see what the error was. This was really helpful in terms of figuring out the issue, how about exposing it as part of the interface in 3.0?
class Library
SYSTEMS = ['arcade', 'atari', 'pc']
attr_accessor :games
def method_missing(name, *args)
system = name.to_s
if SYSTEMS.include?(system)
define_method system do
find_by_system(sytem)
end
send(system)
end
end
private
def find_by_system(system)
games.select { |game| game.system == system }
end
end
Library.new.atari # =>
SeeingIsBelieving::VERSION "2.1.4"
Parser::VERSION "2.1.9"
RUBY_VERSION "2.1.5"
ENV['RUBY_VERSION'] "2.1.5"
it appears to not blow up if I remove send(system)
When I try to annotate schema.rb file generated by rails it gives me this error
# ~> NameError: uninitialized constant ActiveRecord
I have no idea if it has to do with rails or not. I get an uninitialised constant error on controllers as well.
I use Atom. my SiB version I got installed is 2.2.0
Ruby will stop reading a file with a large data segment, causing it to blow up because it closed the pipe. Explanation of the situation at https://bugs.ruby-lang.org/issues/9583#note-1
SiB should probably just rescue a broken pipe and call it good Syntax (can't think of any other reason this would happen).
Could the matrix eval it and set the __FILE__
option so that we don't have to move the file out of the way?
When I evaluate, everything disappears
When I do 'Remove Annotations' it returns error:
ruby: No such file or directory -- seeing_is_believing (LoadError)
Using Sublime Text 3 - should note that 'Preferences > Package Settings' does not show SeeingIsBelieving although in my package command palate it's there.
My settings:
{
// the command to run your ruby, again this is setup for rbenv
// if you've installed Ruby without any managers, this would just be "ruby"
"ruby_command": "/Users/mmahalwy/.rvm/bin/sublime_ruby",
// environment variables to set before running
"environment_variables": {
// for bootstrapping rbenv
// if you manage your versions differently, you'll have to figure out how your manager works
// "RBENV_VERSION": "2.0.0-p0"
},
// get a list of all these options and what they do by going to the console
// and typing `seeing_is_believing --help`
"flags": {
// max length of the entire line (only truncates results, not source lines)
"--line-length": 500,
// select the alignment strategy:
// file (DEFAULT) => the entire file is at the same alignment
// chunk => each chunk of code is at the same alignment
// line => each line is at its own alignment
"--alignment-strategy": "chunk",
// timeout limit in seconds when evaluating source file (ex. -t 0.3 or -t 3)
// omit for no timeout (warning, can freeze your editor up if you have an infinite loop)
"--timeout": 12,
// sets file encoding, equivalent to Ruby's -Kx (see `man ruby` for valid values)
"--encoding": "u"
}
}
-Ku
is deprecated on MRI and everywhere else.
I think Rbx uses -U
and -E
, I think MRI uses -E something or other
Probably this is all working incidentally due to UTF being turned on by default or something. IDK, look into it at some point.
Program: "begin;($seeing_is_believing_current_result.record_result(3, (def m\n($seeing_is_believing_current_result.record_result(2, (m)))\nend)))\n(
Stdout: "--- !ruby/object:SeeingIsBelieving::Result\nmax_line_number: 3\nstdout: ''\nstderr: ''\nresults:\n 3: !ruby/object:SeeingIsBelieving::Line\n array:\n - nil\nmin_line_number: 1\n"
Stderr: ""
Status: #<Process::Status: pid 52968 exit 1>
/Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/evaluate_by_moving_files.rb:129:in fail': Exitstatus: #<Process::Status: pid 52968 exit 1>, (RuntimeError) Error: "" from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/evaluate_by_moving_files.rb:46:in
block in call'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/hard_core_ensure.rb:31:in call' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/hard_core_ensure.rb:31:in
invoke_code'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/hard_core_ensure.rb:14:in call' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/hard_core_ensure.rb:4:in
call'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/evaluate_by_moving_files.rb:39:in call' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing.rb:117:in
block in result_for'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/1.9.1/tmpdir.rb:83:in mktmpdir' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing.rb:115:in
result_for'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing.rb:74:in call' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing.rb:17:in
call'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/binary.rb:53:in results' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/binary.rb:39:in
program_timedout?'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/lib/seeing_is_believing/binary.rb:25:in call' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/seeing_is_believing-0.0.17/bin/seeing_is_believing:6:in
<top (required)>'
from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/bin/seeing_is_believing:23:in load' from /Users/joshcheek/.rbenv/versions/1.9.3-p327-perf/bin/seeing_is_believing:23:in
class Array
undef :map
end
['o', 'm', 'g']
.class # =>
.instance_methods(false).include? :map # =>
It blew up because SeeingIsBelieving isn't good enough >.<
Please log an issue at: https://github.com/JoshCheek/seeing_is_believing/issues
Program: "begin;($seeing_is_believing_current_result.record_result(9, (def destroy_message(string)\n($seeing_is_believing_current_result.record_result(2, ( matched_string = string.match(/:/))))\n($seeing_is_believing_current_result.record_result(7, ( if matched_string \n($seeing_is_believing_current_result.record_result(4, ( "#{matched_string.pre_match}#{matched_string}")))\n else\n return "this has no message"\n end)))\n #string[/\A[^:]:/]\nend)))\n\n($seeing_is_believing_current_result.record_result(14, (def destroy_message!(string)\n # matched_string = string.match(/:/)\n($seeing_is_believing_current_result.record_result(13, ( string.sub!(/(?<=:)./,''))))\nend)))\n\n# Driver code... \n($seeing_is_believing_current_result.record_result(17, (string = "this message will self-destruct: you can't hug every cat")))\n($seeing_is_believing_current_result.record_result(18, (original_string = string.dup)))\n($seeing_is_believing_current_result.record_result(19, (puts destroy_message(string) == "this message will self-destruct:")))\nputs string == original_string # we shouldn't modify the string passed to destroy_message\n\n($seeing_is_believing_current_result.record_result(22, (string = "this has no message")))\n($seeing_is_believing_current_result.record_result(23, (original_string = string.dup)))\n($seeing_is_believing_current_result.record_result(24, (puts destroy_message(string) == string)))\nputs string == original_string # we shouldn't modify the string passed to destroy_message\n\n($seeing_is_believing_current_result.record_result(27, (string = "this message will self-destruct: you can't hug every cat")))\n($seeing_is_believing_current_result.record_result(28, (original_string = string.dup)))\n($seeing_is_believing_current_result.record_result(29, (puts destroy_message!(string) == "this message will self-destruct:")))\n($seeing_is_believing_current_result.record_result(30, (puts string == "this message will self-destruct:")))\n($seeing_is_believing_current_result.record_result(31, (puts string != original_string)))\n\n($seeing_is_believing_current_result.record_result(33, (string = "this has no message")))\n($seeing_is_believing_current_result.record_result(34, (result = destroy_message!(string))))\n($seeing_is_believing_current_result.record_result(35, (puts result.nil?)))\n(
Code that generated this:
def destroy_message(string)
matched_string = string.match(/:/) # => #<MatchData ":">, nil
if matched_string
"#{matched_string.pre_match}#{matched_string}" # => "this message will self-destruct:"
else
return "this has no message" # => nil
end # => "this message will self-destruct:", nil
#string[/\A[^:]*:/]
end # => nil
def destroy_message!(string)
# matched_string = string.match(/:/)
string.sub!(/(?<=:).*/,'') # => "this message will self-destruct:", nil
end # => nil
# Driver code...
string = "this message will self-destruct: you can't hug every cat" # => "this message will self-destruct: you can't hug every cat"
original_string = string.dup # => "this message will self-destruct: you can't hug every cat"
puts destroy_message(string) == "this message will self-destruct:" # => nil
puts string == original_string # we shouldn't modify the string passed to destroy_message
string = "this has no message" # => "this has no message"
original_string = string.dup # => "this has no message"
puts destroy_message(string) == string # => nil
puts string == original_string # we shouldn't modify the string passed to destroy_message
string = "this message will self-destruct: you can't hug every cat" # => "this message will self-destruct: you can't hug every cat"
original_string = string.dup # => "this message will self-destruct: you can't hug every cat"
puts destroy_message!(string) == "this message will self-destruct:" # => nil
puts string == "this message will self-destruct:" # => nil
puts string != original_string # => nil
string = "this has no message" # => "this has no message"
result = destroy_message!(string) # => nil
puts result.nil? # => nil
puts string == string # => nil
# >> true
# >> true
# >> This has no message
# >> false
# >> true
# >> true
# >> true
# >> true
# >> true
# >> true
RbConfig.ruby # => "/Users/josh/.rubies/ruby-2.1.1/bin/ruby"
Given this, we can default --shebang
to RbConfig.ruby
Which then implies that we can set all editor configuration to just ruby
and rely on their existing env vars. (will still have to explain how to make the ruby_executable, if this doesn't work for them)
(1)
https://github.com/whitequark/parser/blob/master/CHANGELOG.md
Please update gem dependencies.
I've checked the gem, its installed.
I get this error in atom:
Window load time: 588ms
/Users/UsmaanJ/.atom/packages/seeing-is-believing/lib/seeing-is-believing.coffee:49 Seeing is Believing:
/Users/UsmaanJ/.atom/packages/seeing-is-believing/lib/seeing-is-believing.coffee:50 command: ruby -S seeing_is_believing --alignment-strategy chunk --number-of-captures 300 --line-length 1000 --timeout 12 --xmpfilter-style
/Users/UsmaanJ/.atom/packages/seeing-is-believing/lib/seeing-is-believing.coffee:51 env: Object {TMPDIR: "/var/folders/x3/bfjwp8013435b5l4nvwj3gq00000gn/T/", __CF_USER_TEXT_ENCODING: "0x1F5:0x0:0x0", SHELL: "/bin/bash", HOME: "/Users/UsmaanJ", Apple_PubSub_Socket_Render: "/private/tmp/com.apple.launchd.F63QWrjIGc/Render"…}
/Users/UsmaanJ/.atom/packages/seeing-is-believing/lib/seeing-is-believing.coffee:63 Seeing is Believing stderr:ruby: No such file or directory -- seeing_is_believing (LoadError)
/Users/UsmaanJ/.atom/packages/seeing-is-believing/lib/seeing-is-believing.coffee:68 Seeing is Believing closed with code 1
I've tried deleting and re-installing but still isn't working.
<<-"ab#{<<x}"
xyz
ab#{<<x}
Haven't explored it, maybe it thinks the last line is a comment?
This will allow it to work across MRI and Rbx.
Probably some features are failing right now as a consequence.
Just tried this in emacs in a rails app and it blows up. Not sure if it's supposed to work inside of a rails app or not, just thought it would be useful.
I'm just doing User.first # =>
and then I call the seeing-is-believing function
Output:
It blew up >.< Please log an issue at: https://github.com/JoshCheek/seeing_is_believing/issues
SeeingIsBelieving::VERSION "2.0.2"
Parser::VERSION "2.0.0.pre6"
RUBY_VERSION "2.0.0"
ENV['RUBY_VERSION'] nil
Also include the source code of program that caused this behaviour.
Syntax error in binary.rb. This is easy enough to fix with a few parens.
ruby -c lib/seeing_is_believing/binary.rb
lib/seeing_is_believing/binary.rb:189: syntax error, unexpected modifier_if
exception: if results.has_exception?
^
lib/seeing_is_believing/binary.rb:195: syntax error, unexpected ',', expecting keyword_end
lib/seeing_is_believing/binary.rb:198: syntax error, unexpected modifier_if
... exception: if result.has_exception?
... ^
lib/seeing_is_believing/binary.rb:203: syntax error, unexpected keyword_end, expecting '}'
lib/seeing_is_believing/binary.rb:219: syntax error, unexpected keyword_end, expecting '}'
Parser doesn't yet (as of version 2.1.9) support Ruby 2.2.x
def self.inspect
self
end
self
This is because inspect is invoked from within SiB code and backtrace does not go into user code, so it appears to the rescue statement that our code blew up here.
It contains all the info we parse out of the lines of the backtrace. But I need to go back and see how long that has been a thing (ie needs to work on 1.9.3)
(raise 'omg' rescue $!).backtrace_locations.first.tap { |btl|
btl.lineno # => 1
btl.label # => "<main>"
btl.base_label # => "<main>"
btl.path # => "/var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20150330-70943-rcok8r/program.rb"
btl.absolute_path # => "/private/var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/seeing_is_believing_temp_dir20150330-70943-rcok8r/program.rb"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.