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

tests: use never instead of dont_allow #4671

Merged
merged 1 commit into from
Oct 18, 2024
Merged

Conversation

Watson1978
Copy link
Contributor

@Watson1978 Watson1978 commented Oct 16, 2024

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

What this PR does / why we need it:
If it use the object applied dont_allow in the other test through ObjectSpace.each_object, it will cause the error.
To relax object constraints, this patch will use never instead.

See sample code in #4063 (comment)

Docs Changes:

Release Note:

@Watson1978 Watson1978 force-pushed the use-never branch 2 times, most recently from 86c93d6 to 7b97c00 Compare October 16, 2024 10:26
@Watson1978 Watson1978 marked this pull request as ready for review October 17, 2024 00:34
Copy link
Contributor

@daipom daipom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix!
Please fix the following points.

test/plugin/out_forward/test_socket_cache.rb Outdated Show resolved Hide resolved
test/plugin/out_forward/test_socket_cache.rb Outdated Show resolved Hide resolved
test/plugin/out_forward/test_socket_cache.rb Outdated Show resolved Hide resolved
@daipom
Copy link
Contributor

daipom commented Oct 18, 2024

I'm checking if this failure on Windows has something to do with this change.

1) Failure: test: multiple values are set to RUBYOPT(TestFluentdCommand::configured to run 2 workers):
  log doesn't match.
  <"[7684, #<Thread:0x0000015755e11768 run>, #<NoMethodError: undefined method `ignored?' for #<Gem::Specification:0x000001575b219c98 @extension_dir=nil, @full_gem_path=nil, @gem_dir=nil, @ignored=nil, @bin_dir=nil, @cache_dir=nil, @cache_file=nil, @doc_dir=nil, @ri_dir=nil, @spec_dir=nil, @spec_file=nil, @gems_dir=\"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems\", @base_dir=\"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0\", @loaded=false, @activated=false, @loaded_from=\"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/specifications/power_assert-2.0.4.gemspec\", @original_platform=nil, @installed_by_version=#<Gem::Version \"3.3.27\">, @autorequire=nil, @date=2024-10-03 00:00:00 UTC, @description=\"Power Assert shows each value of variables and method calls in the expression. It is useful for testing, providing which value wasn't correct when the condition is not satisfied.\", @email=[\"[email protected]\"], @homepage=\"[https://github.com/ruby/power_assert\](https://github.com/ruby/power_assert/)", @name=\"power_assert\", @post_install_message=nil, @signing_key=nil, @summary=\"Power Assert for Ruby\", @version=#<Gem::Version \"2.0.4\">, @authors=[\"Kazuki Tsujimoto\"], @bindir=\"exe\", @cert_chain=[], @dependencies=[], @executables=[], @extensions=[], @extra_rdoc_files=[\"README.md\"], @files=[\"README.md\"], @licenses=[\"BSD-2-Clause\", \"Ruby\"], @metadata={}, @platform=\"ruby\", @rdoc_options=[\"--main\", \"README.md\"], @require_paths=[\"lib\"], @required_ruby_version=#<Gem::Requirement:0x000001575b219ab8 @requirements=[[\">=\", #<Gem::Version \"0\">]]>, @required_rubygems_version=#<Gem::Requirement:0x000001575b219900 @requirements=[[\">=\", #<Gem::Version \"0\">]]>, @requirements=[], @rubygems_version=\"3.3.27\", @specification_version=4, @test_files=[], @new_platform=\"ruby\", @full_name=\"power_assert-2.0.4\" power_assert-2.0.4>\r\n" +
  "Did you mean?  ignored=>, [\"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:2163:in `method_missing'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:273:in `reject'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:273:in `matching_specs'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/dependency.rb:303:in `to_specs'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1080:in `block in unresolved_specs'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1080:in `map'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1080:in `unresolved_specs'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1058:in `find_in_unresolved'\", \"<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:101:in `require'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:298:in `<module:Gem>'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:25:in `<top (required)>'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `require_relative'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `<top (required)>'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `require_relative'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `<top (required)>'\", \"<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\", \"<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\"]]\r\n" +
  "[7684, #<Thread:0x0000015755e11768 run>, #<RuntimeError: CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before false -> after true>, [\"<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:167:in `ensure in require'\", \"<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:167:in `require'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:298:in `<module:Gem>'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:25:in `<top (required)>'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `require_relative'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `<top (required)>'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `require_relative'\", \"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `<top (required)>'\", \"<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\", \"<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\"]]\r\n" +
  "<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:167:in `ensure in require': CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before false -> after true (RuntimeError)\r\n" +
  "\tfrom <internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:167:in `require'\r\n" +
  "<internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:167:in `ensure in require': CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before false -> after true (RuntimeError)\r\n" +
  "\tfrom <internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:167:in `require'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:298:in `<module:Gem>'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:25:in `<top (required)>'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `require_relative'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `<top (required)>'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `require_relative'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `<top (required)>'\r\n" +
  "\tfrom <internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\r\n" +
  "\tfrom <internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\r\n" +
  "C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:2163:in `method_missing': undefined method `ignored?' for #<Gem::Specification:0x000001575b219c98 @extension_dir=nil, @full_gem_path=nil, @gem_dir=nil, @ignored=nil, @bin_dir=nil, @cache_dir=nil, @cache_file=nil, @doc_dir=nil, @ri_dir=nil, @spec_dir=nil, @spec_file=nil, @gems_dir=\"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems\", @base_dir=\"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0\", @loaded=false, @activated=false, @loaded_from=\"C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/specifications/power_assert-2.0.4.gemspec\", @original_platform=nil, @installed_by_version=#<Gem::Version \"3.3.27\">, @autorequire=nil, @date=2024-10-03 00:00:00 UTC, @description=\"Power Assert shows each value of variables and method calls in the expression. It is useful for testing, providing which value wasn't correct when the condition is not satisfied.\", @email=[\"[email protected]\"], @homepage=\"[https://github.com/ruby/power_assert\](https://github.com/ruby/power_assert/)", @name=\"power_assert\", @post_install_message=nil, @signing_key=nil, @summary=\"Power Assert for Ruby\", @version=#<Gem::Version \"2.0.4\">, @authors=[\"Kazuki Tsujimoto\"], @bindir=\"exe\", @cert_chain=[], @dependencies=[], @executables=[], @extensions=[], @extra_rdoc_files=[\"README.md\"], @files=[\"README.md\"], @licenses=[\"BSD-2-Clause\", \"Ruby\"], @metadata={}, @platform=\"ruby\", @rdoc_options=[\"--main\", \"README.md\"], @require_paths=[\"lib\"], @required_ruby_version=#<Gem::Requirement:0x000001575b219ab8 @requirements=[[\">=\", #<Gem::Version \"0\">]]>, @required_rubygems_version=#<Gem::Requirement:0x000001575b219900 @requirements=[[\">=\", #<Gem::Version \"0\">]]>, @requirements=[], @rubygems_version=\"3.3.27\", @specification_version=4, @test_files=[], @new_platform=\"ruby\", @full_name=\"power_assert-2.0.4\" power_assert-2.0.4> (NoMethodError)\r\n" +
  "Did you mean?  ignored=\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:273:in `reject'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:273:in `matching_specs'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/dependency.rb:303:in `to_specs'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1080:in `block in unresolved_specs'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1080:in `map'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1080:in `unresolved_specs'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/specification.rb:1058:in `find_in_unresolved'\r\n" +
  "\tfrom <internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:101:in `require'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:298:in `<module:Gem>'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/rubygems_ext.rb:25:in `<top (required)>'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `require_relative'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler.rb:10:in `<top (required)>'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `require_relative'\r\n" +
  "\tfrom C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/gems/3.1.0/gems/bundler-2.5.22/lib/bundler/setup.rb:6:in `<top (required)>'\r\n" +
  "\tfrom <internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\r\n" +
  "\tfrom <internal:C:/hostedtoolcache/windows/Ruby/3.1.6/x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'\r\n">
  was expected to include:
  <["#0 fluentd worker is now running worker=0"]>
  and not include:
  <["(LoadError)"]>
D:/a/fluentd/fluentd/test/command/test_fluentd.rb:219:in `assert_log_matches'
D:/a/fluentd/fluentd/test/command/test_fluentd.rb:941:in `block (2 levels) in <class:TestFluentdCommand>'
     938: </match>
     939: CONF
     940:       conf_path = create_conf_file('rubyopt_test.conf', conf)
  => 941:       assert_log_matches(
     942:         create_cmdline(conf_path),
     943:         '#0 fluentd worker is now running worker=0',
     944:         patterns_not_match: ['(LoadError)'],

@daipom
Copy link
Contributor

daipom commented Oct 18, 2024

I have confirmed those Windows failures have nothing to do with this change.

Currently, multiple values are set to RUBYOPT(TestFluentdCommand::configured to run 2 workers) fails on Ruby 3.1, 3.0 on Windows.
We need to solve this in another PR.

Copy link
Contributor

@daipom daipom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@daipom daipom merged commit a2b935a into fluent:master Oct 18, 2024
10 of 16 checks passed
@Watson1978 Watson1978 deleted the use-never branch October 18, 2024 03:11
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.

CI: Some tests about signal handlers sometimes fail
2 participants