Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fi 2413 optional groups prioritize pass #431

Merged
merged 10 commits into from
Jan 22, 2024
8 changes: 7 additions & 1 deletion dev_suites/dev_infrastructure_test/passing_optional_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ class PassingOptionalGroup < Inferno::TestGroup

optional

test 'Test in Optional Group' do
test 'Passing test in Optional Group' do
optional

run { assert true }
end

test 'Failing test in Optional Group' do
optional

run { assert false }
end
end
end
4 changes: 4 additions & 0 deletions lib/inferno/result_summarizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def initialize(results)
end

def summarize
return 'pass' if all_optional_results? &&
unique_result_strings.any?('pass') &&
unique_result_strings.none? { |result| %w[wait running].include? result }

prioritized_result_strings.find { |result_string| unique_result_strings.include? result_string }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/inferno/dsl/test_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

results = results_repo.current_results_for_test_session(test_session.id)

expect(results.length).to eq(17)
expect(results.length).to eq(18)

required_results = results.reject(&:optional?)
non_passing_results = required_results.reject { |result| result.result == 'pass' }
Expand Down
4 changes: 2 additions & 2 deletions spec/inferno/result_summarizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
end

context 'when all results are optional' do
it 'returns the highest priority result' do
it 'prioritizes passing over failing when a result passes' do
allow(passing_result).to receive(:optional?).and_return(true)
allow(failing_result).to receive(:optional?).and_return(true)
result = described_class.new([passing_result, failing_result]).summarize

expect(result).to eq('fail')
expect(result).to eq('pass')
end
end

Expand Down
Loading