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

Fix flakey specs #44

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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