Skip to content

Commit

Permalink
Fix $TEST_ENV_NUMBER replacing code to not affect all processes (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiskoza committed May 12, 2023
1 parent f70f2ee commit 6363819
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parallel_tests/test/runner.rb
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
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

0 comments on commit 6363819

Please sign in to comment.