Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ only add here if you are working on a PR

### Breaking Changes

- `test` is not a hardcoded environment for rake tasks

### Added

- Rake tasks will prioritize the `PARALLEL_RAILS_ENV` value over the standard `RAILS_ENV`, so setups where `RAILS_ENV` changes during the process will keep the `PARALLEL_RAILS_ENV` value (see https://github.com/grosser/parallel_tests/pull/776)

### Fixed

## 5.3.1 - 2025-07-23
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ TIPS
- Debug errors that only happen with multiple files using `--verbose` and [cleanser](https://github.com/grosser/cleanser)
- `export PARALLEL_TEST_PROCESSORS=13` to override default processor count
- `export PARALLEL_TEST_MULTIPLY_PROCESSES=.5` to override default processor multiplier
- `export PARALLEL_RAILS_ENV=environment_name` to override default `RAILS_ENV`
- Shell alias: `alias prspec='parallel_rspec -m 2 --'`
- [Spring] Add the [spring-commands-parallel-tests](https://github.com/DocSpring/spring-commands-parallel-tests) gem to your `Gemfile` to get `parallel_tests` working with Spring.
- `--first-is-1` will make the first environment be `1`, so you can test while running your full suite.<br/>
Expand Down
2 changes: 1 addition & 1 deletion lib/parallel_tests/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ParallelTests
module Tasks
class << self
def rails_env
'test'
ENV['PARALLEL_RAILS_ENV'] || ENV['RAILS_ENV'] || 'test'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

let's make this a non-breaking change:

Suggested change
ENV['PARALLEL_RAILS_ENV'] || ENV['RAILS_ENV'] || 'test'
ENV['PARALLEL_RAILS_ENV'] || 'test'

RAILS_ENV could be get by running rake environment parallel:prepare

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hum, the only option to set a different environment will be using PARALLEL_RAILS_ENV? RAILS_ENV will be discarded.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

yeah or we reopen #776

@mfilipe mfilipe Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hum, TBH I prefer the current solution implemented in this PR, but you are the parallel_tests maintainer (have a better overview of the gem project than me), so I can accept your suggestion and change the docs.

Probably I will need to pass PARALLEL_RAILS_ENV and RAILS_ENV in some situations, but at last it attends to my requirements (makes ParallelTests::Tasks.rails_env dynamic).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

using RAILS_ENV looks like a good solution, but I'm pretty sure it would open up old gotchas again
and given that it has been so stable with the current solution I'm rather reluctant to risk that :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done c3b0bbf

end

def load_lib
Expand Down
12 changes: 9 additions & 3 deletions spec/parallel_tests/tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@
end

describe ".rails_env" do
it "should be test" do
it "should be test when nothing was set" do
expect(ParallelTests::Tasks.rails_env).to eq("test")
end

it "should disregard whatever was set" do
it "should be whatever was set" do
ENV["RAILS_ENV"] = "foo"
expect(ParallelTests::Tasks.rails_env).to eq("test")
expect(ParallelTests::Tasks.rails_env).to eq("foo")
end

it "should prioritize the PARALLEL_RAILS_ENV value over the standard" do
ENV["RAILS_ENV"] = "foo"
ENV["PARALLEL_RAILS_ENV"] = "bar"
expect(ParallelTests::Tasks.rails_env).to eq("bar")
end
end

Expand Down