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

Fix $TEST_ENV_NUMBER replacing code to not affect all processes #905

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/parallel_tests/test/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def execute_command(cmd, process_number, num_processes, options)
cmd = ["nice", *cmd] if options[:nice]

# being able to run with for example `-output foo-$TEST_ENV_NUMBER` worked originally and is convenient
cmd.map! { |c| c.gsub("$TEST_ENV_NUMBER", number).gsub("${TEST_ENV_NUMBER}", number) }
cmd = cmd.map { |c| c.gsub("$TEST_ENV_NUMBER", number).gsub("${TEST_ENV_NUMBER}", number) }

print_command(cmd, env) if report_process_command?(options) && !options[:serialize_stdout]

Expand Down
5 changes: 5 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ def test_unicode
expect(result.gsub('"', '').chars.sort).to eq(['0', '2', '3', '4'])
end

it "can exec given commands with $TEST_ENV_NUMBER" do
result = run_tests ['-e', 'echo foo-$TEST_ENV_NUMBER'], processes: 4
expect(result.split(/\n+/).sort).to eq(['foo-', 'foo-2', 'foo-3', 'foo-4'])
end

it "can exec given command non-parallel" do
result = run_tests(
['-e', 'ruby -e "sleep(rand(10)/100.0); puts ENV[:TEST_ENV_NUMBER.to_s].inspect"'],
Expand Down