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

test: Fix stalled tests on Ruby 3.1 #3577

Merged
merged 1 commit into from Dec 21, 2021
Merged

Conversation

ashie
Copy link
Member

@ashie ashie commented Dec 21, 2021

Which issue(s) this PR fixes:
Fixes #3543

What this PR does / why we need it:
Several tests are stalled since Ruby 3.1, I found that it's caused by
the followig Ruby's change:

ruby/ruby@2d98593

It seems that there are some conditions to reproduce it:

  • attr_reader is defined in a class
  • $log is accessed by it
  • assert is called with a block
  • assert refers the $log via the attr_reader
  • ... (some other conditions seem needed but not clarified yet)

Here is the sample test case to reproduce it:

require 'fluent/test'

class StallTest < Test::Unit::TestCase
  class Stall
    attr_reader :log
    def initialize
      @log = $log
    end
  end

  setup do
    Fluent::Test.setup
  end

  20.times do |i|
    test "stall #{i}" do
      assert { Stall.new.log }
    end
  end
end

Becasue all stalled tests don't need to use block, I remove these blocks
to avoid this issue.

Docs Changes:
None.

Release Note:
Same with the title.

Several tests are stalled since Ruby 3.1, I found that it's caused by
the followig Ruby's change:

  ruby/ruby@2d98593

It seems that there are some conditions to reproduce it:

  * `attr_reader` is defined in a class
  * `$log` is accessed by it
  * `assert` is called with a block
  * `assert` refers the `$log` via the `attr_reader`
  * ... (some other conditions seem needed but not clarified yet)

Here is the sample test case to reproduce it:

```ruby
require 'fluent/test'

class StallTest < Test::Unit::TestCase
  class Stall
    attr_reader :log
    def initialize
      @log = $log
    end
  end

  setup do
    Fluent::Test.setup
  end

  20.times do |i|
    test "stall #{i}" do
      assert { Stall.new.log }
    end
  end
end
```

Becasue all stalled tests don't need to use block, I remove these blocks
to avoid this issue.

Fix #3543

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
@fujimotos fujimotos self-requested a review December 21, 2021 03:37
@fujimotos
Copy link
Member

I was initially confused by this patch, thinking "welp, isn't this patch
just removing spaces? Where's the actual diff?", and realized that the
fix is about converting {} to ().
Maybe I need to buy a pair of glasses.

@ashie ashie merged commit 85ff1a3 into master Dec 21, 2021
@ashie ashie deleted the fix-staled-tests-on-ruby3.1 branch December 21, 2021 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants