Patch #44116 » 0001-Enable-parallel-tests-by-default.patch
| .gitignore | ||
|---|---|---|
|
/config/initializers/secret_token.rb
|
||
|
/coverage
|
||
|
/db/*.db
|
||
|
/db/*.sqlite3
|
||
|
/db/*.sqlite3-*
|
||
|
/db/*.sqlite3*
|
||
|
/db/schema.rb
|
||
|
/files/*
|
||
|
/lib/redmine/scm/adapters/mercurial/redminehelper.pyc
|
||
| doc/RUNNING_TESTS | ||
|---|---|---|
|
You can run `ruby test/unit/issue_test.rb` for running a single test case and
|
||
|
`ruby test/unit/issue_test.rb -n test_create` for running a single test.
|
||
|
You can run tests in parallel by setting the PARALLEL_WORKERS environment
|
||
|
variable:
|
||
|
Tests run in parallel by default, using the number of processors as the worker
|
||
|
count. You can change the worker count by setting the PARALLEL_WORKERS
|
||
|
environment variable:
|
||
|
`PARALLEL_WORKERS=8 bin/rails test`
|
||
|
Before running tests, you need to configure both development
|
||
| test/application_system_test_case.rb | ||
|---|---|---|
|
require_relative 'test_helper'
|
||
|
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||
|
parallelize(workers: 1)
|
||
|
DOWNLOADS_PATH = File.expand_path(File.join(Rails.root, 'tmp', 'downloads'))
|
||
|
# Allow running Capybara default server on custom IP address and/or port
|
||
| test/generators/controller_generator_test.rb | ||
|---|---|---|
|
require_relative '../../lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator'
|
||
|
class ControllerGeneratorTest < Rails::Generators::TestCase
|
||
|
TMP_DIR = Rails.root / 'tmp/test/generators'
|
||
|
TMP_DIR = Rails.root / 'tmp/test/generators/controller'
|
||
|
tests RedminePluginControllerGenerator
|
||
|
destination TMP_DIR
|
||
| test/generators/migration_generator_test.rb | ||
|---|---|---|
|
require_relative '../../lib/generators/redmine_plugin_migration/redmine_plugin_migration_generator'
|
||
|
class MigrationGeneratorTest < Rails::Generators::TestCase
|
||
|
TMP_DIR = Rails.root / 'tmp/test/generators'
|
||
|
TMP_DIR = Rails.root / 'tmp/test/generators/migration'
|
||
|
tests RedminePluginMigrationGenerator
|
||
|
destination TMP_DIR
|
||
| test/generators/model_generator_test.rb | ||
|---|---|---|
|
require_relative '../../lib/generators/redmine_plugin_model/redmine_plugin_model_generator'
|
||
|
class ModelGeneratorTest < Rails::Generators::TestCase
|
||
|
TMP_DIR = Rails.root / 'tmp/test/generators'
|
||
|
TMP_DIR = Rails.root / 'tmp/test/generators/model'
|
||
|
tests RedminePluginModelGenerator
|
||
|
destination TMP_DIR
|
||
| test/test_helper.rb | ||
|---|---|---|
|
end
|
||
|
class ActiveSupport::TestCase
|
||
|
parallelize(workers: 1)
|
||
|
parallelize(workers: :number_of_processors)
|
||
|
include ActionDispatch::TestProcess
|
||
| ... | ... | |
|
self.use_transactional_tests = true
|
||
|
self.use_instantiated_fixtures = false
|
||
|
parallelize_setup do |worker|
|
||
|
# Use a separate attachment directory for each worker.
|
||
|
$redmine_tmp_attachments_directory =
|
||
|
File.join($redmine_tmp_attachments_directory, worker.to_s)
|
||
|
FileUtils.mkdir_p $redmine_tmp_attachments_directory
|
||
|
# Use a separate thumbnail directory for each worker.
|
||
|
Attachment.thumbnails_storage_path =
|
||
|
File.join(Attachment.thumbnails_storage_path, worker.to_s)
|
||
|
FileUtils.mkdir_p Attachment.thumbnails_storage_path
|
||
|
end
|
||
|
# Clear Settings cache after each test to prevent test interference
|
||
|
teardown do
|
||
|
Setting.clear_cache
|
||