Add stderr/stdin stream control for console utilities.

Review Request #12246 — Created April 21, 2022 and submitted — Latest diff uploaded

Information

RBTools
release-3.x

Reviewers

This adds stderr and stdin control for get_input(), get_pass(),
confirm(), and confirm_select() utilities. When hooked up properly,
this enables unit tests to automate code paths that require user input.

If stdin is a TTY, these will prompt the user for input as normal.
Otherwise, they'll read a line from stdin. This allows for scripting
inputs.

While here, a few additional tweaks were made to these very old
utilities:

  • confirm() no longer uses a private method in distutils to check
    for Yes/No input strings. Instead, the checks are now under our
    control.

  • confirm() and confirm_select() now show bad user input in quotes.

Unit tests were also added for all these functions.

Unit tests pass.

Commits

Files