Hello community, here is the log from the commit of package rubygem-bindex for openSUSE:Factory checked in at 2019-07-16 08:41:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-bindex (Old) and /work/SRC/openSUSE:Factory/.rubygem-bindex.new.1887 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-bindex" Tue Jul 16 08:41:38 2019 rev:3 rq:715394 version:0.8.1 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-bindex/rubygem-bindex.changes 2019-06-19 20:59:18.974030311 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-bindex.new.1887/rubygem-bindex.changes 2019-07-16 08:41:39.379031695 +0200 @@ -1,0 +2,7 @@ +Mon Jul 15 07:19:03 UTC 2019 - Manuel Schnitzer <[email protected]> + +- updated to version 0.8.1 + + no changelog found + +------------------------------------------------------------------- Old: ---- bindex-0.7.0.gem New: ---- bindex-0.8.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-bindex.spec ++++++ --- /var/tmp/diff_new_pack.ivGODW/_old 2019-07-16 08:41:40.031031345 +0200 +++ /var/tmp/diff_new_pack.ivGODW/_new 2019-07-16 08:41:40.035031342 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-bindex -Version: 0.7.0 +Version: 0.8.1 Release: 0 %define mod_name bindex %define mod_full_name %{mod_name}-%{version} ++++++ bindex-0.7.0.gem -> bindex-0.8.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2019-04-08 22:09:35.000000000 +0200 +++ new/.travis.yml 2019-07-10 15:26:26.000000000 +0200 @@ -1,13 +1,10 @@ language: ruby rvm: - - ruby-2.3.3 - - ruby-2.4.0 + - ruby-2.5 + - ruby-2.6 - ruby-head - - jruby-9.1.8.0 - - jruby-head - allow_failures: - rvm: ruby-head - rvm: jruby-head @@ -18,6 +15,4 @@ before_install: gem install bundler -sudo: false - cache: bundler diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2019-04-08 22:09:35.000000000 +0200 +++ new/README.md 2019-07-10 15:26:26.000000000 +0200 @@ -1,4 +1,4 @@ -# Skiptrace [](https://travis-ci.org/gsamokovarov/bindex) +# Skiptrace [](https://travis-ci.org/gsamokovarov/skiptrace) When Ruby raises an exception, it leaves you a backtrace to help you figure out where did the exception originated in. Skiptrace gives you the bindings as well. @@ -18,6 +18,11 @@ Returns all the bindings up to the one in which the exception originated in. +#### Exception#binding_locations + +Returns an array of `Skiptrace::Location` objects that are like [`Thread::Backtrace::Location`](https://ruby-doc.org/core-2.6.3/Thread/Backtrace/Location.html) +but also carry a `Binding` object for that frame through the `#binding` method. + #### Skiptrace.current_bindings Returns all of the current Ruby execution state bindings. The first one is the @@ -28,7 +33,7 @@ ### CRuby -CRuby 2.0.0 and above is supported. +CRuby 2.5.0 and above is supported. ### JRuby diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2019-04-08 22:09:35.000000000 +0200 +++ new/Rakefile 2019-07-10 15:26:26.000000000 +0200 @@ -7,7 +7,7 @@ Rake::TestTask.new do |t| t.libs << 'test' - t.test_files = FileList['test/*_test.rb'] + t.test_files = FileList['test/**/*_test.rb'] t.verbose = true end @@ -17,7 +17,7 @@ Rake::ExtensionTask.new('skiptrace') do |ext| ext.name = 'cruby' - ext.lib_dir = 'lib/skiptrace' + ext.lib_dir = 'lib/skiptrace/internal' end task default: [:clean, :compile, :test] @@ -26,7 +26,7 @@ Rake::JavaExtensionTask.new('skiptrace') do |ext| ext.name = 'jruby_internals' - ext.lib_dir = 'lib/skiptrace' + ext.lib_dir = 'lib/skiptrace/internal' ext.source_version = '1.8' ext.target_version = '1.8' end Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/skiptrace/extconf.rb new/ext/skiptrace/extconf.rb --- old/ext/skiptrace/extconf.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/ext/skiptrace/extconf.rb 2019-07-10 15:26:26.000000000 +0200 @@ -5,7 +5,7 @@ $CFLAGS << " -Wall" $CFLAGS << " -g3 -O0" if ENV["DEBUG"] - create_makefile("skiptrace/cruby") + create_makefile("skiptrace/internal/cruby") else IO.write(File.expand_path("../Makefile", __FILE__), <<-END) all install static install-so install-rb: Makefile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/binding_ext.rb new/lib/skiptrace/binding_ext.rb --- old/lib/skiptrace/binding_ext.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/skiptrace/binding_ext.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,5 @@ +class Binding + def source_location + eval '[__FILE__, __LINE__.to_i]' + end unless method_defined?(:source_location) +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/binding_locations.rb new/lib/skiptrace/binding_locations.rb --- old/lib/skiptrace/binding_locations.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/skiptrace/binding_locations.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,34 @@ +module Skiptrace + class BindingLocations < BasicObject + def initialize(locations, bindings) + @locations = locations + @bindings = bindings + @cached_locations = {} + end + + private + + def cached_location(location) + @cached_locations[location.to_s] ||= Location.new(location, guess_binding_around(location)) + end + + def guess_binding_around(location) + location && @bindings.find do |binding| + binding.source_location == [location.path, location.lineno] + end + end + + def method_missing(name, *args, &block) + case maybe_location = @locations.public_send(name, *args, &block) + when ::Thread::Backtrace::Location + cached_location(maybe_location) + else + maybe_location + end + end + + def respond_to_missing?(name, include_all = false) + @locations.respond_to?(name, include_all) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/exception_ext.rb new/lib/skiptrace/exception_ext.rb --- old/lib/skiptrace/exception_ext.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/skiptrace/exception_ext.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,5 @@ +class Exception + def binding_locations + @binding_locations ||= Skiptrace::BindingLocations.new(backtrace_locations, bindings) + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/internal/jruby.rb new/lib/skiptrace/internal/jruby.rb --- old/lib/skiptrace/internal/jruby.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/skiptrace/internal/jruby.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,7 @@ +require 'skiptrace/internal/jruby_internals' + +module Skiptrace + java_import com.gsamokovarov.skiptrace.JRubyIntegration + + JRubyIntegration.setup(JRuby.runtime) +end Binary files old/lib/skiptrace/internal/jruby_internals.jar and new/lib/skiptrace/internal/jruby_internals.jar differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/internal/rubinius.rb new/lib/skiptrace/internal/rubinius.rb --- old/lib/skiptrace/internal/rubinius.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/skiptrace/internal/rubinius.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,66 @@ +module Skiptrace + module Rubinius + # Filters internal Rubinius locations. + # + # There are a couple of reasons why we wanna filter out the locations. + # + # * ::Kernel.raise, is implemented in Ruby for Rubinius. We don't wanna + # have the frame for it to align with the CRuby and JRuby implementations. + # + # * For internal methods location variables can be nil. We can't create a + # bindings for them. + # + # * Bindings from the current file are considered internal and ignored. + # + # We do that all that so we can align the bindings with the backtraces + # entries. + class InternalLocationFilter + def initialize(locations) + @locations = locations + end + + def filter + @locations.reject do |location| + location.file.start_with?('kernel/delta/kernel.rb') || + location.file == __FILE__ || + location.variables.nil? + end + end + end + end +end + +# Gets the current bindings for all available Ruby frames. +# +# Filters the internal Rubinius and Skiptrace frames. +def Skiptrace.current_bindings + locations = ::Rubinius::VM.backtrace(1, true) + + Skiptrace::Rubinius::InternalLocationFilter.new(locations).filter.map do |location| + Binding.setup( + location.variables, + location.variables.method, + location.constant_scope, + location.variables.self, + location + ) + end +end + +::Exception.class_eval do + def bindings + @bindings || [] + end +end + +::Rubinius.singleton_class.class_eval do + raise_exception = instance_method(:raise_exception) + + define_method(:raise_exception) do |exc| + if exc.bindings.empty? + exc.instance_variable_set(:@bindings, Skiptrace.current_bindings) + end + + raise_exception.bind(self).call(exc) + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/jruby.rb new/lib/skiptrace/jruby.rb --- old/lib/skiptrace/jruby.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/lib/skiptrace/jruby.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +0,0 @@ -require 'skiptrace/jruby_internals' - -java_import com.gsamokovarov.skiptrace.JRubyIntegration - -JRubyIntegration.setup(JRuby.runtime) Binary files old/lib/skiptrace/jruby_internals.jar and new/lib/skiptrace/jruby_internals.jar differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/location.rb new/lib/skiptrace/location.rb --- old/lib/skiptrace/location.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/skiptrace/location.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,34 @@ +module Skiptrace + class Location + attr_reader :binding + + def initialize(location, binding) + @location = location + @binding = binding + end + + def absolute_path + @location.absolute_path + end + + def base_label + @location.base_label + end + + def inspect + @location.inspect + end + + def label + @location.label + end + + def lineno + @location.lineno + end + + def to_s + @location.to_s + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/rubinius.rb new/lib/skiptrace/rubinius.rb --- old/lib/skiptrace/rubinius.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/lib/skiptrace/rubinius.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,66 +0,0 @@ -module Skiptrace - module Rubinius - # Filters internal Rubinius locations. - # - # There are a couple of reasons why we wanna filter out the locations. - # - # * ::Kernel.raise, is implemented in Ruby for Rubinius. We don't wanna - # have the frame for it to align with the CRuby and JRuby implementations. - # - # * For internal methods location variables can be nil. We can't create a - # bindings for them. - # - # * Bindings from the current file are considered internal and ignored. - # - # We do that all that so we can align the bindings with the backtraces - # entries. - class InternalLocationFilter - def initialize(locations) - @locations = locations - end - - def filter - @locations.reject do |location| - location.file.start_with?('kernel/delta/kernel.rb') || - location.file == __FILE__ || - location.variables.nil? - end - end - end - end -end - -# Gets the current bindings for all available Ruby frames. -# -# Filters the internal Rubinius and Skiptrace frames. -def Skiptrace.current_bindings - locations = ::Rubinius::VM.backtrace(1, true) - - Skiptrace::Rubinius::InternalLocationFilter.new(locations).filter.map do |location| - Binding.setup( - location.variables, - location.variables.method, - location.constant_scope, - location.variables.self, - location - ) - end -end - -::Exception.class_eval do - def bindings - @bindings || [] - end -end - -::Rubinius.singleton_class.class_eval do - raise_exception = instance_method(:raise_exception) - - define_method(:raise_exception) do |exc| - if exc.bindings.empty? - exc.instance_variable_set(:@bindings, Skiptrace.current_bindings) - end - - raise_exception.bind(self).call(exc) - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace/version.rb new/lib/skiptrace/version.rb --- old/lib/skiptrace/version.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/lib/skiptrace/version.rb 2019-07-10 15:26:26.000000000 +0200 @@ -1,3 +1,3 @@ module Skiptrace - VERSION = "0.7.0" + VERSION = "0.8.1" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/skiptrace.rb new/lib/skiptrace.rb --- old/lib/skiptrace.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/lib/skiptrace.rb 2019-07-10 15:26:26.000000000 +0200 @@ -1,11 +1,14 @@ case RUBY_ENGINE when 'rbx' - require 'skiptrace/rubinius' + require 'skiptrace/internal/rubinius' when 'jruby' - require 'skiptrace/jruby' + require 'skiptrace/internal/jruby' when 'ruby' - require 'skiptrace/cruby' + require 'skiptrace/internal/cruby' end -require "skiptrace/version" - +require 'skiptrace/location' +require 'skiptrace/binding_locations' +require 'skiptrace/binding_ext' +require 'skiptrace/exception_ext' +require 'skiptrace/version' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2019-04-08 22:09:35.000000000 +0200 +++ new/metadata 2019-07-10 15:26:26.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: bindex version: !ruby/object:Gem::Version - version: 0.7.0 + version: 0.8.1 platform: ruby authors: - Genadi Samokovarov autorequire: bindir: bin cert_chain: [] -date: 2019-04-08 00:00:00.000000000 Z +date: 2019-07-10 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: minitest @@ -93,18 +93,23 @@ - ext/skiptrace/extconf.rb - lib/bindex.rb - lib/skiptrace.rb -- lib/skiptrace/jruby.rb -- lib/skiptrace/jruby_internals.jar -- lib/skiptrace/rubinius.rb +- lib/skiptrace/binding_ext.rb +- lib/skiptrace/binding_locations.rb +- lib/skiptrace/exception_ext.rb +- lib/skiptrace/internal/jruby.rb +- lib/skiptrace/internal/jruby_internals.jar +- lib/skiptrace/internal/rubinius.rb +- lib/skiptrace/location.rb - lib/skiptrace/version.rb - skiptrace.gemspec -- test/current_bindings_test.rb -- test/exception_test.rb - test/fixtures/basic_nested_fixture.rb - test/fixtures/custom_error_fixture.rb - test/fixtures/eval_nested_fixture.rb - test/fixtures/flat_fixture.rb - test/fixtures/reraised_fixture.rb +- test/skiptrace/current_bindings_test.rb +- test/skiptrace/exception_test.rb +- test/skiptrace/location_test.rb - test/test_helper.rb homepage: https://github.com/gsamokovarov/bindex licenses: @@ -130,11 +135,12 @@ specification_version: 4 summary: Bindings for your Ruby exceptions test_files: -- test/current_bindings_test.rb -- test/exception_test.rb - test/fixtures/basic_nested_fixture.rb - test/fixtures/custom_error_fixture.rb - test/fixtures/eval_nested_fixture.rb - test/fixtures/flat_fixture.rb - test/fixtures/reraised_fixture.rb +- test/skiptrace/current_bindings_test.rb +- test/skiptrace/exception_test.rb +- test/skiptrace/location_test.rb - test/test_helper.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/skiptrace.gemspec new/skiptrace.gemspec --- old/skiptrace.gemspec 2019-04-08 22:09:35.000000000 +0200 +++ new/skiptrace.gemspec 2019-07-10 15:26:26.000000000 +0200 @@ -12,7 +12,7 @@ spec.homepage = "https://github.com/gsamokovarov/skiptrace" spec.license = "MIT" - spec.required_ruby_version = ">= 2.0.0" + spec.required_ruby_version = ">= 2.5.0" spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/current_bindings_test.rb new/test/current_bindings_test.rb --- old/test/current_bindings_test.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/current_bindings_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +0,0 @@ -require 'test_helper' - -class CurrentBindingsTest < BaseTest - test 'first binding returned is the current one' do - assert_equal __LINE__, Skiptrace.current_bindings.first.eval('__LINE__') - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/exception_test.rb new/test/exception_test.rb --- old/test/exception_test.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/exception_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,51 +0,0 @@ -require 'test_helper' - -class ExceptionTest < BaseTest - test 'bindings returns all the bindings of where the error originated' do - exc = FlatFixture.new.call - - assert_equal 3, exc.bindings.first.eval('__LINE__') - end - - test 'bindings returns all the bindings of where a custom error originate' do - exc = CustomErrorFixture.new.call - - assert_equal 5, exc.bindings.first.eval('__LINE__') - end - - test 'bindings goes down the_stack' do - exc = BasicNestedFixture.new.call - - assert_equal 11, exc.bindings.first.eval('__LINE__') - end - - test 'bindings inside_of_an_eval' do - exc = EvalNestedFixture.new.call - - assert_equal 11, exc.bindings.first.eval('__LINE__') - end - - test "re-raising doesn't lose bindings information" do - exc = ReraisedFixture.new.call - - assert_equal 3, exc.bindings.first.eval('__LINE__') - end - - test 'bindings is_empty_when_exception_is_still_not_raised' do - exc = RuntimeError.new - - assert_equal [], exc.bindings - end - - test 'bindings is_empty_when_set_backtrace_is_badly_called' do - exc = RuntimeError.new - - # Exception#set_backtrace expects a string or array of strings. If the - # input isn't like this it will raise a TypeError. - assert_raises(TypeError) do - exc.set_backtrace([nil]) - end - - assert_equal [], exc.bindings - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/fixtures/basic_nested_fixture.rb new/test/fixtures/basic_nested_fixture.rb --- old/test/fixtures/basic_nested_fixture.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/fixtures/basic_nested_fixture.rb 2019-07-10 15:26:26.000000000 +0200 @@ -1,13 +1,17 @@ -class BasicNestedFixture - def call - raise_an_error - rescue => exc - exc - end +module Skiptrace + module BasicNestedFixture + extend self + + def call + raise_an_error + rescue => exc + exc + end - private + private def raise_an_error raise end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/fixtures/custom_error_fixture.rb new/test/fixtures/custom_error_fixture.rb --- old/test/fixtures/custom_error_fixture.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/fixtures/custom_error_fixture.rb 2019-07-10 15:26:26.000000000 +0200 @@ -1,9 +1,11 @@ -class CustomErrorFixture - Error = Class.new(StandardError) +module Skiptrace + module CustomErrorFixture + Error = Class.new(StandardError) - def call - raise Error - rescue => exc - exc + def self.call + raise Error + rescue => exc + exc + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/fixtures/eval_nested_fixture.rb new/test/fixtures/eval_nested_fixture.rb --- old/test/fixtures/eval_nested_fixture.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/fixtures/eval_nested_fixture.rb 2019-07-10 15:26:26.000000000 +0200 @@ -1,13 +1,17 @@ -class EvalNestedFixture - def call - tap { raise_an_error_in_eval } - rescue => exc - exc - end +module Skiptrace + module EvalNestedFixture + extend self + + def call + tap { raise_an_error_in_eval } + rescue => exc + exc + end - private + private def raise_an_error_in_eval eval 'raise', binding, __FILE__, __LINE__ end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/fixtures/flat_fixture.rb new/test/fixtures/flat_fixture.rb --- old/test/fixtures/flat_fixture.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/fixtures/flat_fixture.rb 2019-07-10 15:26:26.000000000 +0200 @@ -1,7 +1,9 @@ -class FlatFixture - def call - raise - rescue => exc - exc +module Skiptrace + module FlatFixture + def self.call + raise + rescue => exc + exc + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/fixtures/reraised_fixture.rb new/test/fixtures/reraised_fixture.rb --- old/test/fixtures/reraised_fixture.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/fixtures/reraised_fixture.rb 2019-07-10 15:26:26.000000000 +0200 @@ -1,11 +1,14 @@ -class ReraisedFixture - def call - reraise_an_error - rescue => exc - exc - end +module Skiptrace + module ReraisedFixture + extend self - private + def call + reraise_an_error + rescue => exc + exc + end + + private def raise_an_error_in_eval method_that_raises @@ -16,4 +19,5 @@ def method_that_raises raise end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/skiptrace/current_bindings_test.rb new/test/skiptrace/current_bindings_test.rb --- old/test/skiptrace/current_bindings_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/skiptrace/current_bindings_test.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,11 @@ +require 'test_helper' + +module Skiptrace + class CurrentBindingsTest < Test + test 'first binding returned is the current one' do + _, lineno = Skiptrace.current_bindings.first.source_location + + assert_equal __LINE__ - 2, lineno + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/skiptrace/exception_test.rb new/test/skiptrace/exception_test.rb --- old/test/skiptrace/exception_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/skiptrace/exception_test.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,67 @@ +require 'test_helper' + +module Skiptrace + class ExceptionTest < Test + test 'bindings returns all the bindings of where the error originated' do + exc = FlatFixture.() + + assert_equal 4, exc.bindings.first.source_location.last + end + + test 'bindings returns all the bindings of where a custom error originate' do + exc = CustomErrorFixture.() + + assert_equal 6, exc.bindings.first.source_location.last + end + + test 'bindings goes down the stack' do + exc = BasicNestedFixture.() + + assert_equal 14, exc.bindings.first.source_location.last + end + + test 'bindings inside of an eval' do + exc = EvalNestedFixture.() + + assert_equal 14, exc.bindings.first.source_location.last + end + + test "re-raising doesn't lose bindings information" do + exc = ReraisedFixture.() + + assert_equal 6, exc.bindings.first.source_location.last + end + + test 'bindings is empty when exception is still not raised' do + exc = RuntimeError.new + + assert_equal [], exc.bindings + end + + test 'bindings is empty when set backtrace is badly called' do + exc = RuntimeError.new + + # Exception#set_backtrace expects a string or array of strings. If the + # input isn't like this it will raise a TypeError. + assert_raises(TypeError) do + exc.set_backtrace([nil]) + end + + assert_equal [], exc.bindings + end + + test 'binding_locations maps closely to backtrace_locations' do + exc = FlatFixture.() + + exc.binding_locations.first.tap do |location| + assert_equal 4, location.lineno + assert_equal exc, location.binding.eval('exc') + end + + exc.binding_locations[1].tap do |location| + assert_equal 54, location.lineno + assert_equal exc, location.binding.eval('exc') + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/skiptrace/location_test.rb new/test/skiptrace/location_test.rb --- old/test/skiptrace/location_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/skiptrace/location_test.rb 2019-07-10 15:26:26.000000000 +0200 @@ -0,0 +1,18 @@ +require 'test_helper' + +module Skiptrace + class LocationTest < Test + test 'behaves like Thread::Backtrace::Location' do + native_location = caller_locations.first + location = Skiptrace::Location.new(native_location, binding) + + assert_equal native_location.absolute_path, location.absolute_path + assert_equal native_location.base_label, location.base_label + assert_equal native_location.inspect, location.inspect + assert_equal native_location.label, location.label + assert_equal native_location.to_s, location.to_s + + assert_equal [__FILE__, __LINE__ - 8], location.binding.source_location + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/test_helper.rb new/test/test_helper.rb --- old/test/test_helper.rb 2019-04-08 22:09:35.000000000 +0200 +++ new/test/test_helper.rb 2019-07-10 15:26:26.000000000 +0200 @@ -10,8 +10,10 @@ require fixture end -class BaseTest < MiniTest::Test - def self.test(name, &block) - define_method("test_#{name}", &block) +module Skiptrace + class Test < MiniTest::Test + def self.test(name, &block) + define_method("test_#{name}", &block) + end end end
