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

Conversation

kiskoza
Copy link
Contributor

@kiskoza kiskoza commented May 10, 2023

Hi. I was trying to create a small script running some custom tests in parallel where I need the TEST_ENV_NUMBER in an other ENV variable, so I naturally tried to reassing it, something like this:

parallel_test -n 3 --first-is-1 -e 'bash -c "export CI_NODE_TOTAL=3 && export CI_NODE_INDEX=$TEST_ENV_NUMBER && echo $CI_NODE_INDEX / $CI_NODE_TOTAL"'

However, it printed 1 / 3 for all processes instead of 1 / 3, 2 / 3 and 3 / 3. Then I found this line that replaces $TEST_ENV_NUMBER and ${TEST_ENV_NUMBER} with the current number by modifying the original cmd array which affects all the other processes as there won't be $TEST_ENV_NUMBER substring in them anymore.

I added one spec that initially failed on the branch and got fixed by my change, I hope I found the right place for it.

Let me know if you need anything else :)

Checklist

  • Feature branch is up-to-date with master (if not - rebase it).
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • Update Readme.md when cli options are changed

@grosser
Copy link
Owner

grosser commented May 12, 2023

awesome bugfix and great test, thx!

you might want to use the actual parallel unix command, which is much more lightweight :)

@grosser grosser merged commit 6363819 into grosser:master May 12, 2023
13 checks passed
@grosser
Copy link
Owner

grosser commented May 12, 2023

4.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants