Skip to content

Commit

Permalink
consider a tool to 'fail' if there are messages, not if it thinks it …
Browse files Browse the repository at this point in the history
…failed

when filtering messages based on changed-files, we don't want the tool to say
it failed, but then supply zero messages. Instead, the pipeline should claim
to have passed
  • Loading branch information
nevinera committed May 24, 2023
1 parent bb4038d commit 6c3b40b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/quiet_quality/executors/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def outcome
end

def failure?
outcome.failure?
messages.any?
end

def messages
Expand Down
18 changes: 14 additions & 4 deletions spec/quiet_quality/executors/pipeline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
let(:runner) { instance_double(QuietQuality::Tools::Rspec::Runner, invoke!: runner_outcome) }
before { allow(QuietQuality::Tools::Rspec::Runner).to receive(:new).and_return(runner) }

let(:other_messages) { generate_messages(4, path: "path/other.rb") }
let(:foo_message) { generate_message(path: "path/foo.rb", start_line: 3, stop_line: 7, body: "foo text") }
let(:bar_message) { generate_message(path: "path/bar.rb", start_line: 8, stop_line: 12, body: "bar text") }
let(:parsed_messages) { QuietQuality::Messages.new(generate_messages(4) + [foo_message, bar_message]) }
let(:parsed_messages) { QuietQuality::Messages.new(other_messages + [foo_message, bar_message]) }
let(:parser) { instance_double(QuietQuality::Tools::Rspec::Parser, messages: parsed_messages) }
before { allow(QuietQuality::Tools::Rspec::Parser).to receive(:new).and_return(parser) }

Expand All @@ -33,10 +34,19 @@

describe "#failure?" do
subject(:failure?) { pipeline.failure? }
it { is_expected.to be_truthy }

context "when the runner succeeds" do
let(:runner_outcome) { build_success(tool_name, "fake output", "fake logging") }
context "when there are messages from the tool" do
let(:parsed_messages) { QuietQuality::Messages.new(other_messages + [foo_message, bar_message]) }
it { is_expected.to be_truthy }

context "but they are all filtered" do
let(:parsed_messages) { QuietQuality::Messages.new(other_messages) }
it { is_expected.to be_falsey }
end
end

context "when there are no messages from the tool" do
let(:parsed_messages) { empty_messages }
it { is_expected.to be_falsey }
end
end
Expand Down

0 comments on commit 6c3b40b

Please sign in to comment.