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

Tests fail when SHELL environment variable is set to /usr/bin/sh that soft links to /usr/bin/bash #4133

Closed
pondichys opened this issue Sep 18, 2024 · 2 comments · Fixed by #4148
Assignees
Labels
bug priority:highest Bugs filled by customers, security issues tests

Comments

@pondichys
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Command attempted

Download release 2.34 tarball and run go test with a user that has his shell set to /usr/bin/sh that links to /usr/bin/bash

I came across this problem while packaging the version 2.34 of the CLI for Void Linux. Package builds for Void happen in a CHROOT where the build user has /usr/bin/sh as SHELL environment variable.

The failing test is TestInit_Prompt/Simple.

Expected Behavior

As bash is a supported shell, the test should follow the link and succeed

Actual Behavior

Test fail with the following error

=== RUN   TestInit_Prompt/Simple
=== PAUSE TestInit_Prompt/Simple
=== CONT  TestInit_Prompt/Simple
    init_test.go:235:
                Error Trace:    /builddir/scaleway-cli-2.34.0/core/testing.go:661
                                                        /builddir/scaleway-cli-2.34.0/core/testing.go:596
                                                        /builddir/scaleway-cli-2.34.0/core/testing.go:462
                Error:          Not equal:
                                expected: "🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲\n🟩🟩🟩 STDOUT️ 🟩🟩🟩️\n✅ Initialization completed with success.\n  Except for SSH key: could not find an SSH key at ~/.ssh/id_rsa.pub\n🟩🟩🟩 JSON STDOUT 🟩🟩🟩\n{\n  \"message\": \"Initialization completed with success\",\n  \"details\": \"Except for SSH key: could not find an SSH key at ~/.ssh/id_rsa.pub\"\n}\n"
                                actual  : "🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲\n🟩🟩🟩 STDOUT️ 🟩🟩🟩️\n✅ Initialization completed with success.\n  Except for autocomplete: unsupported shell 'sh'\n  Except for SSH key: could not find an SSH key at ~/.ssh/id_rsa.pub\n🟩🟩🟩 JSON STDOUT 🟩🟩🟩\n{\n  \"message\": \"Initialization completed with success\",\n  \"details\": \"Except for autocomplete: unsupported shell 'sh'\\nExcept for SSH key: could not find an SSH key at ~/.ssh/id_rsa.pub\"\n}\n"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -3,2 +3,3 @@
                                 ✅ Initialization completed with success.
                                +  Except for autocomplete: unsupported shell 'sh'
                                   Except for SSH key: could not find an SSH key at ~/.ssh/id_rsa.pub
                                @@ -7,3 +8,3 @@
                                   "message": "Initialization completed with success",
                                -  "details": "Except for SSH key: could not find an SSH key at ~/.ssh/id_rsa.pub"
                                +  "details": "Except for autocomplete: unsupported shell 'sh'\nExcept for SSH key: could not find an SSH key at ~/.ssh/id_rsa.pub"
                                 }
                Test:           TestInit_Prompt/Simple
--- FAIL: TestInit_Prompt (0.00s)
    --- FAIL: TestInit_Prompt/Simple (0.00s)
FAIL
FAIL    github.com/scaleway/scaleway-cli/v2/internal/namespaces/init    0.018s

More info

Obviously the scw init command also run into this error if I accept the default detected shell

...
To enable autocomplete, scw needs to update your shell configuration.
What type of shell are you using (default: sh):


✅ Initialization completed with success.
  Except for autocomplete: unsupported shell 'sh'

I do get this is an edge case but it would be nice to be able to package with tests enabled and successful.

Best regards.

@remyleone
Copy link
Member

How could we detect that the shell 'sh' is in fact a bash? The tests are happening here: https://github.com/scaleway/scaleway-cli/blob/master/internal/namespaces/autocomplete/autocomplete.go#L195 and we check the SHELL environment variable.

@pondichys
Copy link
Author

Many thanks for the fix !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug priority:highest Bugs filled by customers, security issues tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants