Skip to content

Commit

Permalink
Merge pull request #44 from selectiveci/fix-file-correlator-spec
Browse files Browse the repository at this point in the history
Fix flakey specs
  • Loading branch information
benjaminwood authored Jan 13, 2024
2 parents 2b0d5fb + f9da6e3 commit 488eee9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/selective/ruby/core/file_correlator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def initialize(diff, num_commits, target_branch)
def correlate
JSON.parse(get_correlated_files, symbolize_names: true)
rescue FileCorrelatorError, JSON::ParserError
print_warning "Selective was unable to correlate the diff to test files. This may result in a sub-optimal test order. If the issue persists, please contact support."
print_warning(<<~MSG)
Selective was unable to correlate the diff to test files. This may result in a sub-optimal test order.
If the issue persists, please contact support.
MSG
end

private
Expand Down
1 change: 1 addition & 0 deletions spec/selective/ruby/core/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

before do
allow(Process).to receive(:spawn).and_return(123)
allow(controller).to receive(:kill_transport)
allow(controller).to receive(:handle_termination_signals)
allow(controller).to receive(:wait_for_connectivity)
allow(controller).to receive(:exit)
Expand Down
5 changes: 5 additions & 0 deletions spec/selective/ruby/core/file_correlator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

describe "#correlate" do
it "returns a hash with the expected shape" do
# The fetch normally happens when the diff is generated
# but if another runner created the manifest the fetch may
# not have happened on the runner that is running this test.
# So, we fetch here to ensure this test ddoes not fail.
`git fetch origin #{target_branch} --depth=1`
expect(instance.correlate).to match({:correlated_files => Hash, :uncorrelated_files => Hash})
end

Expand Down

0 comments on commit 488eee9

Please sign in to comment.