Skip to content

Commit

Permalink
Workaround for JRuby 9.2.14.0
Browse files Browse the repository at this point in the history
This commit a workaround to prevent the following JRuby error.

```console
% ruby -v
jruby 9.2.14.0 (2.5.7) 2020-12-08 ebe64bafb9 Java HotSpot(TM) 64-Bit
Server VM 25.271-b09 on 1.8.0_271-b09 +jit [darwin-x86_64]

% bundle exec rake ascii_spec
(snip)

Failures:

  1) RuboCop::CLI --show-cops with no args prints all cops in their
  right department listing
     Failure/Error:
               lines.slice_before(/Department /).each do |slice|
                 departments = registry.departments.map(&:to_s)
                 current =
                   departments.delete(slice.shift[/Department
  '(?<c>[^']+)'/, 'c'])

                 # all cops in their department listing
                 registry.with_department(current).each do |cop|
                   expect(slice.any? { |l| l.include? cop.cop_name }).to
                 be_truthy
                 end

     ArgumentError:
       invalid byte sequence in US-ASCII
     # uri:classloader:/jruby/kernel/enumerable.rb:17:in `block in
       slice_before'
     # uri:classloader:/jruby/kernel/enumerable.rb:9:in `block in
       slice_before'
     # ./spec/rubocop/cli/cli_options_spec.rb:1136:in `block in <main>'
     # ./spec/support/cli_spec_behavior.rb:27:in `block in
       /Users/koic/src/github.com/rubocop-hq/rubocop/spec/support/cli_spec_behavior.rb'
     # ./lib/rubocop/rspec/shared_contexts.rb:31:in `block in
       /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/rspec/shared_contexts.rb'
     # ./lib/rubocop/rspec/shared_contexts.rb:30:in `block in
       /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/rspec/shared_contexts.rb'
     # ./lib/rubocop/rspec/shared_contexts.rb:7:in `block in
       /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/rspec/shared_contexts.rb'

Finished in 3 minutes 1.3 seconds (files took 7.47 seconds to load)
114 examples, 1 failure

Failed examples:

rspec ./spec/rubocop/cli/cli_options_spec.rb:1134 # RuboCop::CLI
--show-cops with no args prints all cops in their right department listing
```

https://app.circleci.com/pipelines/github/rubocop-hq/rubocop/3729/workflows/d5c1759d-0727-4db1-82ff-4413e446ed87/jobs/166685

See: jruby/jruby#6528
  • Loading branch information
koic authored and bbatsov committed Jan 18, 2021
1 parent 292cba4 commit 0381d1b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/rubocop/cli/cli_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,11 @@ def full_description_of_cop(cop)

it 'prints all cops in their right department listing' do
lines = stdout.lines
# FIXME: Remove the following workaround condition for JRuby.
# https://github.com/jruby/jruby/issues/6528
if RUBY_ENGINE == 'jruby' && Encoding.default_external == Encoding::ASCII
lines = lines.select(&:valid_encoding?)
end
lines.slice_before(/Department /).each do |slice|
departments = registry.departments.map(&:to_s)
current =
Expand Down

0 comments on commit 0381d1b

Please sign in to comment.