Giter Site home page Giter Site logo

seeing_is_believing's People

Contributors

andylampert avatar bjmllr avatar brandoncc avatar bwvoss avatar ckib16 avatar coreyhaines avatar dougbradbury avatar hwartig avatar janko avatar jaywengrow avatar jeanlange avatar joshcheek avatar kotp avatar kunalbhatt avatar marlomajor avatar mrcasals avatar olleolleolle avatar pd avatar pszals avatar rewinfrey avatar waffle-iron avatar zenspider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seeing_is_believing's Issues

Support pp for large/complex structures

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?

Interpolating error into string when run w/ xmpfilter

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

Use RbConfig.ruby

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)

Get it working for JRuby and Rubinius

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.

Allow arbitrary flags to be passed to the bin

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).

seeing is believing isn't working. keeps saying not installed, but it is?

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.

Doesn't run on Ruby 2.2.x

Issue1 (fixed)

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 '}'

Issue2

Parser doesn't yet (as of version 2.1.9) support Ruby 2.2.x

You can't handle the stack overflow!

Program: "begin;($seeing_is_believing_current_result.record_result(3, (def m\n($seeing_is_believing_current_result.record_result(2, (m)))\nend)))\n($seeing_is_believing_current_result.record_result(4, (m)))\n\nrescue Exception;line_number = $!.backtrace.grep(/#{FILE}/).first[/:\d+:/][1..-2].to_i;$seeing_is_believing_current_result.record_exception line_number, $!;end"

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:inblock 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:ininvoke_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:incall'
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:inblock 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:inresult_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:incall'
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:inprogram_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

'

v3.0

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

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.

Features

  • Library
  • Binary
    • Upgrade to latest Parser
    • Ability to get an event stream, so that someone could get the events as they occur rather than at the end. Probably emit events each on one-line and in JSON format. Maybe try implementing it in atom-seeing-is-believing. 6893b81
    • Display xmpfilter previous-line annotations with pretty-print (for #44)
    • Deprecate --shebang since RbConfig.ruby gives the information we needed this for.

Cleanup

  • Generally, tons of stuff happened here. A lot more than is listed.
  • Renamings in EventStream + split it out into multiple files
  • Rename CleanBody -> RemoveAnnotations
  • Refactor that POS AddAnnotations. Probably there are two objects in there, one for sib style, one for xmpfilter style, also, it is annoying that we get the result from AddAnnotations, it conceptually should take a file and a set of results, and add them on each line.
  • Make sure I actually like the Result class (I don't particularly, but it solves a relevant issue).
  • Probably get rid of the line class (the exception is already on Result, other than that it's just an array) completed
  • Parser fixed the heredoc bugs, so doesn't need the stupid hacks I wrote. Probably they are littered all over ParserHelpers and WrapExpressions
  • Figure out this encoding bullshit (#33)
  • Switch syntax checking to use Pry's trick (#38)
  • Get rid of --start-line and --end-line and instead have maybe --show-lines, a comma-separated array of lines to display output on (e.g. I can't think of a start/end line use-case, but it makes sense to want to see the current line, but then show for multiple cursors or where a user has marked in their editor)

Other

  • Order frog stickers #14

Descoped

  • Add a changelog (I added one, but didn't keep it up)
  • Get it working on JRuby and Rbx (already put a lot of work into this, but a bug in current version of JRuby, and inability to install Rbx due to not having llvm are preventing me from getting it at the moment -- actually, I might try again, this worked for me)
  • Use custom evaluators to support safe mode (integration with eval_in) (I no longer intend to do this 17db7e9)
  • Expose ability to provide custom evaluators. (I only need one now. If anyone else needs one, they can ask me to do this. It shouldn't be hard, but don't see the need for the indirection at present.
  • auto-record rescued exceptions (seemed like a lot of work without an obvious benefit)
  • Track, for each line, what kind of obj it's recording (e.g. method def/literal/etc) and provide an interface for the user to specify what they would like to see. (going to have to wait until the next version, it's just going to take a lot of effort)
  • A hybrid chunk/file line aligner that tries to line everything up for the whole file, but will discard outliers that are fucking it up. (might still do this one)
  • Would be nice to find a way to deal with Atom identifying the file change too quickly. (yeah, idk what it would be)
  • Would be nice to bundle a ruby executable with the editor integrations so newbies can just install with the editor's package manager instead of having to configure everything. (Traveling Ruby was what I was thinking, but it doesn't support Windows)

bug: wraps LHS of assignment

{}[:a] ||= {
}

Winds up wrapping like this

<{}[:a]> ||= {
}

But it should wrap like this

<{}[:a] ||= {
}>

Or maybe like this, IDK.

{}[:a] ||= <{
}>

ALSO Check &&= and others

Failures with parser-2.3.0.6

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>'

Fork/exec not recording in child

Issue

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.

Threads seem to die when forking

# 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

File Descriptor is still open for child, results would be recorded if they were being reported

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

line_number local var visible in program

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.

Timeout does not work in some cases (hangs indefinitely)

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

Add ability to set a debugger that logs to a file.

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?

Trying to annotate in rails project results in error

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

Wraps whole body incorrectly on multi-line bodies with expressions not at the end

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

Get off YAML *sigh*

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>'

Does not emit warnings

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

Use backtrace location

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"
}

emacs rails

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.

it blew up

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)

Test suite hangs on Ruby 2.1.1 and 2.1.2

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.

Your shit blows up!

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($seeing_is_believing_current_result.record_result(36, (puts string == string)))\n\nrescue Exception;line_number = $!.backtrace.grep(/#{FILE}/).first[/:\d+/][1..-1].to_i;$seeing_is_believing_current_result.record_exception line_number, $!;end"


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

Hangs when running files containing large benchmarks and memory usages.

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.
Running SiB in two locations

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

system prints directly to stdout

Examples

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

The Problem in MRI

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:

The Implication for SiB

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.

Considering Solutions

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.

Actual Solution

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.

If You Are Swapping Out The Matrix File

You will need to be aware of this and think about how it affects your use case and how to deal with it.

JSON.parse/encoding error

Versions:

SeeingIsBelieving::VERSION  "2.1.4"
Parser::VERSION             "2.2.0.pre.4"
RUBY_VERSION                "2.1.1"
ENV['RUBY_VERSION']         "2.1.1"

Input program

require 'json'  # => false

initial = "”"  # => "”"

result =
  JSON.dump(  # => JSON
    initial   # => "”"
  )           # => "\"”\""

JSON.parse result

Wrapped program

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

Stdout from execution

Is empty.

Stderr from execution

/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)>'

Exit status

1

Exceptions in `at_exit` hooks look like they came from SiB

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:

sib-blows-up-ss

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.

Requiring a file outputs error

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

ruby: No such file or directory -- seeing_is_believing (LoadError)

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"
  }
}


Kaboom

screen shot 2013-08-09 at 12 56 27 am

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($seeing_is_believing_current_result.record_result(7, (describe CreditCard do\n\nend)))\n\nrescue Exception;line_number = $!.backtrace.grep(/#{FILE}/).first[/:\d+/][1..-1].to_i;$seeing_is_believing_current_result.record_exception line_number, $!;end"

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

'\x06;\vF:\tname:\rdescribe:\targs[\x06c\x0FCreditCard;\f@\f:\f@stdoutI"\0\x06;\vT:\f@stderrI"\0\x06;\vT"

Stderr: ""

Status: #<Process::Status: pid 65385 exit 0>
ArgumentError
undefined class/module CreditCard

Blows up on 2.0.4

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

error when using seeing_is_believing in vim

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:ineval'
/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:inload'
/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:inrequire'
/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:inrequire'
/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:inrequire'
/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:inrequire'
/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:inmodule: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:inrequire'
/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:inmodule: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:inrequire'
/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

Encoding variable is wrong

-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.

Blows up when inspect recurses infinitely

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.

Clobbering issue

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.