diff --git a/CHANGELOG.md b/CHANGELOG.md index d3ef8804..4a08c705 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Opal 0.10 support * Arity checking enabled by default * Dropped support for PhantomJS < 2.0 +* Removed `Kernel#caller` monkey patch so test file/line metadata is only available if supplied via test metadata or for failures. Should improve performance since an exception isn't thrown for every test to gather the data ## 0.5.0 (2015-12-08) diff --git a/README.md b/README.md index 9a93c432..7084854e 100644 --- a/README.md +++ b/README.md @@ -266,8 +266,9 @@ RSpec.configure do |c| c.include TestMod end ``` -* Formatting - * Backtrace info on specs is buggy ([no Kernel::caller method in Opal](https://github.com/opal/opal/issues/894)), in Firefox w/ the browser runner, no backtraces show up with failed specs +* Formatting/Reporting + * Specs will not have file path/line number information on them unless they are supplied from user metadata or they fail, see [this issue](https://github.com/opal/opal-rspec/issues/36) + * In Firefox w/ the browser runner, no backtraces show up with failed specs * Diffs are not yet available when objects do not meet expectations (diff-lcs gem dependency has not been dealt with yet in Opal) * Configuration * Not all RSpec runner options are supported yet diff --git a/opal/opal/rspec/fixes/opal.rb b/opal/opal/rspec/fixes/opal.rb index 0671b9a2..6a9e98fd 100644 --- a/opal/opal/rspec/fixes/opal.rb +++ b/opal/opal/rspec/fixes/opal.rb @@ -1,2 +1 @@ require_relative 'opal/compatibility' -require_relative 'opal/kernel' diff --git a/opal/opal/rspec/fixes/opal/kernel.rb b/opal/opal/rspec/fixes/opal/kernel.rb deleted file mode 100644 index d3dc300c..00000000 --- a/opal/opal/rspec/fixes/opal/kernel.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Kernel - # RSpec tries to add context with this. something like this: https://github.com/stacktracejs/stacktrace.js would be better than this but - # avoiding adding an NPM dependency for now - def caller - %x{ - function getErrorObject(){ - try { throw Error('') } catch(err) { return err; } - } - - - var err = getErrorObject(); - } - stack = `err.stack` - caller_lines = stack.split("\n")[4..-1] - caller_lines.reject! { |l| l.strip.empty? } - - result_formatter = lambda do |filename, line, method=nil| - "#{filename}:#{line} in `(#{method ? method : 'unknown method'})'" - end - - caller_lines.map do |raw_line| - if match = /\s*at (.*) \((\S+):(\d+):\d+/.match(raw_line) - method, filename, line = match.captures - result_formatter[filename, line, method] - elsif match = /\s*at (\S+):(\d+):\d+/.match(raw_line) - filename, line = match.captures - result_formatter[filename, line] - # catch phantom/no 2nd line/col # - elsif match = /\s*at (.*) \((\S+):(\d+)/.match(raw_line) - method, filename, line = match.captures - result_formatter[filename, line, method] - elsif match = /\s*at (.*):(\d+)/.match(raw_line) - filename, line = match.captures - result_formatter[filename, line] - # Firefox - Opal.modules["rspec/core/metadata"]/