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

Add a fallback from 'test:prepare' #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions lib/rails/perftest/railties/testing.tasks
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ namespace :test do
task 'perftest:benchmark_mode' do
ENV["BENCHMARK_TESTS"] = '1'
end
if Rake::Task.task_defined?('test:prepare')
Copy link
Member

Choose a reason for hiding this comment

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

Could the if statement be used to just determine the tasks dependencies? This would get us around copying everything.

dependencies = if ...

Rails::SubTestTask.new(benchmark: [*dependencies, 'test:perftest:benchmark_mode']) do |t|
  t.libs << 'test'
  t.pattern = 'test/performance/**/*_test.rb'
end

Copy link
Author

Choose a reason for hiding this comment

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

should we still have the fallback to db:test:prepare or is there something that you would prefer instead?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the db:test:prepare dependency is necessary. It's executed on demand when test_help.rb is loaded.

Rails::SubTestTask.new(benchmark: ['test:prepare', 'test:perftest:benchmark_mode']) do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end

Rails::SubTestTask.new(benchmark: ['test:prepare', 'test:perftest:benchmark_mode']) do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end
Rails::SubTestTask.new(profile: 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end
else
Rails::SubTestTask.new(benchmark: ['db:test:prepare', 'test:perftest:benchmark_mode']) do |t|
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need the db:test:prepare dependency? In newer versions of Rails the test database in maintained when running a test. This is ensured by the method ActiveRecord::Migration.maintain_test_schema! in test_help.rb. Since test_help.rb is required by the generated test_helper.rb it's always triggered when running a test.

t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end

Rails::SubTestTask.new(profile: 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
Rails::SubTestTask.new(profile: 'db:test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end
end
end