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