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-unit-activesupport doesn't support parallelize yet #13

Open
hiroyuki-sato opened this issue Nov 2, 2020 · 1 comment
Open

test-unit-activesupport doesn't support parallelize yet #13

hiroyuki-sato opened this issue Nov 2, 2020 · 1 comment

Comments

@hiroyuki-sato
Copy link

Rails6 introduced parallel methods

rails new command generates the following contents in test/test_helper.rb

class ActiveSupport::TestCase
  # Run tests in parallel with specified workers
  parallelize(workers: :number_of_processors)

  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

After test-unit setting, I execute rails test command and I got the following error.

Traceback (most recent call last):
	53: from -e:1:in `<main>'
	52: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	51: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require'
	50: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
	49: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
	48: from /private/tmp/test_unit_app/bin/rails:9:in `<main>'
	47: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
	46: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	45: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	44: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	43: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	42: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	41: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/commands.rb:18:in `<main>'
	40: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/command.rb:46:in `invoke'
	39: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-6.0.3.4/lib/rails/command/base.rb:69:in `perform'
	38: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	37: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	36: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	35: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-rails-6.0.0/lib/rails/commands/test/test_command.rb:34:in `perform'
	34: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/autorunner.rb:66:in `run'
	33: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/autorunner.rb:434:in `run'
	32: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/autorunner.rb:106:in `block in <class:AutoRunner>'
	31: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:38:in `collect'
	30: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:131:in `add_load_path'
	29: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:43:in `block in collect'
	28: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:43:in `each'
	27: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:46:in `block (2 levels) in collect'
	26: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:90:in `collect_recursive'
	25: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:90:in `each'
	24: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:92:in `block in collect_recursive'
	23: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:90:in `collect_recursive'
	22: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:90:in `each'
	21: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:92:in `block in collect_recursive'
	20: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:85:in `collect_recursive'
	19: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:85:in `each'
	18: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:87:in `block in collect_recursive'
	17: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:112:in `collect_file'
	16: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:136:in `add_load_path'
	15: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/test-unit-3.3.6/lib/test/unit/collector/load.rb:114:in `block in collect_file'
	14: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
	13: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	12: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	11: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	10: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	 9: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	 8: from /private/tmp/test_unit_app/test/channels/application_cable/connection_test.rb:1:in `<main>'
	 7: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.1/lib/zeitwerk/kernel.rb:33:in `require'
	 6: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	 5: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	 4: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	 3: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	 2: from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	 1: from /private/tmp/test_unit_app/test/test_helper.rb:8:in `<main>'
/private/tmp/test_unit_app/test/test_helper.rb:10:in `<class:TestCase>': undefined method `parallelize' for ActiveSupport::TestCase:Class (NoMethodError)

Workaround

comment(or remove) parallelize part

class ActiveSupport::TestCase
  # Run tests in parallel with specified workers
  #parallelize(workers: :number_of_processors) # <--- HERE

  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

environment

  • os: macOS 10.15.7
  • ruby: 2.7.2p137
  • rails: 6.0.3.4
@kou
Copy link
Member

kou commented Nov 4, 2020

Wow. I didn't know it.

We need to add support for parallelization to test-unit.

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

No branches or pull requests

2 participants