support/testing/utils: fix get-developers test without a tty

get-developers will check its stdin to decide whether it is a tty or
not, and behave differently whether it is or not. So, when we run the
tests, we need an actual tty.

However, when running in a CI pipeline, like on Gitlab-CI, there is no
tty available on stdin.

Fake one. We don't need anything too fancy, so just a slave pty will
suffice.

Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/8830671800
Fixes: d10d22221f (utils/get-developers: read patch from stdin when
it's not a tty)

Reported-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
Yann E. MORIN
2025-01-20 08:17:55 +01:00
committed by Julien Olivain
parent 44075c1955
commit 3778f704cd

View File

@@ -15,10 +15,16 @@ import infra
def call_script(args, env, cwd):
"""Call a script and return stdout and stderr as lists and the exit code."""
proc = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE,
# We need stdin to be a tty, not just a pipe or whatever
m_tty, s_tty = os.openpty()
proc = subprocess.Popen(args, cwd=cwd,
stdin=s_tty,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env,
universal_newlines=True)
out, err = proc.communicate()
os.close(s_tty)
os.close(m_tty)
return out.splitlines(), err.splitlines(), proc.returncode