From 7560546628146d83a148d7a7bb2f9cff8328e4f5 Mon Sep 17 00:00:00 2001 From: Eric Mueller Date: Sat, 3 Jun 2023 21:07:20 -0400 Subject: [PATCH 1/4] update Rspec::Parser to clean out some simplecov output before parsing worth noting (and I did so) that there are hundreds of rspec plugins, and any of them can write to stdout, alongside your own rspec configuration. We won't be trying to resolve all such issues, only those with the most common libraries (and we'll prefer to resolve them by helping libraries to avoid writing non-json into rspec's json output). --- lib/quiet_quality/tools/rspec/parser.rb | 20 ++++++++- ...ilures.with-simplecov-encoding-errors.json | 45 +++++++++++++++++++ .../rspec/no-failures.with-simplecov.json | 44 ++++++++++++++++++ spec/quiet_quality/tools/rspec/parser_spec.rb | 12 +++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/tools/rspec/no-failures.with-simplecov-encoding-errors.json create mode 100644 spec/fixtures/tools/rspec/no-failures.with-simplecov.json 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/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 From e292375bd29c13ad0bb9597587b8e21dfbb2ab48 Mon Sep 17 00:00:00 2001 From: Eric Mueller Date: Sat, 3 Jun 2023 21:07:40 -0400 Subject: [PATCH 2/4] bump to 1.2.2 --- lib/quiet_quality/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 9f041a986459c215b7b484ad69926873a45322a2 Mon Sep 17 00:00:00 2001 From: Eric Mueller Date: Sat, 3 Jun 2023 21:22:05 -0400 Subject: [PATCH 3/4] Add changelog entries for 1.2.2 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f67987..907566b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # 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) + ## Release 1.2.1 * Fix the handling of the various ways to specify whether tools should limit From 00ff45f0c5d0402dc643cd245d16bf861abbec01 Mon Sep 17 00:00:00 2001 From: Eric Mueller Date: Sun, 4 Jun 2023 13:17:10 -0400 Subject: [PATCH 4/4] list normal-logging-level in the changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 907566b..c5a8772 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ 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