Conversation
| def self.create(count) | ||
| ENV["PARALLEL_TEST_FIRST_IS_1"] = "true" | ||
| command = ["bundle", "exec", "rake", "db:create", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"] | ||
| args = { count: count.to_s } | ||
| ParallelTests::Tasks.run_in_parallel(command, args) | ||
| end |
There was a problem hiding this comment.
I'm not sure if it should be added to the Runner.
I understand it'd be nicer to reduce the number of steps on the user side. But in this case, it seems, that wrapping two commands in a bash/rake command fits better.
| Create test databases | ||
|
|
||
| ```bash | ||
| $ bundle exec turbo_tests --create | ||
| ``` |
There was a problem hiding this comment.
Create test databases before running tests
- Start
TEST_ENV_NUMBERfrom1
export PARALLEL_TEST_FIRST_IS_1=true- Create databases
bundle exec rake db:create RAILS_ENV=testThere was a problem hiding this comment.
That doesn't create the necessary test databases. That will just create a single "_test" database, not one database per cpu.
Here is your suggestion:
❯ export PARALLEL_TEST_FIRST_IS_1=true
❯ bundle exec rake db:create RAILS_ENV=test
Database 'myapp_test' already exists
Here is my suggestion with this PR:
❯ bundle exec turbo_tests --create
Database 'myapp_test5' already exists
Database 'myapp_test9' already exists
Database 'myapp_test10' already exists
Database 'myapp_test1' already exists
Database 'myapp_test3' already exists
Database 'myapp_test7' already exists
Database 'myapp_test8' already exists
Database 'myapp_test6' already exists
Database 'myapp_test2' already exists
Database 'myapp_test4' already exists
The way to do this without any changes to turbo_tests is first install the parallel_test gem as a direct dependency, and then run this:
❯ export PARALLEL_TEST_FIRST_IS_1=true
❯ bundle exec rake parallel:create
Database 'myapp_test3' already exists
Database 'myapp_test1' already exists
Database 'myapp_test9' already exists
Database 'myapp_test2' already exists
Database 'myapp_test8' already exists
Database 'myapp_test5' already exists
Database 'myapp_test6' already exists
Database 'myapp_test10' already exists
Database 'myapp_test4' already exists
Database 'myapp_test7' already exists
But the problem with this is it it requires having the parallel_tests gem installed as a direct dependency. And this is a direct dependency that is only used for the purpose of this one-time command. With my PR, the user is no longer required to install parallel_tests as a direct dependency. They can just install turbo_tests which acts as their gateway to parallel_tests.
|
seems reasonable to document this even if not done automatically? |
|
any word on this? seems like a worthwhile addition that will make first time setup easier |
|
It looks like this gem is going to have parallel_tests as a direct hard dependency going forward, but regardless this would still be useful to keep the commands within the same namespace, as it is odd to use some commands of parallel_tests, and others of turbo_tests. |
Improve the initial setup experience by allowing the user to run
bundle exec turbo_tests --createto create the databases. Also add documentation regarding this new onboarding process. This may help with #12 being less of a hurdle for users coming over from parallel_tests, as well as brand new users.