diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f67987..c5a8772 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## Release 1.2.2 + +* Add some code to the Rspec::Parser that _cleans_ the json of certain text that + simplecov may write into the rspec json output. (#91, resolves #86) +* Include the name of the originating tool in the printed message, and the + annotation, when a warning is presented. (#90 resolves #72) +* Support `normal` as a logging level, and the `--normal` and `-n` cli + arguments. This is the default value, so this really only matters if your + config file sets another value and you want to override it from the cli. + (#91, resolves #86) + ## Release 1.2.1 * Fix the handling of the various ways to specify whether tools should limit diff --git a/lib/quiet_quality/tools/rspec/parser.rb b/lib/quiet_quality/tools/rspec/parser.rb index 3df1216..d1f0f2a 100644 --- a/lib/quiet_quality/tools/rspec/parser.rb +++ b/lib/quiet_quality/tools/rspec/parser.rb @@ -16,8 +16,26 @@ def messages attr_reader :text + # Many people use simplecov with rspec, and its default formatter + # writes text output into the stdout stream of rspec even when rspec is + # asked for json output. I have an issue open here, and I'll get a pair + # of PRs together if they indicate any willingness to accept such a + # change: https://github.com/simplecov-ruby/simplecov/issues/1060 + # + # The only stdout writes are visible on these lines: + # https://github.com/simplecov-ruby/simplecov-html/blob/main/lib/simplecov-html.rb#L31 + # https://github.com/simplecov-ruby/simplecov-html/blob/main/lib/simplecov-html.rb#L80 + # + # There are _hundreds_ of rspec plugins, and any of them could write to + # stdout - we probably won't worry about any but the most common. + def cleaned_text + @_cleaned_text ||= text + .gsub(/Coverage report generated.*covered.$/, "") + .gsub(/Encoding problems with file.*$/, "") + end + def content - @_content ||= JSON.parse(text, symbolize_names: true) + @_content ||= JSON.parse(cleaned_text, symbolize_names: true) end def examples diff --git a/lib/quiet_quality/version.rb b/lib/quiet_quality/version.rb index 9091081..c973991 100644 --- a/lib/quiet_quality/version.rb +++ b/lib/quiet_quality/version.rb @@ -1,3 +1,3 @@ module QuietQuality - VERSION = "1.2.1" + VERSION = "1.2.2" end diff --git a/spec/fixtures/tools/rspec/no-failures.with-simplecov-encoding-errors.json b/spec/fixtures/tools/rspec/no-failures.with-simplecov-encoding-errors.json new file mode 100644 index 0000000..6ac0954 --- /dev/null +++ b/spec/fixtures/tools/rspec/no-failures.with-simplecov-encoding-errors.json @@ -0,0 +1,45 @@ +{ + "version": "3.12.2", + "seed": 64304, + "examples": [ + { + "id": "./spec/quiet_quality/tools/standardrb/runner_spec.rb[1:1:4:3:2]", + "description": "calls standardrb correctly, with no targets", + "full_description": "QuietQuality::Tools::Standardrb::Runner#invoke! when changed_files is full and contains too many ruby files calls standardrb correctly, with no targets", + "status": "passed", + "file_path": "./spec/quiet_quality/tools/standardrb/runner_spec.rb", + "line_number": 75, + "run_time": 0.000185, + "pending_message": null + }, + { + "id": "./spec/quiet_quality/tools/standardrb/runner_spec.rb[1:1:4:1:1]", + "description": "does not call standardrb", + "full_description": "QuietQuality::Tools::Standardrb::Runner#invoke! when changed_files is full but contains no ruby files does not call standardrb", + "status": "passed", + "file_path": "./spec/quiet_quality/tools/standardrb/runner_spec.rb", + "line_number": 54, + "run_time": 0.000125, + "pending_message": null + }, + { + "id": "./spec/quiet_quality/tools/standardrb/runner_spec.rb[1:1:4:2:2]", + "description": "calls standardrb correctly, with changed and relevant targets", + "full_description": "QuietQuality::Tools::Standardrb::Runner#invoke! when changed_files is full and contains some ruby files calls standardrb correctly, with changed and relevant targets", + "status": "passed", + "file_path": "./spec/quiet_quality/tools/standardrb/runner_spec.rb", + "line_number": 63, + "run_time": 0.000148, + "pending_message": null + } + ], + "summary": { + "duration": 0.018751, + "example_count": 3, + "failure_count": 0, + "pending_count": 0, + "errors_outside_of_examples_count": 0 + }, + "summary_line": "89 examples, 0 failures" +}Encoding problems with file foo.rb. Simplecov/ERB can't handle non ASCII characters in filenames. Error: Fake error. +Encoding problems with file bar.rb. Simplecov/ERB can't handle non ASCII characters in filenames. Error: Fake error. diff --git a/spec/fixtures/tools/rspec/no-failures.with-simplecov.json b/spec/fixtures/tools/rspec/no-failures.with-simplecov.json new file mode 100644 index 0000000..7a40d4a --- /dev/null +++ b/spec/fixtures/tools/rspec/no-failures.with-simplecov.json @@ -0,0 +1,44 @@ +{ + "version": "3.12.2", + "seed": 64304, + "examples": [ + { + "id": "./spec/quiet_quality/tools/standardrb/runner_spec.rb[1:1:4:3:2]", + "description": "calls standardrb correctly, with no targets", + "full_description": "QuietQuality::Tools::Standardrb::Runner#invoke! when changed_files is full and contains too many ruby files calls standardrb correctly, with no targets", + "status": "passed", + "file_path": "./spec/quiet_quality/tools/standardrb/runner_spec.rb", + "line_number": 75, + "run_time": 0.000185, + "pending_message": null + }, + { + "id": "./spec/quiet_quality/tools/standardrb/runner_spec.rb[1:1:4:1:1]", + "description": "does not call standardrb", + "full_description": "QuietQuality::Tools::Standardrb::Runner#invoke! when changed_files is full but contains no ruby files does not call standardrb", + "status": "passed", + "file_path": "./spec/quiet_quality/tools/standardrb/runner_spec.rb", + "line_number": 54, + "run_time": 0.000125, + "pending_message": null + }, + { + "id": "./spec/quiet_quality/tools/standardrb/runner_spec.rb[1:1:4:2:2]", + "description": "calls standardrb correctly, with changed and relevant targets", + "full_description": "QuietQuality::Tools::Standardrb::Runner#invoke! when changed_files is full and contains some ruby files calls standardrb correctly, with changed and relevant targets", + "status": "passed", + "file_path": "./spec/quiet_quality/tools/standardrb/runner_spec.rb", + "line_number": 63, + "run_time": 0.000148, + "pending_message": null + } + ], + "summary": { + "duration": 0.018751, + "example_count": 3, + "failure_count": 0, + "pending_count": 0, + "errors_outside_of_examples_count": 0 + }, + "summary_line": "89 examples, 0 failures" +}Coverage report generated for RSpec to /Users/emueller/src/quiet_quality/coverage. 1072 / 1072 LOC (100.0%) covered. diff --git a/spec/quiet_quality/tools/rspec/parser_spec.rb b/spec/quiet_quality/tools/rspec/parser_spec.rb index 50e4c44..b0f94e8 100644 --- a/spec/quiet_quality/tools/rspec/parser_spec.rb +++ b/spec/quiet_quality/tools/rspec/parser_spec.rb @@ -47,5 +47,17 @@ expect(m.tool_name).to eq(:rspec) end end + + context "when simplecov dumps its non-json results output into the stream" do + let(:text) { fixture_content("tools", "rspec", "no-failures.with-simplecov.json") } + it { is_expected.to be_a(QuietQuality::Messages) } + it { is_expected.to be_empty } + end + + context "when simplecov dumps multiple filename encoding problems into the stream" do + let(:text) { fixture_content("tools", "rspec", "no-failures.with-simplecov-encoding-errors.json") } + it { is_expected.to be_a(QuietQuality::Messages) } + it { is_expected.to be_empty } + end end end