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

Add the ERL_SYS_SHELL env variable to point to system shell for os:cmd() #8972

Open
wants to merge 2 commits into
base: maint
Choose a base branch
from

Conversation

yarisx
Copy link
Contributor

@yarisx yarisx commented Oct 22, 2024

A fix for #8944

Copy link
Contributor

github-actions bot commented Oct 22, 2024

CT Test Results

    2 files     69 suites   1h 4m 55s ⏱️
1 534 tests 1 291 ✅ 242 💤 1 ❌
1 748 runs  1 473 ✅ 274 💤 1 ❌

For more details on these failures, see this check.

Results for commit 98e2413.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@garazdawi
Copy link
Contributor

Hello! Thanks for the PR!

The variable should be a kernel configuration parameter that is set to the correct value when kernel is started. It also needs to be documented here and a testcase needs to be added to os_SUITE.

@garazdawi garazdawi self-assigned this Oct 22, 2024
@yarisx yarisx force-pushed the ymaslenn/8944_set_sys_shell branch from f3e7b34 to 94dde80 Compare October 23, 2024 08:37
@garazdawi
Copy link
Contributor

Thanks for the update! I've pushed a commit that renames the variable to os_cmd_shell which I think better describes what it does and also moved the shell detection logic to happen when we start instead of everytime we do os:cmd.

Would you mind updating the docs of os:cmd/2 to point to the docs for the configuration parameter so that users know where to find it?

Feel free to squash my commit into yours if you agree with my changes.

… for os:cmd/2

Initialize the parameter at startup

Fix the test - restore the old shell after the test
Add initialization to other tests that use os:cmd/2
Update os:cmd/2 description
@yarisx yarisx force-pushed the ymaslenn/8944_set_sys_shell branch from f71fc7a to 7af29a1 Compare October 24, 2024 10:26
@yarisx
Copy link
Contributor Author

yarisx commented Oct 24, 2024

I'm a bit confused by the test results. As I see one subtest in shell_history_custom_error/1 test failed with the timeout, but a similar subtest passed just fine. Moreover I don't see how this part of the functionality can be affected by my changes, and locally the test passed just fine. Could you give me a hint on what might cause the test to fail?

Copy link
Contributor

@garazdawi garazdawi left a comment

Choose a reason for hiding this comment

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

I think there might be a race in that testcase that you've had the misfortune of hitting, so you can ignore that.

However, the os:internal_init_os_cmd/1 should not need to be called in all those test suites. The testcase needs to make sure that it resets the state (as you have done). Why did you add them?

Also could you please add a test that uses ?CT_PEER to start a new code where the config parameter is set at startup to see that that works. I don't think os:cmd is used anywhere when booting Erlang so we should be safe.

lib/kernel/src/os.erl Show resolved Hide resolved
lib/kernel/test/os_SUITE.erl Outdated Show resolved Hide resolved
lib/kernel/test/os_SUITE.erl Outdated Show resolved Hide resolved
Co-authored-by: Lukas Backström (FKA Larsson) <[email protected]>
@yarisx
Copy link
Contributor Author

yarisx commented Oct 25, 2024

I added os:internal_init_os_cmd/1 because locally the tests that contain os:cmd/2 (at least some of them) crashed with badmatch at {ok, Shell} = application:get_env() in os:mk_cmd/2.
I will add the test with ?CT_PEER

@garazdawi
Copy link
Contributor

I added os:internal_init_os_cmd/1 because locally the tests that contain os:cmd/2 (at least some of them) crashed with badmatch at {ok, Shell} = application:get_env() in os:mk_cmd/2.

How odd, can you remove them and see if that happens in github ci as well?

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.

2 participants