Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Remove exe rspec from backtrace #1648

Merged
merged 4 commits into from

4 participants

@myronmarston

No description provided.

@cupakromer
Collaborator

Did you mean to remove the formatter output fixture in this commit as well?

@myronmarston

The -2.1.0.html file is unused (see cbfe6b4). html_formatted.html is still used and kept.

@cupakromer
Collaborator

Ok, just wanted to verify the intent was to include in this PR, just seemed unrelated.

LGTM :+1:

@myronmarston

There's something weird here with the html formatter spec/fixture. My backtrace formatter change caused that spec to fail locally, so I regenerated the fixture and looked at it in my browser to confirm it was OK. That made the spec pass locally. However, on travis it caused it to fail. So I reverted the change. Now it fails for me locally, and passes on travis when the entire suite is run, but fails on travis when it runs the spec file individually.

Anyone have an idea what's going on here? I have a vague memory of an issue like this before with the html formattater spec and fixture...

@JonRowe
Owner

IIRC @xaviershay tried to make the formatter not match exact backtrace lines so ping @xaviershay ?

@xaviershay
Collaborator

sorry won't have a chance to look at this in detail until next week, am in NY for work.

The intent of my change was to strip any ruby-dependent output from the HTML fixture before comparison so that we could use a single fixture rather than one per ruby. Some of this logic already existed to remove backtraces that would be different depending on what computer the specs were run on.

myronmarston added some commits
@myronmarston myronmarston Exclude exe/rspec from backtraces.
When users had installed rspec-core as a bundler :git dependency,
the rspec binary (locally defined in `exe/rspec`) would be included
in backtraces. This wouldn't affect users who had done a normal
gem install since rubygems copies it to a `bin` directory.

Fixes #1646.
3a5f17e
@myronmarston myronmarston Only ignore JRuby files on JRuby.
This should make things slightly faster on MRI as it’s
one less regex to check.
8f72a98
@myronmarston myronmarston Remove unused file. 2e56b71
@myronmarston myronmarston Update changelog. 3f5d94e
@myronmarston myronmarston merged commit bc64892 into master
@myronmarston myronmarston deleted the remove-exe-rspec-from-backtrace branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 31, 2014
  1. @myronmarston

    Exclude exe/rspec from backtraces.

    myronmarston authored
    When users had installed rspec-core as a bundler :git dependency,
    the rspec binary (locally defined in `exe/rspec`) would be included
    in backtraces. This wouldn't affect users who had done a normal
    gem install since rubygems copies it to a `bin` directory.
    
    Fixes #1646.
  2. @myronmarston

    Only ignore JRuby files on JRuby.

    myronmarston authored
    This should make things slightly faster on MRI as it’s
    one less regex to check.
  3. @myronmarston

    Remove unused file.

    myronmarston authored
  4. @myronmarston

    Update changelog.

    myronmarston authored
This page is out of date. Refresh to see the latest.
View
7 Changelog.md
@@ -18,6 +18,13 @@ Enhancements:
* Allow rspec-core to be used when neither rspec-mocks or
rspec-expectations are installed, without requiring any
user configuration. (Sam Phippen, Myron Marston, #1615)
+* Don't filter out gems from backtraces by default. (The RSpec
+ gems will still be filtered). User feedback has indicated
+ that including gems in default backtraces will be useful.
+ (Myron Marston, #1641)
+* Fix default backtrace filters so that the RSpec binary is
+ excluded when installing RSpec as a bundler `:git` dependency.
+ (Myron Marston, #1648)
Bug Fixes:
View
8 lib/rspec/core/backtrace_formatter.rb
@@ -8,11 +8,9 @@ class BacktraceFormatter
def initialize
@full_backtrace = false
- patterns = [
- "/lib\d*/ruby/",
- "org/jruby/",
- "bin/",
- ].map { |s| Regexp.new(s.gsub("/", File::SEPARATOR)) }
+ patterns = %w[ /lib\d*/ruby/ bin/ exe/rspec ]
+ patterns << "org/jruby/" if RUBY_PLATFORM == 'java'
+ patterns.map! { |s| Regexp.new(s.gsub("/", File::SEPARATOR)) }
@system_exclusion_patterns = [Regexp.union(RSpec::CallerFilter::IGNORE_REGEX, *patterns)]
@exclusion_patterns = [] + @system_exclusion_patterns
View
6 spec/rspec/core/backtrace_formatter_spec.rb
@@ -19,7 +19,11 @@ def make_backtrace_formatter(exclusion_patterns=nil, inclusion_patterns=nil)
expect(make_backtrace_formatter.exclude?("/lib/rspec/support/foo.rb")).to be true
end
- it "excludes java files (for JRuby)" do
+ it "excludes the rspec binary, even when rspec-core has installed as a bundler :git dependency" do
+ expect(make_backtrace_formatter.exclude?("exe/rspec")).to be true
+ end
+
+ it "excludes java files (for JRuby)", :if => (RUBY_PLATFORM == 'java') do
expect(make_backtrace_formatter.exclude?("org/jruby/RubyArray.java:2336")).to be true
end
View
392 spec/rspec/core/formatters/html_formatted-2.1.0.html
@@ -1,392 +0,0 @@
-<html lang="en">
-<head>
- <title>RSpec results</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta http-equiv="Expires" content="-1">
- <meta http-equiv="Pragma" content="no-cache">
- <style type="text/css">
- body {
- margin: 0;
- padding: 0;
- background: #fff;
- font-size: 80%;
- }
- </style>
- <script type="text/javascript">
- // <![CDATA[
-
-function addClass(element_id, classname) {
- document.getElementById(element_id).className += (" " + classname);
-}
-
-function removeClass(element_id, classname) {
- var elem = document.getElementById(element_id);
- var classlist = elem.className.replace(classname,'');
- elem.className = classlist;
-}
-
-function moveProgressBar(percentDone) {
- document.getElementById("rspec-header").style.width = percentDone +"%";
-}
-
-function makeRed(element_id) {
- removeClass(element_id, 'passed');
- removeClass(element_id, 'not_implemented');
- addClass(element_id,'failed');
-}
-
-function makeYellow(element_id) {
- var elem = document.getElementById(element_id);
- if (elem.className.indexOf("failed") == -1) { // class doesn't includes failed
- if (elem.className.indexOf("not_implemented") == -1) { // class doesn't include not_implemented
- removeClass(element_id, 'passed');
- addClass(element_id,'not_implemented');
- }
- }
-}
-
-function apply_filters() {
- var passed_filter = document.getElementById('passed_checkbox').checked;
- var failed_filter = document.getElementById('failed_checkbox').checked;
- var pending_filter = document.getElementById('pending_checkbox').checked;
-
- assign_display_style("example passed", passed_filter);
- assign_display_style("example failed", failed_filter);
- assign_display_style("example not_implemented", pending_filter);
-
- assign_display_style_for_group("example_group passed", passed_filter);
- assign_display_style_for_group("example_group not_implemented", pending_filter, pending_filter || passed_filter);
- assign_display_style_for_group("example_group failed", failed_filter, failed_filter || pending_filter || passed_filter);
-}
-
-function get_display_style(display_flag) {
- var style_mode = 'none';
- if (display_flag == true) {
- style_mode = 'block';
- }
- return style_mode;
-}
-
-function assign_display_style(classname, display_flag) {
- var style_mode = get_display_style(display_flag);
- var elems = document.getElementsByClassName(classname)
- for (var i=0; i<elems.length;i++) {
- elems[i].style.display = style_mode;
- }
-}
-
-function assign_display_style_for_group(classname, display_flag, subgroup_flag) {
- var display_style_mode = get_display_style(display_flag);
- var subgroup_style_mode = get_display_style(subgroup_flag);
- var elems = document.getElementsByClassName(classname)
- for (var i=0; i<elems.length;i++) {
- var style_mode = display_style_mode;
- if ((display_flag != subgroup_flag) && (elems[i].getElementsByTagName('dt')[0].innerHTML.indexOf(", ") != -1)) {
- elems[i].style.display = subgroup_style_mode;
- } else {
- elems[i].style.display = display_style_mode;
- }
- }
-}
-
- // ]]>
- </script>
- <style type="text/css">
-#rspec-header {
- background: #65C400; color: #fff; height: 4em;
-}
-
-.rspec-report h1 {
- margin: 0px 10px 0px 10px;
- padding: 10px;
- font-family: "Lucida Grande", Helvetica, sans-serif;
- font-size: 1.8em;
- position: absolute;
-}
-
-#label {
- float:left;
-}
-
-#display-filters {
- float:left;
- padding: 28px 0 0 40%;
- font-family: "Lucida Grande", Helvetica, sans-serif;
-}
-
-#summary {
- float:right;
- padding: 5px 10px;
- font-family: "Lucida Grande", Helvetica, sans-serif;
- text-align: right;
-}
-
-#summary p {
- margin: 0 0 0 2px;
-}
-
-#summary #totals {
- font-size: 1.2em;
-}
-
-.example_group {
- margin: 0 10px 5px;
- background: #fff;
-}
-
-dl {
- margin: 0; padding: 0 0 5px;
- font: normal 11px "Lucida Grande", Helvetica, sans-serif;
-}
-
-dt {
- padding: 3px;
- background: #65C400;
- color: #fff;
- font-weight: bold;
-}
-
-dd {
- margin: 5px 0 5px 5px;
- padding: 3px 3px 3px 18px;
-}
-
-dd .duration {
- padding-left: 5px;
- text-align: right;
- right: 0px;
- float:right;
-}
-
-dd.example.passed {
- border-left: 5px solid #65C400;
- border-bottom: 1px solid #65C400;
- background: #DBFFB4; color: #3D7700;
-}
-
-dd.example.not_implemented {
- border-left: 5px solid #FAF834;
- border-bottom: 1px solid #FAF834;
- background: #FCFB98; color: #131313;
-}
-
-dd.example.pending_fixed {
- border-left: 5px solid #0000C2;
- border-bottom: 1px solid #0000C2;
- color: #0000C2; background: #D3FBFF;
-}
-
-dd.example.failed {
- border-left: 5px solid #C20000;
- border-bottom: 1px solid #C20000;
- color: #C20000; background: #FFFBD3;
-}
-
-
-dt.not_implemented {
- color: #000000; background: #FAF834;
-}
-
-dt.pending_fixed {
- color: #FFFFFF; background: #C40D0D;
-}
-
-dt.failed {
- color: #FFFFFF; background: #C40D0D;
-}
-
-
-#rspec-header.not_implemented {
- color: #000000; background: #FAF834;
-}
-
-#rspec-header.pending_fixed {
- color: #FFFFFF; background: #C40D0D;
-}
-
-#rspec-header.failed {
- color: #FFFFFF; background: #C40D0D;
-}
-
-
-.backtrace {
- color: #000;
- font-size: 12px;
-}
-
-a {
- color: #BE5C00;
-}
-
-/* Ruby code, style similar to vibrant ink */
-.ruby {
- font-size: 12px;
- font-family: monospace;
- color: white;
- background-color: black;
- padding: 0.1em 0 0.2em 0;
-}
-
-.ruby .keyword { color: #FF6600; }
-.ruby .constant { color: #339999; }
-.ruby .attribute { color: white; }
-.ruby .global { color: white; }
-.ruby .module { color: white; }
-.ruby .class { color: white; }
-.ruby .string { color: #66FF00; }
-.ruby .ident { color: white; }
-.ruby .method { color: #FFCC00; }
-.ruby .number { color: white; }
-.ruby .char { color: white; }
-.ruby .comment { color: #9933CC; }
-.ruby .symbol { color: white; }
-.ruby .regex { color: #44B4CC; }
-.ruby .punct { color: white; }
-.ruby .escape { color: white; }
-.ruby .interp { color: white; }
-.ruby .expr { color: white; }
-
-.ruby .offending { background-color: gray; }
-.ruby .linenum {
- width: 75px;
- padding: 0.1em 1em 0.2em 0;
- color: #000000;
- background-color: #FFFBD3;
-}
-
- </style>
-</head>
-<body>
-<div class="rspec-report">
-
-<div id="rspec-header">
- <div id="label">
- <h1>RSpec Code Examples</h1>
- </div>
-
- <div id="display-filters">
- <input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked onchange="apply_filters()" value="1"> <label for="passed_checkbox">Passed</label>
- <input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked onchange="apply_filters()" value="2"> <label for="failed_checkbox">Failed</label>
- <input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked onchange="apply_filters()" value="3"> <label for="pending_checkbox">Pending</label>
- </div>
-
- <div id="summary">
- <p id="totals"> </p>
- <p id="duration"> </p>
- </div>
-</div>
-
-
-<div class="results">
-<div id="div_group_1" class="example_group passed">
- <dl style="margin-left: 0px;">
- <dt id="example_group_1" class="passed">pending spec with no implementation</dt>
- <script type="text/javascript">makeYellow('rspec-header');</script>
- <script type="text/javascript">makeYellow('div_group_1');</script>
- <script type="text/javascript">makeYellow('example_group_1');</script>
- <script type="text/javascript">moveProgressBar('14.2');</script>
- <dd class="example not_implemented"><span class="not_implemented_spec_name">is pending (PENDING: Not yet implemented)</span></dd>
- </dl>
-</div>
-<div id="div_group_2" class="example_group passed">
- <dl style="margin-left: 0px;">
- <dt id="example_group_2" class="passed">pending command with block format</dt>
- </dl>
-</div>
-<div id="div_group_3" class="example_group passed">
- <dl style="margin-left: 15px;">
- <dt id="example_group_3" class="passed">with content that would fail</dt>
- <script type="text/javascript">moveProgressBar('28.5');</script>
- <dd class="example passed"><span class="passed_spec_name">is pending</span><span class='duration'>n.nnnns</span></dd>
- </dl>
-</div>
-<div id="div_group_4" class="example_group passed">
- <dl style="margin-left: 15px;">
- <dt id="example_group_4" class="passed">with content that would pass</dt>
- <script type="text/javascript">makeRed('rspec-header');</script>
- <script type="text/javascript">makeRed('div_group_4');</script>
- <script type="text/javascript">makeRed('example_group_4');</script>
- <script type="text/javascript">moveProgressBar('42.8');</script>
- <dd class="example pending_fixed">
- <span class="failed_spec_name">fails</span>
- <span class="duration">n.nnnns</span>
- <div class="failure" id="failure_1">
- <div class="message"><pre>RSpec::Core::Pending::PendingExampleFixedError</pre></div>
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:18</pre></div>
- <pre class="ruby"><code><span class="linenum">16</span> context <span class="string"><span class="delimiter">"</span><span class="content">with content that would pass</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
-<span class="linenum">17</span> it <span class="string"><span class="delimiter">"</span><span class="content">fails</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
-<span class="offending"><span class="linenum">18</span> pending <span class="keyword">do</span></span>
-<span class="linenum">19</span> expect(<span class="integer">1</span>).to eq(<span class="integer">1</span>)
-<span class="linenum">20</span> <span class="keyword">end</span></code></pre>
- </div>
- </dd>
- </dl>
-</div>
-<div id="div_group_5" class="example_group passed">
- <dl style="margin-left: 0px;">
- <dt id="example_group_5" class="passed">passing spec</dt>
- <script type="text/javascript">moveProgressBar('57.1');</script>
- <dd class="example passed">
-<span class="passed_spec_name">passes</span><span class="duration">n.nnnns</span>
-</dd>
- </dl>
-</div>
-<div id="div_group_6" class="example_group passed">
- <dl style="margin-left: 0px;">
- <dt id="example_group_6" class="passed">failing spec</dt>
- <script type="text/javascript">makeRed('div_group_6');</script>
- <script type="text/javascript">makeRed('example_group_6');</script>
- <script type="text/javascript">moveProgressBar('71.4');</script>
- <dd class="example failed">
- <span class="failed_spec_name">fails</span>
- <span class="duration">n.nnnns</span>
- <div class="failure" id="failure_2">
- <div class="message"><pre>
-expected: 2
- got: 1
-
-(compared using ==)
-</pre></div>
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:33</pre></div>
- <pre class="ruby"><code><span class="linenum">31</span><span class="constant">RSpec</span>.describe <span class="string"><span class="delimiter">"</span><span class="content">failing spec</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
-<span class="linenum">32</span> it <span class="string"><span class="delimiter">"</span><span class="content">fails</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
-<span class="offending"><span class="linenum">33</span> expect(<span class="integer">1</span>).to eq(<span class="integer">2</span>)</span>
-<span class="linenum">34</span> <span class="keyword">end</span>
-<span class="linenum">35</span><span class="keyword">end</span></code></pre>
- </div>
- </dd>
- </dl>
-</div>
-<div id="div_group_7" class="example_group passed">
- <dl style="margin-left: 0px;">
- <dt id="example_group_7" class="passed">a failing spec with odd backtraces</dt>
- <script type="text/javascript">makeRed('div_group_7');</script>
- <script type="text/javascript">makeRed('example_group_7');</script>
- <script type="text/javascript">moveProgressBar('85.7');</script>
- <dd class="example failed">
- <span class="failed_spec_name">fails with a backtrace that has no file</span>
- <span class="duration">n.nnnns</span>
- <div class="failure" id="failure_3">
- <div class="message"><pre>foo</pre></div>
- <div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:41</pre></div>
- <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
- </div>
- </dd>
- <script type="text/javascript">moveProgressBar('100.0');</script>
- <dd class="example failed">
- <span class="failed_spec_name">fails with a backtrace containing an erb file</span>
- <span class="duration">n.nnnns</span>
- <div class="failure" id="failure_4">
- <div class="message"><pre>Exception</pre></div>
- <div class="backtrace"><pre></pre></div>
- <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
- </div>
- </dd>
- </dl>
-</div>
-<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>n.nnnn seconds</strong>";</script>
-<script type="text/javascript">document.getElementById('totals').innerHTML = "7 examples, 4 failures, 1 pending";</script>
-</div>
-</div>
-</body>
-</html>
View
22 spec/rspec/core/formatters/html_formatted.html
@@ -334,8 +334,14 @@
(compared using ==)
</pre></div>
<div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:31</pre></div>
-
-
+ <pre class="ruby"><code><span class="linenum">29</span><span class="constant">RSpec</span>.describe <span class="string"><span class="delimiter">"</span><span class="content">failing spec</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
+<span class="linenum">30</span> it <span class="string"><span class="delimiter">"</span><span class="content">fails</span><span class="delimiter">"</span></span> <span class="keyword">do</span>
+<span class="offending"><span class="linenum">31</span> expect(<span class="integer">1</span>).to eq(<span class="integer">2</span>)</span>
+<span class="linenum">32</span> <span class="keyword">end</span>
+<span class="linenum">33</span><span class="keyword">end</span></code></pre>
+ </div>
+ </dd>
+ </dl>
</div>
<div id="div_group_7" class="example_group passed">
<dl style="margin-left: 0px;">
@@ -346,7 +352,9 @@
<div class="failure" id="failure_3">
<div class="message"><pre>foo</pre></div>
<div class="backtrace"><pre>./spec/rspec/core/resources/formatter_specs.rb:39</pre></div>
-
+ <pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for (erb)</span></code></pre>
+ </div>
+ </dd>
<script type="text/javascript">moveProgressBar('100.0');</script><dd class="example failed">
<span class="failed_spec_name">fails with a backtrace containing an erb file</span>
<span class="duration">n.nnnns</span>
@@ -356,15 +364,9 @@
<pre class="ruby"><code><span class="linenum">-1</span><span class="comment"># Couldn't get snippet for /foo.html.erb</span></code></pre>
</div>
</dd>
-
+ </dl>
</div>
<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>n.nnnn seconds</strong>";</script><script type="text/javascript">document.getElementById('totals').innerHTML = "7 examples, 4 failures, 2 pending";</script>
-</dd>
-</dl>
-</div>
-</dd>
-</dl>
-</div>
</div>
</div>
</body>
View
11 spec/support/formatter_support.rb
@@ -6,7 +6,10 @@ def run_example_specs_with_formatter(formatter_option)
err.set_encoding("utf-8") if err.respond_to?(:set_encoding)
runner = RSpec::Core::Runner.new(options)
- runner.instance_variable_get("@configuration").backtrace_formatter.inclusion_patterns = []
+ configuration = runner.instance_variable_get("@configuration")
+ configuration.backtrace_formatter.exclusion_patterns << /rspec_with_simplecov/
+ configuration.backtrace_formatter.inclusion_patterns = []
+
runner.run(err, out)
output = out.string
@@ -52,7 +55,7 @@ def expected_summary_output_for_example_specs
| (compared using ==)
| # ./spec/rspec/core/resources/formatter_specs.rb:31
| # ./spec/spec_helper.rb:77:in `run'
- | # ./spec/support/formatter_support.rb:10:in `run_example_specs_with_formatter'
+ | # ./spec/support/formatter_support.rb:13:in `run_example_specs_with_formatter'
| # ./spec/spec_helper.rb:124:in `run'
| # ./spec/spec_helper.rb:124
| # ./spec/spec_helper.rb:82:in `instance_exec'
@@ -109,7 +112,7 @@ def expected_summary_output_for_example_specs
| (compared using ==)
| # ./spec/rspec/core/resources/formatter_specs.rb:31:in `block (2 levels) in <top (required)>'
| # ./spec/spec_helper.rb:77:in `run'
- | # ./spec/support/formatter_support.rb:10:in `run_example_specs_with_formatter'
+ | # ./spec/support/formatter_support.rb:13:in `run_example_specs_with_formatter'
| # ./spec/spec_helper.rb:124:in `block (4 levels) in <top (required)>'
| # ./spec/spec_helper.rb:82:in `instance_exec'
| # ./spec/spec_helper.rb:82:in `block in sandboxed'
@@ -123,7 +126,7 @@ def expected_summary_output_for_example_specs
| # (erb):1:in `<main>'
| # ./spec/rspec/core/resources/formatter_specs.rb:39:in `block (2 levels) in <top (required)>'
| # ./spec/spec_helper.rb:77:in `run'
- | # ./spec/support/formatter_support.rb:10:in `run_example_specs_with_formatter'
+ | # ./spec/support/formatter_support.rb:13:in `run_example_specs_with_formatter'
| # ./spec/spec_helper.rb:124:in `block (4 levels) in <top (required)>'
| # ./spec/spec_helper.rb:82:in `instance_exec'
| # ./spec/spec_helper.rb:82:in `block in sandboxed'
Something went wrong with that request. Please try again.