test: fixing failing system_tests/run_command under some Locales #30788

pull jadijadi wants to merge 1 commits into bitcoin:master from jadijadi:fix-system-test-locale changing 1 files +2 −2
  1. jadijadi commented at 1:12 pm on September 2, 2024: contributor

    the run_command test under system_tests fails if the locale is anything other than English ones because results such as “No such file or directory” will be different under Non-English locales.

    On the old version, a ls nonexistingfile was used to generate the error output which is not ideal. In the current version we are using a Python one-liner to generate a non 0 zero return value and “err” on stderr and check the expected value against this.

    fixes https://github.com/bitcoin/bitcoin/issues/30608

  2. maflcko commented at 1:24 pm on September 2, 2024: member

    Seems fine as a fix, but it seems incomplete, because the test may still fail if the file exists.

    The test only wants to check the stderr and exit code, so instead of using ls, it may be easier to use a python command (https://github.com/bitcoin/bitcoin/pull/29868#discussion_r1740457415), or something similar.

  3. maflcko commented at 1:29 pm on September 2, 2024: member
    Also, the commit message is wrong echo success is never translated, because echo is just a tool to echo something, not to translate a passed string.
  4. DrahtBot commented at 11:15 pm on September 2, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hebasto, maflcko, achow101

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #29868 (Reintroduce external signer support for Windows by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. jadijadi force-pushed on Sep 3, 2024
  6. jadijadi commented at 12:20 pm on September 3, 2024: contributor

    Also, the commit message is wrong echo success is never translated, because echo is just a tool to echo something, not to translate a passed string.

    you are right and thanks for mentioning it. fixed the message

  7. jadijadi force-pushed on Sep 3, 2024
  8. jadijadi force-pushed on Sep 3, 2024
  9. jadijadi commented at 12:50 pm on September 3, 2024: contributor

    The test only wants to check the stderr and exit code, so instead of using ls, it may be easier to use a python command (#29868 (comment)), or something similar.

    Agree with your solution. Python one-liner is cleaner and more reliable. Used that one so we do not need the Locale anymore. tests pass both in PT and C locale.

    by the way since you are working on this in a larger scale, I can close my PR and wait for a full fix via yours.

  10. maflcko commented at 12:53 pm on September 3, 2024: member
    Looks good. Make sure to adjust the pull request description, now that the approach has changed.
  11. maflcko commented at 6:49 pm on September 3, 2024: member

    review ACK 8289373ebf089d0719a8edecb8bfbd52c244f4ee

    Please adjust the pull request description, now that the approach has changed: #30788#issue-2500949706

  12. DrahtBot added the label Tests on Sep 4, 2024
  13. test: fixing failing system_tests/run_command under some Locales
    the run_command test under system_tests fails if the locale is anything
    other than English ones because results such as "No such file or directory"
    will be different under Non-English locales.
    
    On the old version, a `ls nonexistingfile` was used to generate the error
    output which is not ideal. In the current version we are using a Python one-liner
    to generate a non 0 zero return value and "err" on stderr and check the
    expected value against this.
    
    fixes #30608
    ae48a22a3d
  14. jadijadi force-pushed on Sep 4, 2024
  15. jadijadi commented at 6:04 am on September 4, 2024: contributor

    review ACK 8289373

    Please adjust the pull request description, now that the approach has changed: #30788 (comment)

    Done. The PR description (https://github.com/bitcoin/bitcoin/pull/30788#issue-2500949706) is updated to reflect the changes in the commit message.

  16. maflcko commented at 6:08 am on September 4, 2024: member
    Please update the pull request description properly. There is no need to include incorrect stuff (echo success isn’t translated), or outdated stuff of a previous commit. Please focus on the important and correct details only.
  17. hebasto approved
  18. hebasto commented at 6:30 am on September 4, 2024: member

    ACK ae48a22a3df086fb59843b7b814619ed5df7557b, tested on Ubuntu 24.04 by switching locale.

    #30788#issue-2500949706

    the run_command test under system_tests fails if the locale is anything other than US/UK/C (English ones) because it checks for things like result.find_value("success");

    To prevent this, a setenv("LC_ALL", "C", 1); is added to make sure that the tests are being run under C locale even if something else is set in the terminal.

    fixes #30608

    Update: based on below discussions, the solution is changed. Now we are using a python one-liner to 1. return a non zero value and 2. output “err” on stderr and check the run against this which is more reliable than using “ls nonexistencefile” and hope for error. The commit message have been updated accordingly.

    The second paragraph should be dropped, I guess.

  19. DrahtBot requested review from maflcko on Sep 4, 2024
  20. maflcko commented at 6:33 am on September 4, 2024: member
    The commit description looks fine, so why not copy-paste it and replace the pull request description?
  21. maflcko commented at 6:34 am on September 4, 2024: member
    review ACK ae48a22a3df086fb59843b7b814619ed5df7557b
  22. jadijadi commented at 7:13 am on September 4, 2024: contributor

    The commit description looks fine, so why not copy-paste it and replace the pull request description?

    just did. thanks.

  23. achow101 added this to the milestone 28.0 on Sep 4, 2024
  24. achow101 commented at 7:19 pm on September 4, 2024: member
    ACK ae48a22a3df086fb59843b7b814619ed5df7557b
  25. achow101 merged this on Sep 4, 2024
  26. achow101 closed this on Sep 4, 2024

  27. achow101 added the label Needs backport (28.x) on Sep 4, 2024
  28. fanquake referenced this in commit 199bb09d88 on Sep 5, 2024
  29. fanquake removed the label Needs backport (28.x) on Sep 5, 2024
  30. fanquake commented at 8:44 am on September 5, 2024: member
    Backported to 28.x in #30762.
  31. hebasto commented at 11:07 am on September 5, 2024: member
    Apparently, this PR made this test dependent on the Python executable, which should be reflected in the build system, I guess.
  32. maflcko commented at 11:14 am on September 5, 2024: member

    The tests already depend on Python and ctest can already not be run without it. See also doc/dependencies.md:

    0| [Python](https://www.python.org) (scripts, tests) | [3.9](https://github.com/bitcoin/bitcoin/pull/28211) |
    

    If you find an alternative command, maybe based on GNU Coreutils that achieves the same, feel free to replace it.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-24 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me