Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR supports auto-restart RuboCop server when updating RuboCop. First, cache RuboCop version when the RuboCop server starts. And, auto-restarts when the runtime (client) RuboCop version does not match the cached RuboCop version.
- Loading branch information
Showing
7 changed files
with
76 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'rubocop --server', :isolated_environment do # rubocop:disable RSpec/DescribeClass | ||
let(:rubocop) { "#{RuboCop::ConfigLoader::RUBOCOP_HOME}/exe/rubocop" } | ||
|
||
include_context 'cli spec behavior' | ||
|
||
if RuboCop::Server.support_server? | ||
context 'when using `--server` option after updating RuboCop' do | ||
before do | ||
options = '--server --only Style/FrozenStringLiteralComment,Style/StringLiterals' | ||
`ruby -I . "#{rubocop}" #{options}` | ||
|
||
# Emulating RuboCop updates. `0.99.9` is a version value for testing that | ||
# will never be used in the real world RuboCop version. | ||
RuboCop::Server::Cache.write_version_file('0.99.9') | ||
end | ||
|
||
after do | ||
`ruby -I . "#{rubocop}" --stop-server` | ||
end | ||
|
||
it 'displays a restart information message' do | ||
create_file('example.rb', <<~RUBY) | ||
# frozen_string_literal: true | ||
x = 0 | ||
puts x | ||
RUBY | ||
options = '--server --only Style/FrozenStringLiteralComment,Style/StringLiterals' | ||
expect(`ruby -I . "#{rubocop}" #{options}`).to start_with( | ||
'RuboCop version incompatibility found, RuboCop server restarting...' | ||
) | ||
end | ||
end | ||
end | ||
end |